Skip to content

Commit 4395fcd

Browse files
bgpd: backpressure - fix to properly remove dest for bgp under deletion
In case of imported routes (L3vni/vrf leaks), when a bgp instance is being deleted, the peer->bgp comparision with the incoming bgp to remove the dest from the pending fifo is wrong. This can lead to the fifo having stale entries resulting in crash. Two changes are done here. - Instead of pop/push items in list if the struct bgp doesnt match, simply iterate the list and remove the expected ones. - Corrected the way bgp is fetched from dest rather than relying on path_info->peer so that it works for all kinds of routes. Ticket :#3980988 Signed-off-by: Chirag Shah <chirag @nvidia.com> Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
1 parent 7d08b29 commit 4395fcd

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

bgpd/bgp_evpn.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6333,16 +6333,16 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
63336333
void bgp_evpn_free(struct bgp *bgp, struct bgpevpn *vpn)
63346334
{
63356335
struct bgp_dest *dest = NULL;
6336-
uint32_t ann_count = zebra_announce_count(&bm->zebra_announce_head);
6336+
struct bgp_dest *dest_next = NULL;
63376337

6338-
while (ann_count) {
6339-
dest = zebra_announce_pop(&bm->zebra_announce_head);
6340-
ann_count--;
6338+
for (dest = zebra_announce_first(&bm->zebra_announce_head); dest;
6339+
dest = dest_next) {
6340+
dest_next = zebra_announce_next(&bm->zebra_announce_head, dest);
63416341
if (dest->za_vpn == vpn) {
63426342
bgp_path_info_unlock(dest->za_bgp_pi);
63436343
bgp_dest_unlock_node(dest);
6344-
} else
6345-
zebra_announce_add_tail(&bm->zebra_announce_head, dest);
6344+
zebra_announce_del(&bm->zebra_announce_head, dest);
6345+
}
63466346
}
63476347

63486348
bgp_evpn_remote_ip_hash_destroy(vpn);

bgpd/bgpd.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3936,19 +3936,25 @@ int bgp_delete(struct bgp *bgp)
39363936
safi_t safi;
39373937
int i;
39383938
struct bgp_dest *dest = NULL;
3939+
struct bgp_dest *dest_next = NULL;
3940+
struct bgp_table *dest_table = NULL;
39393941
struct graceful_restart_info *gr_info;
3940-
uint32_t ann_count = zebra_announce_count(&bm->zebra_announce_head);
39413942

39423943
assert(bgp);
39433944

3944-
while (ann_count) {
3945-
dest = zebra_announce_pop(&bm->zebra_announce_head);
3946-
ann_count--;
3947-
if (dest->za_bgp_pi->peer->bgp == bgp) {
3945+
/*
3946+
* Iterate the pending dest list and remove all the dest pertaininig to
3947+
* the bgp under delete.
3948+
*/
3949+
for (dest = zebra_announce_first(&bm->zebra_announce_head); dest;
3950+
dest = dest_next) {
3951+
dest_next = zebra_announce_next(&bm->zebra_announce_head, dest);
3952+
dest_table = bgp_dest_table(dest);
3953+
if (dest_table->bgp == bgp) {
39483954
bgp_path_info_unlock(dest->za_bgp_pi);
39493955
bgp_dest_unlock_node(dest);
3950-
} else
3951-
zebra_announce_add_tail(&bm->zebra_announce_head, dest);
3956+
zebra_announce_del(&bm->zebra_announce_head, dest);
3957+
}
39523958
}
39533959

39543960
bgp_soft_reconfig_table_task_cancel(bgp, NULL, NULL);

0 commit comments

Comments
 (0)