]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: backpressure - Fix to avoid CPU hog
authorRajasekar Raja <rajasekarr@nvidia.com>
Fri, 17 May 2024 22:43:59 +0000 (15:43 -0700)
committerRajasekar Raja <rajasekarr@nvidia.com>
Fri, 17 May 2024 22:43:59 +0000 (15:43 -0700)
In case when bgp_evpn_free or bgp_delete is called and the announce_list
has few items where vpn/bgp does not match, we add the item back to the
list. Because of this the list count is always > 0 thereby hogging CPU or
infinite loop.

Ticket: #3905624

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
bgpd/bgp_evpn.c
bgpd/bgpd.c

index 1c3b4e05c63645a469b7b58961542cae1a5cf370..ce9666d6115a23380e696bc0d157f0b638291420 100644 (file)
@@ -6317,9 +6317,11 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
 void bgp_evpn_free(struct bgp *bgp, struct bgpevpn *vpn)
 {
        struct bgp_dest *dest = NULL;
+       uint32_t ann_count = zebra_announce_count(&bm->zebra_announce_head);
 
-       while (zebra_announce_count(&bm->zebra_announce_head)) {
+       while (ann_count) {
                dest = zebra_announce_pop(&bm->zebra_announce_head);
+               ann_count--;
                if (dest->za_vpn == vpn) {
                        bgp_path_info_unlock(dest->za_bgp_pi);
                        bgp_dest_unlock_node(dest);
index 80383dacdf407cce57c36b7a69b6b037ae3d5ec2..09e64cf9ec31ebd416f9ea941ee2f62d5cd48bf8 100644 (file)
@@ -3908,11 +3908,13 @@ int bgp_delete(struct bgp *bgp)
        int i;
        struct bgp_dest *dest = NULL;
        struct graceful_restart_info *gr_info;
+       uint32_t ann_count = zebra_announce_count(&bm->zebra_announce_head);
 
        assert(bgp);
 
-       while (zebra_announce_count(&bm->zebra_announce_head)) {
+       while (ann_count) {
                dest = zebra_announce_pop(&bm->zebra_announce_head);
+               ann_count--;
                if (dest->za_bgp_pi->peer->bgp == bgp) {
                        bgp_path_info_unlock(dest->za_bgp_pi);
                        bgp_dest_unlock_node(dest);