Routing – BGP Decision process priority vs Longest match

bgprouting

tl;dr Which is looked at first, longest match or the BGP decision process

I'm taking a course on BGP right now and trying to figure out how these two routing processes work together.

I know that a more specific route is preferred in the router over a less specific one (192.0.0.0/25 will always be chosen over 192.0.0.0/24)
I also know how the BGP decision process works (Local pref is looked at before AS_Path, ect)

So my question is, if an AS has 2 neighbors, and it advertises a more specific network to one of them than the other, then some other AS down the line gets both of those advertisements, will longest match take affect automatically and the more specific one will automatically be chosen? Or does the BGP decision process happen first, therefore only one of the routes is put into the route table and longest match has no impact on it at all?

Hope I explained that in a way that makes sense. Thanks for the help

Best Answer

Don't confuse the BGP process and tables with the routing table used by the router to switch packets. The BGP table can contain both the longer and shorter prefixes, and BGP can advertise both to other neighbors.

The route selection in a router will install the longest match in its routing table, assuming it is presented with both matches, but that doesn't remove the shorter prefix from the BGP table. BGP can be set to prefer the shortest match, and that may be the one presented to the routing table.