Skip to content

Commit

Permalink
bgpd: do not del peer upon pg remote as change
Browse files Browse the repository at this point in the history
Currently, when peer-group remote-as is removed, it
deletes all associated neighbors.
Upon re configuring peer-group remote-as, all neighbors
needs to be reconfigured.

Instead, when peer-group remote-as is remove,
cease associated peer's connection and keep in Idle state.
When the peer-group remote-as is (re)configured, trigger
BGP Peer FSM to form neighbor.
Note the connection will be initiated after start timer
expiry.

Ticket: #3828243
Testing:

----- Peers start config ----

router bgp 65566
 bgp router-id 27.0.0.5
 bgp bestpath as-path multipath-relax
 neighbor fabric peer-group
 neighbor fabric remote-as external >>>>
 neighbor swp1 interface peer-group fabric
 neighbor swp1 advertisement-interval 0
 neighbor swp1 timers 3 9
 neighbor swp1 timers connect 10
 neighbor swp2 interface peer-group fabric
 neighbor swp2 advertisement-interval 0
 neighbor swp2 timers 3 9

tor(config)# router bgp 65566
tor(config-router)# no neighbor fabric remote-as external

----- Peers are retained in config ----
router bgp 65566
 bgp router-id 27.0.0.5
 bgp bestpath as-path multipath-relax
 neighbor fabric peer-group
 neighbor swp1 interface peer-group fabric
 neighbor swp1 advertisement-interval 0
 neighbor swp1 timers 3 9
 neighbor swp1 timers connect 10
 neighbor swp2 interface peer-group fabric
 neighbor swp2 advertisement-interval 0
 neighbor swp2 timers 3 9

----- Peers are in idle state ----
Neighbor        V  AS  MsgRcvd MsgSent TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc
spine-1(swp1)   4   0       52      34      0    0    0 00:00:04         Idle        0 N/A
spine-3(swp2)   4   0       52      34      0    0    0 00:00:04         Idle        0 N/A

tor(config)# router bgp 65566
tor(config-router)# neighbor fabric remote-as external

---- after connect timer expiry forms the neighbor ----

Neighbor       V    AS MsgRcvd MsgSent TblVer InQ OutQ  Up/Down State/PfxRcd  PfxSnt Desc
spine-1(swp1)  4 64435     784     749      0   0    0 00:35:10           11       2 N/A
spine-3(swp2)  4 64435     784     749      0   0    0 00:35:10           11       2 N/A

Signed-off-by: Chirag Shah <[email protected]>
  • Loading branch information
chiragshah6 committed Mar 18, 2024
1 parent 5e42011 commit 6b96dcf
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2973,9 +2973,21 @@ int peer_group_remote_as(struct bgp *bgp, const char *group_name, as_t *as,
peer_as_change(group->conf, *as, as_type, as_str);

for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
if (((peer->as_type == AS_SPECIFIED) && peer->as != *as)
|| (peer->as_type != as_type))
if (((peer->as_type == AS_SPECIFIED) && peer->as != *as) ||
(peer->as_type != as_type)) {
peer_as_change(peer, *as, as_type, as_str);
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s peer %s set to as_type %u curr status %s trigger BGP_Start",
__func__, peer->host, peer->as_type,
lookup_msg(bgp_status_msg,
peer->connection->status, NULL));
/* Start Peer FSM to form neighbor using new as,
* NOTE: the connection is triggered upon start
* timer expiry.
*/
if (!BGP_PEER_START_SUPPRESSED(peer))
BGP_EVENT_ADD(peer->connection, BGP_Start);
}
}

return 0;
Expand Down Expand Up @@ -3070,27 +3082,20 @@ int peer_group_delete(struct peer_group *group)

int peer_group_remote_as_delete(struct peer_group *group)
{
struct peer *peer, *other;
struct peer *peer;
struct listnode *node, *nnode;

if ((group->conf->as_type == AS_UNSPECIFIED)
|| ((!group->conf->as) && (group->conf->as_type == AS_SPECIFIED)))
return 0;

for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
other = peer->doppelganger;

if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE))
bgp_zebra_terminate_radv(peer->bgp, peer);

peer_delete(peer);

if (other && other->connection->status != Deleted) {
other->group = NULL;
peer_delete(other);
}
/* reset existing peer connection */
peer_as_change(peer, 0, AS_UNSPECIFIED, NULL);
}
list_delete_all_node(group->peer);

group->conf->as = 0;
group->conf->as_type = AS_UNSPECIFIED;
Expand Down

0 comments on commit 6b96dcf

Please sign in to comment.