Skip to content

Commit 6cc9540

Browse files
authored
Merge pull request #17714 from opensourcerouting/fix/backport_b6dcf618777bb7a11176617d647e16ab64f49b7b_10.0
bgpd: Fix `enforce-first-as` per peer-group removal (backport)
2 parents a2c3cfa + 327d08b commit 6cc9540

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

bgpd/bgp_vty.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18201,7 +18201,11 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
1820118201

1820218202
/* enforce-first-as */
1820318203
if (CHECK_FLAG(bgp->flags, BGP_FLAG_ENFORCE_FIRST_AS)) {
18204-
if (!peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS))
18204+
/* The `no` form is printed because by default this enforcing
18205+
* is enabled, thus we need to print it inverted.
18206+
* See peer_new().
18207+
*/
18208+
if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS))
1820518209
vty_out(vty, " no neighbor %s enforce-first-as\n", addr);
1820618210
} else {
1820718211
if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS))

bgpd/bgpd.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,13 @@ struct peer *peer_new(struct bgp *bgp)
15641564

15651565
SET_FLAG(peer->sflags, PEER_STATUS_CAPABILITY_OPEN);
15661566

1567-
if (CHECK_FLAG(bgp->flags, BGP_FLAG_ENFORCE_FIRST_AS))
1568-
peer_flag_set(peer, PEER_FLAG_ENFORCE_FIRST_AS);
1567+
/* By default this is enabled, thus we need to mark it as
1568+
* inverted in order to display correctly in the configuration.
1569+
*/
1570+
if (CHECK_FLAG(bgp->flags, BGP_FLAG_ENFORCE_FIRST_AS)) {
1571+
SET_FLAG(peer->flags_invert, PEER_FLAG_ENFORCE_FIRST_AS);
1572+
SET_FLAG(peer->flags, PEER_FLAG_ENFORCE_FIRST_AS);
1573+
}
15691574

15701575
if (CHECK_FLAG(bgp->flags, BGP_FLAG_SOFT_VERSION_CAPABILITY))
15711576
peer_flag_set(peer, PEER_FLAG_CAPABILITY_SOFT_VERSION);

0 commit comments

Comments
 (0)