mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 10:08:41 +00:00
bgpd: Make sure we don't miss to unlock for bgp_dest before returning
bgp_node_lookup() increases `lock` which is not decreased on return. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
parent
64fcf85d38
commit
e71ad4b64e
@ -2628,8 +2628,10 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
|
|||||||
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
|
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!pi)
|
if (!pi) {
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (bgp_debug_zebra(NULL))
|
if (bgp_debug_zebra(NULL))
|
||||||
zlog_debug("... delete dest %p (l %d) pi %p (l %d, f 0x%x)",
|
zlog_debug("... delete dest %p (l %d) pi %p (l %d, f 0x%x)",
|
||||||
@ -2690,8 +2692,10 @@ static int uninstall_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
|
|||||||
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
|
&& (struct bgp_path_info *)pi->extra->parent == parent_pi)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!pi)
|
if (!pi) {
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Mark entry for deletion */
|
/* Mark entry for deletion */
|
||||||
bgp_path_info_delete(dest, pi);
|
bgp_path_info_delete(dest, pi);
|
||||||
@ -5308,8 +5312,10 @@ int bgp_evpn_local_macip_del(struct bgp *bgp, vni_t vni, struct ethaddr *mac,
|
|||||||
} else {
|
} else {
|
||||||
/* Re-instate the current remote best path if any */
|
/* Re-instate the current remote best path if any */
|
||||||
dest = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
|
dest = bgp_node_lookup(vpn->route_table, (struct prefix *)&p);
|
||||||
if (dest)
|
if (dest) {
|
||||||
evpn_zebra_reinstall_best_route(bgp, vpn, dest);
|
evpn_zebra_reinstall_best_route(bgp, vpn, dest);
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -269,8 +269,10 @@ static int bgp_evpn_es_route_uninstall(struct bgp *bgp, struct bgp_evpn_es *es,
|
|||||||
parent_pi)
|
parent_pi)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!pi)
|
if (!pi) {
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Mark entry for deletion */
|
/* Mark entry for deletion */
|
||||||
bgp_path_info_delete(dest, pi);
|
bgp_path_info_delete(dest, pi);
|
||||||
|
@ -2418,6 +2418,10 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
|
|||||||
if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
|
if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
|
||||||
if (!json)
|
if (!json)
|
||||||
vty_out(vty, "%% Network not in table\n");
|
vty_out(vty, "%% Network not in table\n");
|
||||||
|
|
||||||
|
if (dest)
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2452,6 +2456,8 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
|
|||||||
vty_out(vty, "\nDisplayed %u paths for requested prefix\n",
|
vty_out(vty, "\nDisplayed %u paths for requested prefix\n",
|
||||||
path_cnt);
|
path_cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2488,6 +2494,10 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
|
|||||||
if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
|
if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
|
||||||
if (!json)
|
if (!json)
|
||||||
vty_out(vty, "%% Network not in table\n");
|
vty_out(vty, "%% Network not in table\n");
|
||||||
|
|
||||||
|
if (dest)
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2522,6 +2532,8 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
|
|||||||
vty_out(vty, "\nDisplayed %u paths for requested prefix\n",
|
vty_out(vty, "\nDisplayed %u paths for requested prefix\n",
|
||||||
path_cnt);
|
path_cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disaplay EVPN routes for a ESI - VTY handler */
|
/* Disaplay EVPN routes for a ESI - VTY handler */
|
||||||
@ -2592,6 +2604,10 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
|
|||||||
if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
|
if (!dest || !bgp_dest_has_bgp_path_info_data(dest)) {
|
||||||
if (!json)
|
if (!json)
|
||||||
vty_out(vty, "%% Network not in table\n");
|
vty_out(vty, "%% Network not in table\n");
|
||||||
|
|
||||||
|
if (dest)
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2627,6 +2643,8 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
|
|||||||
vty_out(vty, "\nDisplayed %u paths for requested prefix\n",
|
vty_out(vty, "\nDisplayed %u paths for requested prefix\n",
|
||||||
path_cnt);
|
path_cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2660,14 +2678,18 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
table = bgp_dest_get_bgp_table_info(rd_dest);
|
table = bgp_dest_get_bgp_table_info(rd_dest);
|
||||||
if (table == NULL)
|
if (table == NULL) {
|
||||||
|
bgp_dest_unlock_node(rd_dest);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
json_rd = json_object_new_object();
|
json_rd = json_object_new_object();
|
||||||
json_object_string_add(json_rd, "rd", rd_str);
|
json_object_string_add(json_rd, "rd", rd_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bgp_dest_unlock_node(rd_dest);
|
||||||
|
|
||||||
/* Display all prefixes with this RD. */
|
/* Display all prefixes with this RD. */
|
||||||
for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
|
for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
|
||||||
const struct prefix_evpn *evp =
|
const struct prefix_evpn *evp =
|
||||||
@ -2878,6 +2900,8 @@ static void evpn_show_route_rd_all_macip(struct vty *vty, struct bgp *bgp,
|
|||||||
json_rd = NULL;
|
json_rd = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
|
@ -89,8 +89,8 @@ int bgp_parse_fec_update(void)
|
|||||||
bgp_set_valid_label(&dest->local_label);
|
bgp_set_valid_label(&dest->local_label);
|
||||||
}
|
}
|
||||||
SET_FLAG(dest->flags, BGP_NODE_LABEL_CHANGED);
|
SET_FLAG(dest->flags, BGP_NODE_LABEL_CHANGED);
|
||||||
bgp_dest_unlock_node(dest);
|
|
||||||
bgp_process(bgp, dest, afi, safi);
|
bgp_process(bgp, dest, afi, safi);
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -689,12 +689,12 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
|
|||||||
dest = bgp_node_lookup(bgp->rib[AFI_IP][SAFI_UNICAST],
|
dest = bgp_node_lookup(bgp->rib[AFI_IP][SAFI_UNICAST],
|
||||||
(struct prefix *)addr);
|
(struct prefix *)addr);
|
||||||
if (dest) {
|
if (dest) {
|
||||||
bgp_dest_unlock_node(dest);
|
|
||||||
|
|
||||||
for (path = bgp_dest_get_bgp_path_info(dest); path;
|
for (path = bgp_dest_get_bgp_path_info(dest); path;
|
||||||
path = path->next)
|
path = path->next)
|
||||||
if (sockunion_same(&path->peer->su, &su))
|
if (sockunion_same(&path->peer->su, &su))
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
offset = name + v->namelen;
|
offset = name + v->namelen;
|
||||||
|
@ -883,7 +883,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
|
|||||||
/* If default route is present in the local RIB, advertise the
|
/* If default route is present in the local RIB, advertise the
|
||||||
* route
|
* route
|
||||||
*/
|
*/
|
||||||
if (dest != NULL) {
|
if (dest) {
|
||||||
for (pi = bgp_dest_get_bgp_path_info(dest); pi;
|
for (pi = bgp_dest_get_bgp_path_info(dest); pi;
|
||||||
pi = pi->next) {
|
pi = pi->next) {
|
||||||
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
|
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
|
||||||
@ -895,6 +895,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
|
|||||||
dest, subgrp, &attr,
|
dest, subgrp, &attr,
|
||||||
pi);
|
pi);
|
||||||
}
|
}
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!CHECK_FLAG(subgrp->sflags,
|
if (!CHECK_FLAG(subgrp->sflags,
|
||||||
@ -907,7 +908,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
|
|||||||
* clear adj_out for the 0.0.0.0/0 prefix in the BGP
|
* clear adj_out for the 0.0.0.0/0 prefix in the BGP
|
||||||
* table.
|
* table.
|
||||||
*/
|
*/
|
||||||
if (dest != NULL) {
|
if (dest) {
|
||||||
/* Remove the adjacency for the previously
|
/* Remove the adjacency for the previously
|
||||||
* advertised default route
|
* advertised default route
|
||||||
*/
|
*/
|
||||||
@ -923,6 +924,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
|
|||||||
/* Free allocated information. */
|
/* Free allocated information. */
|
||||||
adj_free(adj);
|
adj_free(adj);
|
||||||
}
|
}
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Advertise the default route */
|
/* Advertise the default route */
|
||||||
|
@ -2444,8 +2444,6 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
|
|||||||
if (!dest)
|
if (!dest)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
bgp_dest_unlock_node(dest);
|
|
||||||
|
|
||||||
switch (note) {
|
switch (note) {
|
||||||
case ZAPI_ROUTE_INSTALLED:
|
case ZAPI_ROUTE_INSTALLED:
|
||||||
new_select = NULL;
|
new_select = NULL;
|
||||||
@ -2474,6 +2472,8 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
|
|||||||
flog_err(EC_BGP_INVALID_ROUTE,
|
flog_err(EC_BGP_INVALID_ROUTE,
|
||||||
"selected route %pRN not found",
|
"selected route %pRN not found",
|
||||||
dest);
|
dest);
|
||||||
|
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2504,6 +2504,8 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
|
|||||||
__func__, dest);
|
__func__, dest);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user