2

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

1

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.

  • 1
    Actually both routes will be installed in the routing table. But when a routing decision is made, longest match wins, of course. – Ron Trunk Dec 4 '15 at 17:42
  • @RonTrunk, if you use prefix filters and permit or deny on lengths, you can have both in the BGP table, but only the shortest match in the routing table. – Ron Maupin Dec 4 '15 at 17:45
  • Just clarifying, with a "default" BGP implementation, no prefix filtering, the router getting two advertisements for the same IP will install the longest match in its table, but still advertises both routes to its neighbors? Thanks! – Shahad Dec 4 '15 at 17:54
  • @Shahad, in a default situation, it will have both prefixes in its BGP table, but the routing table will only end up with the longest match. The routing table process takes the best routes offered by all routing processes. BGP will advertise all the routes in the BGP table to its neighbors. – Ron Maupin Dec 4 '15 at 18:02
  • @Shahad BGP will offer both prefixes for the next level of route selection. Usually both prefixes will be installed in the routing table. At packet forwarding time (data plane), the longest prefix will win of course. – Everton Jan 4 '16 at 20:48
1

Longest Match will always be looked at first. A /25 RIP route will be preferred over a /24 EIGRP/OSPF/BGP/anything route.

  • 1
    I understand that if there are two routes in the route table longest match will always be looked at first. But I was under the impression that BGP only put one route per network into the route table. Or does it put one entry per prefix instead of one per network? – Shahad Dec 4 '15 at 18:01
  • The RIB carries both network and prefix information – user6423 Jan 4 '16 at 20:31
  • 1
    @Shahad For BGP, the prefix length is part of the prefix. So 192.0.0.0/25 is a completely distinct prefix from 192.0.0.0/24. Then BGP will offer both to the next level of route selection. – Everton Jan 4 '16 at 20:44
1

Please notice the control plane processing (BGP) runs asynchronously from the data plane forwarding. For BGP, because 192.0.0.0/25 prefix is distinct from 192.0.0.0/24, the protocol won't even try to choose between those prefixes, so both prefixes will be sent for the forwarding plane. At forwarding time, of course the longest prefix is going to take precedence for packet switching decision.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.