summaryrefslogtreecommitdiff
path: root/bgpd/bgp_packet.c
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2024-09-13 10:51:41 +0300
committerDonatas Abraitis <donatas@opensourcerouting.org>2024-09-13 10:51:41 +0300
commitcadfa693d618f56c9fcffd2cd227917f15953711 (patch)
treeac4c6e3d179b0078c343561cf6884746a6374416 /bgpd/bgp_packet.c
parentbf1fa1b2dfeebb4fefcf3655111f30a766b6bc6d (diff)
bgpd: Implement BGP dual-as feature
This is helpful for migrations, etc. The neighbor is configured with: ``` router bgp 65000 neighbor X local-as 65001 no-prepend replace-as dual-as ``` Neighbor X can use either 65000, or 65001 to peer with. Closes: https://github.com/FRRouting/frr/issues/13928 Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_packet.c')
-rw-r--r--bgpd/bgp_packet.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index fa03f1d21d..62be7ffbf7 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -2702,6 +2702,19 @@ static int bgp_notify_receive(struct peer_connection *connection,
inner.subcode == BGP_NOTIFY_OPEN_UNSUP_PARAM)
UNSET_FLAG(peer->sflags, PEER_STATUS_CAPABILITY_OPEN);
+ /* Resend the next OPEN message with a global AS number if we received
+ * a `Bad Peer AS` notification. This is only valid if `dual-as` is
+ * configured.
+ */
+ if (inner.code == BGP_NOTIFY_OPEN_ERR &&
+ inner.subcode == BGP_NOTIFY_OPEN_BAD_PEER_AS &&
+ CHECK_FLAG(peer->flags, PEER_FLAG_DUAL_AS)) {
+ if (peer->change_local_as != peer->bgp->as)
+ peer->change_local_as = peer->bgp->as;
+ else
+ peer->change_local_as = peer->local_as;
+ }
+
/* If Graceful-Restart N-bit (Notification) is exchanged,
* and it's not a Hard Reset, let's retain the routes.
*/