diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2015-03-29 21:24:47 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2015-03-29 21:24:47 +0200 |
commit | 2eadd36fa004d705a4003892d1639485eeaf8486 (patch) | |
tree | a32ef780cacbdb1446adbb7d5455b38ed58ff6d9 /proto/bgp | |
parent | 9aed29e605334d34d0e6a90fc172ee83d0274ad3 (diff) |
BGP: AS-wide unique router ID (RFC 6286) support
RFC 6286 relaxed rules for router IDs, allowing EBGP sessions between
routers with the same ID (but different ASN).
Diffstat (limited to 'proto/bgp')
-rw-r--r-- | proto/bgp/packets.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index 2d2a84b3..27d82729 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -943,7 +943,8 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, int len) if (hold > 0 && hold < 3) { bgp_error(conn, 2, 6, pkt+22, 2); return; } - if (!id || id == 0xffffffff || id == p->local_id) + /* RFC 6286 2.2 - router ID is nonzero and AS-wide unique */ + if (!id || (p->is_internal && id == p->local_id)) { bgp_error(conn, 2, 3, pkt+24, -4); return; } if ((conn->advertised_as != base_as) && (base_as != AS_TRANS)) @@ -978,8 +979,23 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, int len) break; case BS_OPENCONFIRM: - if ((p->local_id < id) == (conn == &p->incoming_conn)) - { + /* + * Description of collision detection rules in RFC 4271 is confusing and + * contradictory, but it is essentially: + * + * 1. Router with higher ID is dominant + * 2. If both have the same ID, router with higher ASN is dominant [RFC6286] + * 3. When both connections are in OpenConfirm state, one initiated by + * the dominant router is kept. + * + * The first line in the expression below evaluates whether the neighbor + * is dominant, the second line whether the new connection was initiated + * by the neighbor. If both are true (or both are false), we keep the new + * connection, otherwise we keep the old one. + */ + if (((p->local_id < id) || ((p->local_id == id) && (p->local_as < p->remote_as))) + == (conn == &p->incoming_conn)) + { /* Should close the other connection */ BGP_TRACE(D_EVENTS, "Connection collision, giving up the other connection"); bgp_error(other, 6, 7, NULL, 0); |