]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Fix missed unlocks
authorDonald Sharp <sharpd@nvidia.com>
Sat, 14 Nov 2020 20:32:49 +0000 (15:32 -0500)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 17 Nov 2020 18:07:59 +0000 (21:07 +0300)
When iterating over the bgp_dest table, using this pattern:

for (dest = bgp_table_top(table); dest;
     dest = bgp_route_next(dest)) {

If the code breaks or returns in the middle we will not have
properly unlocked the node as that bgp_table_top locks the top
dest and bgp_route_next locks the next dest and unlocks the old
dest.

From code inspection I have found a bunch of places that
we either return in the middle of or a break is issued.

Add appropriate unlocks.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_evpn.c
bgpd/bgp_evpn_mh.c
bgpd/bgp_updgrp_adv.c

index 0703853354fcdaabad4b1253576b2392f83b2c70..999345118b434051c69942517029fd11f90cc24a 100644 (file)
@@ -2941,6 +2941,8 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
                                                                   sizeof(buf)),
                                                        vrf_id_to_name(
                                                                bgp_vrf->vrf_id));
+                                               bgp_dest_unlock_node(rd_dest);
+                                               bgp_dest_unlock_node(dest);
                                                return ret;
                                        }
                                }
@@ -3020,6 +3022,9 @@ static int install_uninstall_routes_for_vni(struct bgp *bgp,
                                                                ? "MACIP"
                                                                : "IMET",
                                                        vpn->vni);
+
+                                               bgp_dest_unlock_node(rd_dest);
+                                               bgp_dest_unlock_node(dest);
                                                return ret;
                                        }
                                }
index 780981036388cb76a73475013a2e0b6935d368c7..e47a4d65071af9c5cd427a68dd61feb87d4974bc 100644 (file)
@@ -744,6 +744,9 @@ static int bgp_evpn_type4_remote_routes_import(struct bgp *bgp,
                                                        prefix2str(evp, buf,
                                                                sizeof(buf)),
                                                        es->esi_str);
+
+                                       bgp_dest_unlock_node(rd_rn);
+                                       bgp_dest_unlock_node(rn);
                                        return ret;
                                }
                        }
index 4524d1be71e7d9ad2e009c7f4d2b28ab55ad6e3c..7b361fba1d9aee0a52a0cda0812ffceb62c64c0b 100644 (file)
@@ -808,8 +808,10 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
                                        break;
                                }
                        }
-                       if (ret == RMAP_PERMITMATCH)
+                       if (ret == RMAP_PERMITMATCH) {
+                               bgp_dest_unlock_node(dest);
                                break;
+                       }
                }
                bgp->peer_self->rmap_type = 0;