From: Donald Sharp Date: Sat, 14 Nov 2020 20:32:49 +0000 (-0500) Subject: bgpd: Fix missed unlocks X-Git-Tag: frr-7.5.1~33^2~9 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=39dfa3141d45ba5a4e4483fc5a9f05b603f11c4d;p=mirror%2Ffrr.git bgpd: Fix missed unlocks 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 --- diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 0703853354..999345118b 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -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; } } diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c index 7809810363..e47a4d6507 100644 --- a/bgpd/bgp_evpn_mh.c +++ b/bgpd/bgp_evpn_mh.c @@ -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; } } diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index 4524d1be71..7b361fba1d 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -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;