Skip to content

Commit

Permalink
bgpd : Prevent deletion of BGP peer groups associated to listen range
Browse files Browse the repository at this point in the history
Description:
-----
Deleting a peer group also deletes its associated BGP listen range.
This behaviour is undesired as it could cause unintended configuration changes.

Fix :
-----
-Do not allow peer group deletion until they are no longer associated with any listen range.
-Check the count of listen ranges attached to the group.
If any listen ranges are found, returns a configuration warning, preventing the deletion.

Signed-off-by: Pooja Rathore <rathorepo@vmware.com>
  • Loading branch information
rathorepo committed Apr 19, 2024
1 parent 27cc9ae commit 33eb965
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -5196,9 +5196,19 @@ DEFUN (no_neighbor_peer_group,
VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_word = 2;
struct peer_group *group;
afi_t afi;

group = peer_group_lookup(bgp, argv[idx_word]->arg);
if (group) {
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
int lr_count = listcount(group->listen_range[afi]);
if (lr_count) {
vty_out(vty,
"%%Peer-group %s is attached to %d listen-range(s), delete them first\n",
group->name, lr_count);
return CMD_WARNING_CONFIG_FAILED;
}
}
peer_group_notify_unconfig(group);
peer_group_delete(group);
} else {
Expand Down

0 comments on commit 33eb965

Please sign in to comment.