Skip to content

Commit

Permalink
Merge pull request #17713 from opensourcerouting/fix/backport_b6dcf61…
Browse files Browse the repository at this point in the history
…8777bb7a11176617d647e16ab64f49b7b_10.1

bgpd: Fix `enforce-first-as` per peer-group removal (backport)
  • Loading branch information
Jafaral authored Dec 23, 2024
2 parents ff61f9a + 8a1737d commit 65daeaa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -18634,7 +18634,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))
Expand Down
9 changes: 7 additions & 2 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1568,8 +1568,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);
Expand Down

0 comments on commit 65daeaa

Please sign in to comment.