Merge pull request #11059 from anlancs/fix/bgpd-evnp-wrong-check-hashget

bgpd: fix memory leak for evpn
This commit is contained in:
Donatas Abraitis 2022-05-04 21:19:51 +03:00 committed by GitHub
commit 50f1f2e724
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 50 additions and 124 deletions

View File

@ -861,9 +861,6 @@ struct aspath *aspath_parse(struct stream *s, size_t length, int use32bit)
/* If already same aspath exist then return it. */ /* If already same aspath exist then return it. */
find = hash_get(ashash, &as, aspath_hash_alloc); find = hash_get(ashash, &as, aspath_hash_alloc);
/* bug! should not happen, let the daemon crash below */
assert(find);
/* if the aspath was already hashed free temporary memory. */ /* if the aspath was already hashed free temporary memory. */
if (find->refcnt) { if (find->refcnt) {
assegment_free_all(as.segments); assegment_free_all(as.segments);

View File

@ -184,7 +184,7 @@ community_list_insert(struct community_list_handler *ch, const char *name,
new->name_hash = bgp_clist_hash_key_community_list(new); new->name_hash = bgp_clist_hash_key_community_list(new);
/* Save for later */ /* Save for later */
hash_get(cm->hash, new, hash_alloc_intern); (void)hash_get(cm->hash, new, hash_alloc_intern);
/* If name is made by all digit character. We treat it as /* If name is made by all digit character. We treat it as
number. */ number. */

View File

@ -106,12 +106,12 @@ int bgp_community_alias_write(struct vty *vty)
void bgp_ca_community_insert(struct community_alias *ca) void bgp_ca_community_insert(struct community_alias *ca)
{ {
hash_get(bgp_ca_community_hash, ca, bgp_community_alias_alloc); (void)hash_get(bgp_ca_community_hash, ca, bgp_community_alias_alloc);
} }
void bgp_ca_alias_insert(struct community_alias *ca) void bgp_ca_alias_insert(struct community_alias *ca)
{ {
hash_get(bgp_ca_alias_hash, ca, bgp_community_alias_alloc); (void)hash_get(bgp_ca_alias_hash, ca, bgp_community_alias_alloc);
} }
void bgp_ca_community_delete(struct community_alias *ca) void bgp_ca_community_delete(struct community_alias *ca)

View File

@ -167,10 +167,7 @@ static struct vrf_irt_node *vrf_import_rt_new(struct ecommunity_val *rt)
irt->vrfs = list_new(); irt->vrfs = list_new();
/* Add to hash */ /* Add to hash */
if (!hash_get(bgp_evpn->vrf_import_rt_hash, irt, hash_alloc_intern)) { (void)hash_get(bgp_evpn->vrf_import_rt_hash, irt, hash_alloc_intern);
XFREE(MTYPE_BGP_EVPN_VRF_IMPORT_RT, irt);
return NULL;
}
return irt; return irt;
} }
@ -272,10 +269,7 @@ static struct irt_node *import_rt_new(struct bgp *bgp,
irt->vnis = list_new(); irt->vnis = list_new();
/* Add to hash */ /* Add to hash */
if (!hash_get(bgp->import_rt_hash, irt, hash_alloc_intern)) { (void)hash_get(bgp->import_rt_hash, irt, hash_alloc_intern);
XFREE(MTYPE_BGP_EVPN_IMPORT_RT, irt);
return NULL;
}
return irt; return irt;
} }
@ -5336,10 +5330,7 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
vpn->route_table = bgp_table_init(bgp, AFI_L2VPN, SAFI_EVPN); vpn->route_table = bgp_table_init(bgp, AFI_L2VPN, SAFI_EVPN);
/* Add to hash */ /* Add to hash */
if (!hash_get(bgp->vnihash, vpn, hash_alloc_intern)) { (void)hash_get(bgp->vnihash, vpn, hash_alloc_intern);
XFREE(MTYPE_BGP_EVPN, vpn);
return NULL;
}
bgp_evpn_remote_ip_hash_init(vpn); bgp_evpn_remote_ip_hash_init(vpn);
bgp_evpn_link_to_vni_svi_hash(bgp, vpn); bgp_evpn_link_to_vni_svi_hash(bgp, vpn);
@ -6217,9 +6208,6 @@ static void bgp_evpn_remote_ip_hash_add(struct bgpevpn *vpn,
} }
ip = hash_get(vpn->remote_ip_hash, &tmp, bgp_evpn_remote_ip_hash_alloc); ip = hash_get(vpn->remote_ip_hash, &tmp, bgp_evpn_remote_ip_hash_alloc);
if (!ip)
return;
(void)listnode_add(ip->macip_path_list, pi); (void)listnode_add(ip->macip_path_list, pi);
bgp_evpn_remote_ip_process_nexthops(vpn, &ip->addr, true); bgp_evpn_remote_ip_process_nexthops(vpn, &ip->addr, true);
@ -6352,7 +6340,7 @@ static void bgp_evpn_link_to_vni_svi_hash(struct bgp *bgp, struct bgpevpn *vpn)
if (vpn->svi_ifindex == 0) if (vpn->svi_ifindex == 0)
return; return;
hash_get(bgp->vni_svi_hash, vpn, hash_alloc_intern); (void)hash_get(bgp->vni_svi_hash, vpn, hash_alloc_intern);
} }
static void bgp_evpn_unlink_from_vni_svi_hash(struct bgp *bgp, static void bgp_evpn_unlink_from_vni_svi_hash(struct bgp *bgp,

View File

@ -2272,7 +2272,7 @@ static int bgp_establish(struct peer *peer)
* so the hash_release is the same for either. * so the hash_release is the same for either.
*/ */
hash_release(peer->bgp->peerhash, peer); hash_release(peer->bgp->peerhash, peer);
hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); (void)hash_get(peer->bgp->peerhash, peer, hash_alloc_intern);
/* Start BFD peer if not already running. */ /* Start BFD peer if not already running. */
if (peer->bfd_config) if (peer->bfd_config)

View File

@ -256,7 +256,7 @@ void bgp_keepalives_on(struct peer *peer)
holder.peer = peer; holder.peer = peer;
if (!hash_lookup(peerhash, &holder)) { if (!hash_lookup(peerhash, &holder)) {
struct pkat *pkat = pkat_new(peer); struct pkat *pkat = pkat_new(peer);
hash_get(peerhash, pkat, hash_alloc_intern); (void)hash_get(peerhash, pkat, hash_alloc_intern);
peer_lock(peer); peer_lock(peer);
} }
SET_FLAG(peer->thread_flags, PEER_THREAD_KEEPALIVES_ON); SET_FLAG(peer->thread_flags, PEER_THREAD_KEEPALIVES_ON);

View File

@ -539,7 +539,7 @@ static void bgp_accept(struct thread *thread)
peer = peer_create(&su, peer1->conf_if, peer1->bgp, peer1->local_as, peer = peer_create(&su, peer1->conf_if, peer1->bgp, peer1->local_as,
peer1->as, peer1->as_type, NULL); peer1->as, peer1->as_type, NULL);
hash_release(peer->bgp->peerhash, peer); hash_release(peer->bgp->peerhash, peer);
hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); (void)hash_get(peer->bgp->peerhash, peer, hash_alloc_intern);
peer_xfer_config(peer, peer1); peer_xfer_config(peer, peer1);
bgp_peer_gr_flags_update(peer); bgp_peer_gr_flags_update(peer);

View File

@ -191,9 +191,6 @@ void bgp_tip_add(struct bgp *bgp, struct in_addr *tip)
tmp.addr = *tip; tmp.addr = *tip;
addr = hash_get(bgp->tip_hash, &tmp, bgp_tip_hash_alloc); addr = hash_get(bgp->tip_hash, &tmp, bgp_tip_hash_alloc);
if (!addr)
return;
addr->refcnt++; addr->refcnt++;
} }

View File

@ -2350,7 +2350,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
pbr_rule.action = bpa; pbr_rule.action = bpa;
bpr = hash_get(bgp->pbr_rule_hash, &pbr_rule, bpr = hash_get(bgp->pbr_rule_hash, &pbr_rule,
bgp_pbr_rule_alloc_intern); bgp_pbr_rule_alloc_intern);
if (bpr && bpr->unique == 0) { if (bpr->unique == 0) {
bpr->unique = ++bgp_pbr_action_counter_unique; bpr->unique = ++bgp_pbr_action_counter_unique;
bpr->installed = false; bpr->installed = false;
bpr->install_in_progress = false; bpr->install_in_progress = false;
@ -2359,7 +2359,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
} else } else
bpr_found = true; bpr_found = true;
/* already installed */ /* already installed */
if (bpr_found && bpr) { if (bpr_found) {
struct bgp_path_info_extra *extra = struct bgp_path_info_extra *extra =
bgp_path_info_extra_get(path); bgp_path_info_extra_get(path);
@ -2376,7 +2376,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
bgp_pbr_bpa_add(bpa); bgp_pbr_bpa_add(bpa);
/* ip rule add */ /* ip rule add */
if (bpr && !bpr->installed) if (!bpr->installed)
bgp_send_pbr_rule_action(bpa, bpr, true); bgp_send_pbr_rule_action(bpa, bpr, true);
/* A previous entry may already exist /* A previous entry may already exist

View File

@ -754,8 +754,6 @@ static struct update_group *update_group_create(struct peer_af *paf)
updgrp = hash_get(paf->peer->bgp->update_groups[paf->afid], &tmp, updgrp = hash_get(paf->peer->bgp->update_groups[paf->afid], &tmp,
updgrp_hash_alloc); updgrp_hash_alloc);
if (!updgrp)
return NULL;
update_group_checkin(updgrp); update_group_checkin(updgrp);
if (BGP_DEBUG(update_groups, UPDATE_GROUPS)) if (BGP_DEBUG(update_groups, UPDATE_GROUPS))

View File

@ -1650,7 +1650,7 @@ void bgp_peer_conf_if_to_su_update(struct peer *peer)
/* /*
* Since our su changed we need to del/add peer to the peerhash * Since our su changed we need to del/add peer to the peerhash
*/ */
hash_get(peer->bgp->peerhash, peer, hash_alloc_intern); (void)hash_get(peer->bgp->peerhash, peer, hash_alloc_intern);
} }
void bgp_recalculate_afi_safi_bestpaths(struct bgp *bgp, afi_t afi, safi_t safi) void bgp_recalculate_afi_safi_bestpaths(struct bgp *bgp, afi_t afi, safi_t safi)
@ -1737,7 +1737,7 @@ struct peer *peer_create(union sockunion *su, const char *conf_if,
peer = peer_lock(peer); /* bgp peer list reference */ peer = peer_lock(peer); /* bgp peer list reference */
peer->group = group; peer->group = group;
listnode_add_sort(bgp->peer, peer); listnode_add_sort(bgp->peer, peer);
hash_get(bgp->peerhash, peer, hash_alloc_intern); (void)hash_get(bgp->peerhash, peer, hash_alloc_intern);
/* Adjust update-group coalesce timer heuristics for # peers. */ /* Adjust update-group coalesce timer heuristics for # peers. */
if (bgp->heuristic_coalesce) { if (bgp->heuristic_coalesce) {

View File

@ -267,8 +267,8 @@ void isis_lfa_excluded_ifaces_clear(struct isis_circuit *circuit, int level)
void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level, void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level,
const char *ifname) const char *ifname)
{ {
hash_get(circuit->lfa_excluded_ifaces[level - 1], (char *)ifname, (void)hash_get(circuit->lfa_excluded_ifaces[level - 1], (char *)ifname,
lfa_excl_interface_hash_alloc); lfa_excl_interface_hash_alloc);
} }
/** /**

View File

@ -527,14 +527,14 @@ static void vertex_add_parent_firsthop(struct hash_bucket *bucket, void *arg)
struct isis_vertex *vertex = arg; struct isis_vertex *vertex = arg;
struct isis_vertex *hop = bucket->data; struct isis_vertex *hop = bucket->data;
hash_get(vertex->firsthops, hop, hash_alloc_intern); (void)hash_get(vertex->firsthops, hop, hash_alloc_intern);
} }
static void vertex_update_firsthops(struct isis_vertex *vertex, static void vertex_update_firsthops(struct isis_vertex *vertex,
struct isis_vertex *parent) struct isis_vertex *parent)
{ {
if (vertex->d_N <= 2) if (vertex->d_N <= 2)
hash_get(vertex->firsthops, vertex, hash_alloc_intern); (void)hash_get(vertex->firsthops, vertex, hash_alloc_intern);
if (vertex->d_N < 2 || !parent) if (vertex->d_N < 2 || !parent)
return; return;
@ -606,8 +606,8 @@ isis_spf_add2tent(struct isis_spftree *spftree, enum vertextype vtype, void *id,
if (vertex->N.ip.sr.label != MPLS_INVALID_LABEL) if (vertex->N.ip.sr.label != MPLS_INVALID_LABEL)
vertex->N.ip.sr.present = true; vertex->N.ip.sr.present = true;
hash_get(spftree->prefix_sids, vertex, (void)hash_get(spftree->prefix_sids, vertex,
hash_alloc_intern); hash_alloc_intern);
} }
} }

View File

@ -315,7 +315,7 @@ void _install_element(enum node_type ntype, const struct cmd_element *cmd)
return; return;
} }
assert(hash_get(cnode->cmd_hash, (void *)cmd, hash_alloc_intern)); (void)hash_get(cnode->cmd_hash, (void *)cmd, hash_alloc_intern);
if (cnode->graph_built || !defer_cli_tree) { if (cnode->graph_built || !defer_cli_tree) {
struct graph *graph = graph_new(); struct graph *graph = graph_new();

View File

@ -86,7 +86,7 @@ void log_ref_add(struct log_ref *ref)
frr_with_mutex(&refs_mtx) { frr_with_mutex(&refs_mtx) {
while (ref[i].code != END_FERR) { while (ref[i].code != END_FERR) {
hash_get(refs, &ref[i], hash_alloc_intern); (void)hash_get(refs, &ref[i], hash_alloc_intern);
i++; i++;
} }
} }

View File

@ -333,7 +333,7 @@ void frrscript_register_type_codec(struct frrscript_codec *codec)
assert(!"Type codec double-registered."); assert(!"Type codec double-registered.");
} }
assert(hash_get(codec_hash, &c, codec_alloc)); (void)hash_get(codec_hash, &c, codec_alloc);
} }
void frrscript_register_type_codecs(struct frrscript_codec *codecs) void frrscript_register_type_codecs(struct frrscript_codec *codecs)
@ -399,7 +399,7 @@ int frrscript_load(struct frrscript *fs, const char *function_name,
/* Add the Lua function state to frrscript */ /* Add the Lua function state to frrscript */
struct lua_function_state key = {.name = function_name, .L = L}; struct lua_function_state key = {.name = function_name, .L = L};
hash_get(fs->lua_function_hash, &key, lua_function_alloc); (void)hash_get(fs->lua_function_hash, &key, lua_function_alloc);
return 0; return 0;
fail: fail:

View File

@ -2216,7 +2216,8 @@ void nb_running_move_tree(const char *xpath_from, const char *xpath_to)
strlcpy(entry->xpath, newpath, sizeof(entry->xpath)); strlcpy(entry->xpath, newpath, sizeof(entry->xpath));
XFREE(MTYPE_TMP, newpath); XFREE(MTYPE_TMP, newpath);
hash_get(running_config_entries, entry, hash_alloc_intern); (void)hash_get(running_config_entries, entry,
hash_alloc_intern);
} }
list_delete(&entries); list_delete(&entries);

View File

@ -29,7 +29,7 @@ uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool *p, struct nhrp_reqid *r,
if (++p->next_request_id == 0) if (++p->next_request_id == 0)
p->next_request_id = 1; p->next_request_id = 1;
r->cb = cb; r->cb = cb;
hash_get(p->reqid_hash, r, hash_alloc_intern); (void)hash_get(p->reqid_hash, r, hash_alloc_intern);
} }
return r->request_id; return r->request_id;
} }

View File

@ -1562,7 +1562,7 @@ static void
ospf6_link_route_to_aggr(struct ospf6_external_aggr_rt *aggr, ospf6_link_route_to_aggr(struct ospf6_external_aggr_rt *aggr,
struct ospf6_route *rt) struct ospf6_route *rt)
{ {
hash_get(aggr->match_extnl_hash, rt, hash_alloc_intern); (void)hash_get(aggr->match_extnl_hash, rt, hash_alloc_intern);
rt->aggr_route = aggr; rt->aggr_route = aggr;
} }

View File

@ -831,8 +831,8 @@ static void ospf6_gr_helper_support_set_per_routerid(struct ospf6 *ospf6,
} else { } else {
/* Add the routerid to the enable router hash table */ /* Add the routerid to the enable router hash table */
hash_get(ospf6->ospf6_helper_cfg.enable_rtr_list, &temp, (void)hash_get(ospf6->ospf6_helper_cfg.enable_rtr_list, &temp,
ospf6_enable_rtr_hash_alloc); ospf6_enable_rtr_hash_alloc);
} }
} }

View File

@ -595,7 +595,7 @@ static void ospf_link_ei_to_aggr(struct ospf_external_aggr_rt *aggr,
"%s: Linking extrenal route(%pI4/%d) to aggregator(%pI4/%d)", "%s: Linking extrenal route(%pI4/%d) to aggregator(%pI4/%d)",
__func__, &ei->p.prefix, ei->p.prefixlen, __func__, &ei->p.prefix, ei->p.prefixlen,
&aggr->p.prefix, aggr->p.prefixlen); &aggr->p.prefix, aggr->p.prefixlen);
hash_get(aggr->match_extnl_hash, ei, hash_alloc_intern); (void)hash_get(aggr->match_extnl_hash, ei, hash_alloc_intern);
ei->aggr_route = aggr; ei->aggr_route = aggr;
} }

View File

@ -933,8 +933,8 @@ void ospf_gr_helper_support_set_per_routerid(struct ospf *ospf,
} else { } else {
/* Add the routerid to the enable router hash table */ /* Add the routerid to the enable router hash table */
hash_get(ospf->enable_rtr_list, &temp, (void)hash_get(ospf->enable_rtr_list, &temp,
ospf_enable_rtr_hash_alloc); ospf_enable_rtr_hash_alloc);
} }
} }

View File

@ -1463,14 +1463,6 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)
srn = (struct sr_node *)hash_get(OspfSR.neighbors, srn = (struct sr_node *)hash_get(OspfSR.neighbors,
&lsah->adv_router, &lsah->adv_router,
(void *)sr_node_new); (void *)sr_node_new);
/* Sanity check */
if (srn == NULL) {
flog_err(
EC_OSPF_SR_NODE_CREATE,
"SR (%s): Abort! can't create SR node in hash table",
__func__);
return;
}
/* update LSA ID */ /* update LSA ID */
srn->instance = ntohl(lsah->id.s_addr); srn->instance = ntohl(lsah->id.s_addr);
/* Copy SRGB */ /* Copy SRGB */
@ -1582,14 +1574,6 @@ void ospf_sr_ext_link_lsa_update(struct ospf_lsa *lsa)
(void *)&(lsah->adv_router), (void *)&(lsah->adv_router),
(void *)sr_node_new); (void *)sr_node_new);
/* Sanity check */
if (srn == NULL) {
flog_err(EC_OSPF_SR_NODE_CREATE,
"SR (%s): Abort! can't create SR node in hash table",
__func__);
return;
}
/* Initialize TLV browsing */ /* Initialize TLV browsing */
length = lsa->size - OSPF_LSA_HEADER_SIZE; length = lsa->size - OSPF_LSA_HEADER_SIZE;
for (tlvh = TLV_HDR_TOP(lsah); length > 0 && tlvh; for (tlvh = TLV_HDR_TOP(lsah); length > 0 && tlvh;
@ -1814,15 +1798,6 @@ void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *lsa)
srn = (struct sr_node *)hash_get(OspfSR.neighbors, srn = (struct sr_node *)hash_get(OspfSR.neighbors,
(void *)&(lsah->adv_router), (void *)&(lsah->adv_router),
(void *)sr_node_new); (void *)sr_node_new);
/* Sanity check */
if (srn == NULL) {
flog_err(EC_OSPF_SR_NODE_CREATE,
"SR (%s): Abort! can't create SR node in hash table",
__func__);
return;
}
/* Initialize TLV browsing */ /* Initialize TLV browsing */
length = lsa->size - OSPF_LSA_HEADER_SIZE; length = lsa->size - OSPF_LSA_HEADER_SIZE;
for (tlvh = TLV_HDR_TOP(lsah); length > 0 && tlvh; for (tlvh = TLV_HDR_TOP(lsah); length > 0 && tlvh;

View File

@ -1041,8 +1041,9 @@ static int pbr_nht_individual_nexthop_vrf_handle(struct hash_bucket *b,
nhrcvi.nhrc); nhrcvi.nhrc);
nhrcvi.nhrc->nexthop.vrf_id = nhrcvi.nhrc->nexthop.vrf_id =
pbr_vrf_id(pnhi->pbr_vrf); pbr_vrf_id(pnhi->pbr_vrf);
hash_get(pbr_nhrc_hash, nhrcvi.nhrc, (void)hash_get(pbr_nhrc_hash,
hash_alloc_intern); nhrcvi.nhrc,
hash_alloc_intern);
pbr_send_rnh(&nhrcvi.nhrc->nexthop, true); pbr_send_rnh(&nhrcvi.nhrc->nexthop, true);
} }
} while (nhrcvi.nhrc); } while (nhrcvi.nhrc);
@ -1087,7 +1088,8 @@ static void pbr_nht_nexthop_vrf_handle(struct hash_bucket *b, void *data)
if (pnhi.pnhc) { if (pnhi.pnhc) {
pnhi.pnhc->nexthop.vrf_id = pbr_vrf_id(pbr_vrf); pnhi.pnhc->nexthop.vrf_id = pbr_vrf_id(pbr_vrf);
hash_get(pnhgc->nhh, pnhi.pnhc, hash_alloc_intern); (void)hash_get(pnhgc->nhh, pnhi.pnhc,
hash_alloc_intern);
} else } else
pnhc->nexthop.vrf_id = pbr_vrf_id(pbr_vrf); pnhc->nexthop.vrf_id = pbr_vrf_id(pbr_vrf);
@ -1141,11 +1143,11 @@ static void pbr_nht_nexthop_interface_handle(struct hash_bucket *b, void *data)
if (nhrc) { if (nhrc) {
hash_release(pbr_nhrc_hash, nhrc); hash_release(pbr_nhrc_hash, nhrc);
nhrc->nexthop.ifindex = ifp->ifindex; nhrc->nexthop.ifindex = ifp->ifindex;
hash_get(pbr_nhrc_hash, nhrc, hash_alloc_intern); (void)hash_get(pbr_nhrc_hash, nhrc, hash_alloc_intern);
} }
pnhi.pnhc->nexthop.ifindex = ifp->ifindex; pnhi.pnhc->nexthop.ifindex = ifp->ifindex;
hash_get(pnhgc->nhh, pnhi.pnhc, hash_alloc_intern); (void)hash_get(pnhgc->nhh, pnhi.pnhc, hash_alloc_intern);
pbr_map_check_interface_nh_group_change(pnhgc->name, ifp, pbr_map_check_interface_nh_group_change(pnhgc->name, ifp,
old_ifindex); old_ifindex);
@ -1290,7 +1292,7 @@ uint32_t pbr_nht_reserve_next_table_id(struct pbr_nexthop_group_cache *nhgc)
nhgc->table_id = pbr_next_unallocated_table_id; nhgc->table_id = pbr_next_unallocated_table_id;
/* Mark table id as allocated in id-indexed hash */ /* Mark table id as allocated in id-indexed hash */
hash_get(pbr_nhg_allocated_id_hash, nhgc, hash_alloc_intern); (void)hash_get(pbr_nhg_allocated_id_hash, nhgc, hash_alloc_intern);
/* Pre-compute the next unallocated table id */ /* Pre-compute the next unallocated table id */
pbr_nht_update_next_unallocated_table_id(); pbr_nht_update_next_unallocated_table_id();

View File

@ -151,7 +151,7 @@ int pim_find_or_track_nexthop(struct pim_instance *pim, struct prefix *addr,
} }
if (up != NULL) if (up != NULL)
hash_get(pnc->upstream_hash, up, hash_alloc_intern); (void)hash_get(pnc->upstream_hash, up, hash_alloc_intern);
if (CHECK_FLAG(pnc->flags, PIM_NEXTHOP_VALID)) { if (CHECK_FLAG(pnc->flags, PIM_NEXTHOP_VALID)) {
if (out_pnc) if (out_pnc)

View File

@ -160,7 +160,7 @@ static void test_state_add_route(struct test_state *test,
} }
rn->info = (void *)0xdeadbeef; rn->info = (void *)0xdeadbeef;
hash_get(test->log, hash_entry, log_alloc); (void)hash_get(test->log, hash_entry, log_alloc);
}; };
static void test_state_del_route(struct test_state *test, static void test_state_del_route(struct test_state *test,

View File

@ -654,7 +654,7 @@ struct vrrp_vrouter *vrrp_vrouter_create(struct interface *ifp, uint8_t vrid,
vrrp_set_advertisement_interval(vr, vd.advertisement_interval); vrrp_set_advertisement_interval(vr, vd.advertisement_interval);
hash_get(vrrp_vrouters_hash, vr, hash_alloc_intern); (void)hash_get(vrrp_vrouters_hash, vr, hash_alloc_intern);
return vr; return vr;
} }

View File

@ -1022,7 +1022,6 @@ struct zebra_evpn *zebra_evpn_add(vni_t vni)
memset(&tmp_zevpn, 0, sizeof(struct zebra_evpn)); memset(&tmp_zevpn, 0, sizeof(struct zebra_evpn));
tmp_zevpn.vni = vni; tmp_zevpn.vni = vni;
zevpn = hash_get(zvrf->evpn_table, &tmp_zevpn, zebra_evpn_alloc); zevpn = hash_get(zvrf->evpn_table, &tmp_zevpn, zebra_evpn_alloc);
assert(zevpn);
zebra_evpn_es_evi_init(zevpn); zebra_evpn_es_evi_init(zevpn);

View File

@ -1105,7 +1105,6 @@ struct zebra_mac *zebra_evpn_mac_add(struct zebra_evpn *zevpn,
memset(&tmp_mac, 0, sizeof(struct zebra_mac)); memset(&tmp_mac, 0, sizeof(struct zebra_mac));
memcpy(&tmp_mac.macaddr, macaddr, ETH_ALEN); memcpy(&tmp_mac.macaddr, macaddr, ETH_ALEN);
mac = hash_get(zevpn->mac_table, &tmp_mac, zebra_evpn_mac_alloc); mac = hash_get(zevpn->mac_table, &tmp_mac, zebra_evpn_mac_alloc);
assert(mac);
mac->zevpn = zevpn; mac->zevpn = zevpn;
mac->dad_mac_auto_recovery_timer = NULL; mac->dad_mac_auto_recovery_timer = NULL;

View File

@ -570,10 +570,7 @@ zebra_evpn_acc_vl_new(vlanid_t vid, struct interface *br_if)
acc_bd->mbr_zifs = list_new(); acc_bd->mbr_zifs = list_new();
/* Add to hash */ /* Add to hash */
if (!hash_get(zmh_info->evpn_vlan_table, acc_bd, hash_alloc_intern)) { (void)hash_get(zmh_info->evpn_vlan_table, acc_bd, hash_alloc_intern);
XFREE(MTYPE_ZACC_BD, acc_bd);
return NULL;
}
/* check if an svi exists for the vlan */ /* check if an svi exists for the vlan */
if (br_if) { if (br_if) {
@ -1091,10 +1088,7 @@ static uint32_t zebra_evpn_nhid_alloc(struct zebra_evpn_es *es)
nh_id = id | EVPN_NHG_ID_TYPE_BIT; nh_id = id | EVPN_NHG_ID_TYPE_BIT;
/* Add to NHG hash */ /* Add to NHG hash */
es->nhg_id = nh_id; es->nhg_id = nh_id;
if (!hash_get(zmh_info->nhg_table, es, hash_alloc_intern)) { (void)hash_get(zmh_info->nhg_table, es, hash_alloc_intern);
bf_release_index(zmh_info->nh_id_bitmap, id);
return 0;
}
} else { } else {
nh_id = id | EVPN_NH_ID_TYPE_BIT; nh_id = id | EVPN_NH_ID_TYPE_BIT;
} }
@ -1361,10 +1355,7 @@ static struct zebra_evpn_l2_nh *zebra_evpn_l2_nh_alloc(struct in_addr vtep_ip)
nh = XCALLOC(MTYPE_L2_NH, sizeof(*nh)); nh = XCALLOC(MTYPE_L2_NH, sizeof(*nh));
nh->vtep_ip = vtep_ip; nh->vtep_ip = vtep_ip;
if (!hash_get(zmh_info->nh_ip_table, nh, hash_alloc_intern)) { (void)hash_get(zmh_info->nh_ip_table, nh, hash_alloc_intern);
XFREE(MTYPE_L2_NH, nh);
return NULL;
}
nh->nh_id = zebra_evpn_nhid_alloc(NULL); nh->nh_id = zebra_evpn_nhid_alloc(NULL);
if (!nh->nh_id) { if (!nh->nh_id) {

View File

@ -553,7 +553,6 @@ static struct zebra_neigh *zebra_evpn_neigh_add(struct zebra_evpn *zevpn,
memset(&tmp_n, 0, sizeof(struct zebra_neigh)); memset(&tmp_n, 0, sizeof(struct zebra_neigh));
memcpy(&tmp_n.ip, ip, sizeof(struct ipaddr)); memcpy(&tmp_n.ip, ip, sizeof(struct ipaddr));
n = hash_get(zevpn->neigh_table, &tmp_n, zebra_evpn_neigh_alloc); n = hash_get(zevpn->neigh_table, &tmp_n, zebra_evpn_neigh_alloc);
assert(n);
n->state = ZEBRA_NEIGH_INACTIVE; n->state = ZEBRA_NEIGH_INACTIVE;
n->zevpn = zevpn; n->zevpn = zevpn;

View File

@ -1596,12 +1596,9 @@ static int zfpm_trigger_rmac_update(struct zebra_mac *rmac,
UNSET_FLAG(fpm_mac->fpm_flags, ZEBRA_MAC_UPDATE_FPM); UNSET_FLAG(fpm_mac->fpm_flags, ZEBRA_MAC_UPDATE_FPM);
return 0; return 0;
} }
} else { } else
fpm_mac = hash_get(zfpm_g->fpm_mac_info_table, &key, fpm_mac = hash_get(zfpm_g->fpm_mac_info_table, &key,
zfpm_mac_info_alloc); zfpm_mac_info_alloc);
if (!fpm_mac)
return 0;
}
fpm_mac->r_vtep_ip.s_addr = rmac->fwd_info.r_vtep_ip.s_addr; fpm_mac->r_vtep_ip.s_addr = rmac->fwd_info.r_vtep_ip.s_addr;
fpm_mac->zebra_flags = rmac->flags; fpm_mac->zebra_flags = rmac->flags;

View File

@ -188,8 +188,6 @@ static int lsp_install(struct zebra_vrf *zvrf, mpls_label_t label,
/* Locate or allocate LSP entry. */ /* Locate or allocate LSP entry. */
tmp_ile.in_label = label; tmp_ile.in_label = label;
lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc); lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc);
if (!lsp)
return -1;
/* For each active nexthop, create NHLFE. Note that we deliberately skip /* For each active nexthop, create NHLFE. Note that we deliberately skip
* recursive nexthops right now, because intermediate hops won't * recursive nexthops right now, because intermediate hops won't
@ -2920,8 +2918,6 @@ int mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
/* Find or create LSP object */ /* Find or create LSP object */
tmp_ile.in_label = zl->local_label; tmp_ile.in_label = zl->local_label;
lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc); lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc);
if (!lsp)
return -1;
} }
/* Prep for route/FEC update if requested */ /* Prep for route/FEC update if requested */
@ -3199,8 +3195,6 @@ int mpls_lsp_install(struct zebra_vrf *zvrf, enum lsp_types_t type,
/* Find or create LSP object */ /* Find or create LSP object */
tmp_ile.in_label = in_label; tmp_ile.in_label = in_label;
lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc); lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc);
if (!lsp)
return -1;
nhlfe = lsp_add_nhlfe(lsp, type, num_out_labels, out_labels, gtype, nhlfe = lsp_add_nhlfe(lsp, type, num_out_labels, out_labels, gtype,
gate, ifindex, false /*backup*/); gate, ifindex, false /*backup*/);
@ -3562,8 +3556,6 @@ int zebra_mpls_static_lsp_add(struct zebra_vrf *zvrf, mpls_label_t in_label,
/* Find or create LSP. */ /* Find or create LSP. */
tmp_ile.in_label = in_label; tmp_ile.in_label = in_label;
lsp = hash_get(slsp_table, &tmp_ile, lsp_alloc); lsp = hash_get(slsp_table, &tmp_ile, lsp_alloc);
if (!lsp)
return -1;
nhlfe = nhlfe_find(&lsp->nhlfe_list, ZEBRA_LSP_STATIC, gtype, gate, nhlfe = nhlfe_find(&lsp->nhlfe_list, ZEBRA_LSP_STATIC, gtype, gate,
ifindex); ifindex);

View File

@ -329,7 +329,7 @@ static int zebra_nhg_insert_id(struct nhg_hash_entry *nhe)
return -1; return -1;
} }
hash_get(zrouter.nhgs_id, nhe, hash_alloc_intern); (void)hash_get(zrouter.nhgs_id, nhe, hash_alloc_intern);
return 0; return 0;
} }

View File

@ -1189,8 +1189,6 @@ static struct zebra_mac *zl3vni_rmac_add(struct zebra_l3vni *zl3vni,
memset(&tmp_rmac, 0, sizeof(struct zebra_mac)); memset(&tmp_rmac, 0, sizeof(struct zebra_mac));
memcpy(&tmp_rmac.macaddr, rmac, ETH_ALEN); memcpy(&tmp_rmac.macaddr, rmac, ETH_ALEN);
zrmac = hash_get(zl3vni->rmac_table, &tmp_rmac, zl3vni_rmac_alloc); zrmac = hash_get(zl3vni->rmac_table, &tmp_rmac, zl3vni_rmac_alloc);
assert(zrmac);
zrmac->nh_list = list_new(); zrmac->nh_list = list_new();
zrmac->nh_list->cmp = (int (*)(void *, void *))l3vni_rmac_nh_list_cmp; zrmac->nh_list->cmp = (int (*)(void *, void *))l3vni_rmac_nh_list_cmp;
zrmac->nh_list->del = (void (*)(void *))l3vni_rmac_nh_free; zrmac->nh_list->del = (void (*)(void *))l3vni_rmac_nh_free;
@ -1466,7 +1464,6 @@ static struct zebra_neigh *zl3vni_nh_add(struct zebra_l3vni *zl3vni,
memset(&tmp_n, 0, sizeof(struct zebra_neigh)); memset(&tmp_n, 0, sizeof(struct zebra_neigh));
memcpy(&tmp_n.ip, ip, sizeof(struct ipaddr)); memcpy(&tmp_n.ip, ip, sizeof(struct ipaddr));
n = hash_get(zl3vni->nh_table, &tmp_n, zl3vni_nh_alloc); n = hash_get(zl3vni->nh_table, &tmp_n, zl3vni_nh_alloc);
assert(n);
RB_INIT(host_rb_tree_entry, &n->host_rb); RB_INIT(host_rb_tree_entry, &n->host_rb);
@ -1696,7 +1693,6 @@ static struct zebra_l3vni *zl3vni_add(vni_t vni, vrf_id_t vrf_id)
tmp_zl3vni.vni = vni; tmp_zl3vni.vni = vni;
zl3vni = hash_get(zrouter.l3vni_table, &tmp_zl3vni, zl3vni_alloc); zl3vni = hash_get(zrouter.l3vni_table, &tmp_zl3vni, zl3vni_alloc);
assert(zl3vni);
zl3vni->vrf_id = vrf_id; zl3vni->vrf_id = vrf_id;
zl3vni->svi_if = NULL; zl3vni->svi_if = NULL;
@ -6039,11 +6035,6 @@ static struct zebra_vxlan_sg *zebra_vxlan_sg_add(struct zebra_vrf *zvrf,
} }
vxlan_sg = zebra_vxlan_sg_new(zvrf, sg); vxlan_sg = zebra_vxlan_sg_new(zvrf, sg);
if (!vxlan_sg) {
if (parent)
zebra_vxlan_sg_do_deref(zvrf, sip, sg->grp);
return vxlan_sg;
}
zebra_vxlan_sg_send(zvrf, sg, vxlan_sg->sg_str, zebra_vxlan_sg_send(zvrf, sg, vxlan_sg->sg_str,
ZEBRA_VXLAN_SG_ADD); ZEBRA_VXLAN_SG_ADD);