diff options
| author | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2024-12-22 22:48:23 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-22 22:48:23 -0600 |
| commit | 763ecdcd694aeb2e8bb0a78c98704536d9978331 (patch) | |
| tree | 3fee302b80e47caae461456f9be0a0a297e06990 | |
| parent | 9e3f285d2e3218a81f94082c9849a025cd9ed9fd (diff) | |
| parent | d893a04df675030363cd348b74a44cabdb765721 (diff) | |
Merge pull request #17712 from opensourcerouting/fix/backport_b6dcf618777bb7a11176617d647e16ab64f49b7b_10.2
bgpd: Fix `enforce-first-as` per peer-group removal (backport)
| -rw-r--r-- | bgpd/bgp_vty.c | 6 | ||||
| -rw-r--r-- | bgpd/bgpd.c | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 253f70cd87..0f9631757c 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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)) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index de506402ee..80e7021953 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -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); |
