BGP: Local Policy First, Shortest Route Only as a Tie-Break
Technical
Two networks can both offer a way to reach the same block of addresses, and the router that hears both keeps one of them. The rule it uses to choose is not in the protocol specification, which says as much in a single sentence. Four documents are enough to follow what that omission produced, and two of them exist only to report what went wrong.
Preference is read before anything is compared
Of the four, one specifies a protocol. The Border Gateway Protocol is set out in RFC 4271, published in January 2006, and the other three describe, between them, a failure nobody could define, a failure nobody configured, and a repair. Start with the specification, because the rest of them answer to one line in it.
A router running the protocol does not keep a single list of routes. It holds what each neighbour has offered it, decides what to use itself, and separately what to pass on. What gets offered is a block rather than one address, written in the notation whose trailing number counts the bits held fixed. RFC 4271 calls the middle step the Decision Process, and describes it as the application of a local rule rather than a weighing of candidates: it works by “applying the policies in the local Policy Information Base (PIB) to the routes stored in its Adj-RIBs-In”.
Phase one assigns a number, and the operator supplies it. For an offer learned from outside the network, “the local BGP speaker computes the degree of preference based on preconfigured policy information”. Then comes the line the other three documents answer to: “The exact nature of this policy information, and the computation involved, is a local matter.”
Mind when that number is worked out. The function producing it may not take three things as inputs: “the existence of other routes, the non-existence of other routes, or the path attributes of other routes”. Every offer is scored on its own, before anything is set against anything else. By the time two routes to one destination meet, each already carries a figure somebody chose for their own reasons, and it says nothing at all about the other.
Shortest counts, and only among equals
There is a tie-break list, and it is both ordered and mandatory. It opens by narrowing what it applies to: “a BGP speaker may have several routes to the same destination that have the same degree of preference”, and the procedure “begins by considering all equally preferable routes to the same destination”. Inside that set, “The criteria MUST be applied in the order specified.”
Counting networks is the first criterion. Among routes already tied on preference, the one recording the fewest autonomous systems between here and the destination stays and the others are dropped. Counting them is a narrower job than identifying any one of them, which is the work a single number in a routing record does.
Distance is therefore real, and it is a tie-break. RFC 4264, a problem statement from November 2005, states the ordering from the operator’s side rather than the protocol’s: “the local preference overrides the AS path length metric of the base BGP operation.”
One more decision is pushed outside. Whether a route learned this way should beat a route to the same destination from some other source “is a local policy decision, and is not specified in this document”. All of it is settled long before you see anything, which is why asking about a routable destination returns something that reads as a plain fact and is really a single result with no runners-up.
What gets broken is held outside the protocol
By June 2016 the industry had a name for a systemic weakness in this arrangement and no agreed account of what the name meant. RFC 7908 was written to supply one, and puts the gap in its own abstract: incidents that disrupt routing are called route leaks, but “to date a common definition of the term has been lacking”. A document that exists to define a word already in wide use is worth reading for whatever the word was covering up.
Its working definition runs to one sentence. “A route leak is the propagation of routing announcement(s) beyond their intended scope.” The clause after it says whose intention is at stake, because such an offer is “in violation of the intended policies of the receiver, the sender, and/or one of the ASes along the preceding AS path”.
Then the part that explains why nothing stops it. That scope “is usually defined by a set of local redistribution/filtering policies distributed among the ASes involved”, and those policies are “defined in terms of the pair-wise peering business relationship between ASes”. What gets violated is a commercial agreement, held as configuration spread across several operators, and the protocol as specified in 2006 carried no field that recorded it.
A leak is therefore well formed. RFC 7908’s first worked example succeeds “because the second ISP prefers customer announcement over peer announcement of the same prefix”, which is the preference rule from the section above behaving exactly as configured. Nothing in the design is meant to catch it, and RFC 4264 is explicit that BGP “contains no specific mechanisms to prevent the unauthorized modification of the information by a forwarding agent”. In that example the traffic still arrives, by a longer route, and the practical way to notice is to look at which networks it crossed getting there.
Every policy looks rational where it was written
RFC 4264 opens by naming a belief before dismantling it. “It has commonly been assumed” that the protocol distributes reachability in a way that “creates forwarding paths in a deterministic manner”. What the memo sets out instead is a class of arrangements in which “forwarding states other than the intended state are equally stable”.
Its simplest situation runs like this. A network buys from two upstream providers and marks one connection primary and the other backup. The primary link fails, traffic moves to the backup, and the design has done its job. The primary link comes back, and the state does not. Each network above it is still preferring what a customer offered over what a peer offered, so nobody upstream has a reason to change anything, and nothing anywhere is misconfigured.
Getting back needs a deliberate outage. In the simplest case the intended state returns only if the network at the bottom takes down a working session, “even though it is carrying traffic”. Have that network split its address space instead, so each link is primary for one half and backup for the other, and “there is no eBGP peering that can be reset that will flip BGP back to the intended state”, leaving the remedy of withdrawing the backup offers altogether and running without them for a while.
Diagnosis is the uncomfortable part. These states “do not represent misconfiguration in the standard sense”, because “all policies may look completely rational locally, but their interaction across multiple routing entities can cause unintended outcomes”. One configuration admits several stable results, some of them “not consistent with the policy writer’s intent”, and which one you are living in turns on the order things happened rather than on anything you can read back afterwards. Putting it right takes administrative effort resting on “configuration knowledge that may not be locally available”.
Making the relationship part of the session
If each side has been acting on a private understanding of a shared relationship, the repair is to make both say it out loud. RFC 9234, a Standards Track document from May 2022, does that. It names the weakness in what came before, which marked routes by local setting alone, “with no check that the configuration corresponds to that of the External BGP (eBGP) neighbor”, and replaces it “with an in-band method for route leak prevention and detection”.
Each end now declares what it is to the other. A role is still configured locally, running from provider and customer through the lateral peer to the two route-server variants, but it is also sent when the session opens and checked against what comes back. The check is settled on the spot, because “If the Roles do not correspond, the BGP speaker MUST reject the connection” using a notification defined for the purpose. Disagreement about the relationship becomes a session that will not come up.
Note what has actually been encoded. Those labels “do not necessarily represent business relationships based on payment agreements”; they restrict where a route may be passed on. The compatibility rule then concedes the limit, because where it is sent and nothing comes back a speaker should “ignore the absence of the BGP Role Capability and proceed with session establishment”. It binds the ends that have implemented it and leaves the rest as they were.
Very little of this is visible from where you sit. What you can act on is narrower: a block has an operator, an operator has a policy, and the way to find out who to ask is the registry entry naming who holds the block. One line of the specification hands that policy to whoever runs each network, and the other three documents are all, in their own ways, reports on where the handover led.