Skip to content

Commit 763ecdc

Browse files
authored
Merge pull request #17712 from opensourcerouting/fix/backport_b6dcf618777bb7a11176617d647e16ab64f49b7b_10.2
bgpd: Fix `enforce-first-as` per peer-group removal (backport)
2 parents 9e3f285 + d893a04 commit 763ecdc

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
@@ -18812,7 +18812,11 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
1881218812

1881318813
/* enforce-first-as */
1881418814
if (CHECK_FLAG(bgp->flags, BGP_FLAG_ENFORCE_FIRST_AS)) {
18815-
if (!peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS))
18815+
/* The `no` form is printed because by default this enforcing
18816+
* is enabled, thus we need to print it inverted.
18817+
* See peer_new().
18818+
*/
18819+
if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS))
1881618820
vty_out(vty, " no neighbor %s enforce-first-as\n", addr);
1881718821
} else {
1881818822
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
@@ -1594,8 +1594,13 @@ struct peer *peer_new(struct bgp *bgp)
15941594

15951595
SET_FLAG(peer->sflags, PEER_STATUS_CAPABILITY_OPEN);
15961596

1597-
if (CHECK_FLAG(bgp->flags, BGP_FLAG_ENFORCE_FIRST_AS))
1598-
peer_flag_set(peer, PEER_FLAG_ENFORCE_FIRST_AS);
1597+
/* By default this is enabled, thus we need to mark it as
1598+
* inverted in order to display correctly in the configuration.
1599+
*/
1600+
if (CHECK_FLAG(bgp->flags, BGP_FLAG_ENFORCE_FIRST_AS)) {
1601+
SET_FLAG(peer->flags_invert, PEER_FLAG_ENFORCE_FIRST_AS);
1602+
SET_FLAG(peer->flags, PEER_FLAG_ENFORCE_FIRST_AS);
1603+
}
15991604

16001605
if (CHECK_FLAG(bgp->flags, BGP_FLAG_SOFT_VERSION_CAPABILITY))
16011606
peer_flag_set(peer, PEER_FLAG_CAPABILITY_SOFT_VERSION);

0 commit comments

Comments
 (0)