diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-04-03 15:54:50 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-04-03 15:54:50 +0200 |
commit | 23ee6b1cd6dc597876d91db9a015f7a633764808 (patch) | |
tree | 1f1901d6dd52eabc360fa1e5184875be06cd3b0f /proto/bgp/packets.c | |
parent | a22c3e59683d0ea6c379a37f990e74a6d281ccef (diff) |
BGP: Promiscuous ASN mode
Allow to specify just 'internal' or 'external' for remote neighbor
instead of specific ASN. In the second case that means BGP peers with
any non-local ASNs are accepted.
Diffstat (limited to 'proto/bgp/packets.c')
-rw-r--r-- | proto/bgp/packets.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index fc572a21..0e142a7a 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -732,13 +732,18 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, uint len) if ((as4 != asn) && (asn != AS_TRANS)) log(L_WARN "%s: Peer advertised inconsistent AS numbers", p->p.name); - if (as4 != p->remote_as) + /* When remote ASN is unspecified, it must be external one */ + if (p->remote_as ? (as4 != p->remote_as) : (as4 == p->local_as)) { as4 = htonl(as4); bgp_error(conn, 2, 2, (byte *) &as4, 4); return; } + + conn->received_as = as4; } else { - if (asn != p->remote_as) + if (p->remote_as ? (asn != p->remote_as) : (asn == p->local_as)) { bgp_error(conn, 2, 2, pkt+20, 2); return; } + + conn->received_as = asn; } /* Check the other connection */ |