Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: Fix enforce-first-as per peer-group removal (backport #17705) #17710

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -18201,7 +18201,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 @@ -1564,8 +1564,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
9 changes: 9 additions & 0 deletions tests/topotests/bgp_route_server_client/r1/bgpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
router bgp 65001
bgp router-id 10.10.10.1
no bgp ebgp-requires-policy
<<<<<<< HEAD
no bgp enforce-first-as
neighbor 2001:db8:1::1 remote-as external
neighbor 2001:db8:1::1 timers 3 10
neighbor 2001:db8:1::1 timers connect 5
=======
neighbor pg peer-group
neighbor pg remote-as external
neighbor pg timers 1 3
neighbor pg timers connect 1
no neighbor pg enforce-first-as
neighbor 2001:db8:1::1 peer-group pg
>>>>>>> 9047ce6d9 (tests: Check if enforce-first-as is working with peer-groups)
address-family ipv6 unicast
redistribute connected
neighbor 2001:db8:1::1 activate
Expand Down
Loading