]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Fix `enforce-first-as` per peer-group removal
authorDonatas Abraitis <donatas@opensourcerouting.org>
Sat, 21 Dec 2024 15:03:14 +0000 (17:03 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Sun, 22 Dec 2024 11:28:52 +0000 (13:28 +0200)
If we do `no neighbor PG enforce-first-as`, it wasn't working because the flag
was inherited incorrectly for the members of the peer-group.

Fixes: 322462920e2a2c8b73191c6eb5157d64cf4a593e ("bgpd: Enable enforce-first-as by default")
Closes: https://github.com/FRRouting/frr/issues/17702
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_vty.c
bgpd/bgpd.c

index 253f70cd870825588e877e65113a5fb8adbb15da..0f9631757c0ee8c4122551d0428f2cfdb527a2ad 100644 (file)
@@ -18812,7 +18812,11 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
 
        /* enforce-first-as */
        if (CHECK_FLAG(bgp->flags, BGP_FLAG_ENFORCE_FIRST_AS)) {
-               if (!peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS))
+               /* The `no` form is printed because by default this enforcing
+                * is enabled, thus we need to print it inverted.
+                * See peer_new().
+                */
+               if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS))
                        vty_out(vty, " no neighbor %s enforce-first-as\n", addr);
        } else {
                if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS))
index de506402ee8fe308738a145c2b80b89060a7ad4b..80e70219538f1d6ee521782981c08da89323ac2a 100644 (file)
@@ -1594,8 +1594,13 @@ struct peer *peer_new(struct bgp *bgp)
 
        SET_FLAG(peer->sflags, PEER_STATUS_CAPABILITY_OPEN);
 
-       if (CHECK_FLAG(bgp->flags, BGP_FLAG_ENFORCE_FIRST_AS))
-               peer_flag_set(peer, PEER_FLAG_ENFORCE_FIRST_AS);
+       /* By default this is enabled, thus we need to mark it as
+        * inverted in order to display correctly in the configuration.
+        */
+       if (CHECK_FLAG(bgp->flags, BGP_FLAG_ENFORCE_FIRST_AS)) {
+               SET_FLAG(peer->flags_invert, PEER_FLAG_ENFORCE_FIRST_AS);
+               SET_FLAG(peer->flags, PEER_FLAG_ENFORCE_FIRST_AS);
+       }
 
        if (CHECK_FLAG(bgp->flags, BGP_FLAG_SOFT_VERSION_CAPABILITY))
                peer_flag_set(peer, PEER_FLAG_CAPABILITY_SOFT_VERSION);