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 : Prevent deletion of BGP peer groups associated to listen range #15670

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -5102,6 +5102,8 @@ DEFUN (no_neighbor,
struct peer_group *group;
struct peer *peer;
struct peer *other;
afi_t afi;
int lr_count;

ret = str2sockunion(argv[idx_peer]->arg, &su);
if (ret < 0) {
Expand All @@ -5119,6 +5121,15 @@ DEFUN (no_neighbor,

group = peer_group_lookup(bgp, argv[idx_peer]->arg);
if (group) {
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
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 Expand Up @@ -5196,9 +5207,20 @@ DEFUN (no_neighbor_peer_group,
VTY_DECLVAR_CONTEXT(bgp, bgp);
int idx_word = 2;
struct peer_group *group;
afi_t afi;
int lr_count;

group = peer_group_lookup(bgp, argv[idx_word]->arg);
if (group) {
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
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