mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 01:52:27 +00:00
zebra: Add helper functions for freeing the members of nexthop group hash entries
Add some functions that can be called to free everything that should have been allocated in a nexthop group hash entry. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
This commit is contained in:
parent
cced3a2d29
commit
b599cd2acc
@ -328,38 +328,54 @@ struct nhg_hash_entry *zebra_nhg_find(struct nexthop_group *nhg,
|
|||||||
lookup.id = id;
|
lookup.id = id;
|
||||||
lookup.vrf_id = vrf_id;
|
lookup.vrf_id = vrf_id;
|
||||||
lookup.afi = afi;
|
lookup.afi = afi;
|
||||||
lookup.nhg = *nhg;
|
lookup.nhg = nhg;
|
||||||
lookup.nhg_depends = NULL;
|
lookup.nhg_depends = nhg_depends;
|
||||||
|
|
||||||
if (dep_count)
|
if (id)
|
||||||
lookup.nhg_depends = nhg_depends;
|
nhe = zebra_nhg_lookup_id(id);
|
||||||
|
else
|
||||||
nhe = hash_lookup(zrouter.nhgs, &lookup);
|
nhe = hash_lookup(zrouter.nhgs, &lookup);
|
||||||
|
|
||||||
if (!nhe) {
|
if (!nhe) {
|
||||||
nhe = hash_get(zrouter.nhgs, &lookup, zebra_nhg_alloc);
|
nhe = hash_get(zrouter.nhgs, &lookup, zebra_nhg_alloc);
|
||||||
} else {
|
} else {
|
||||||
if (id) {
|
zebra_nhg_free_group_depends(nhg, nhg_depends);
|
||||||
/* Duplicate but with different ID from the kernel */
|
|
||||||
|
|
||||||
/* The kernel allows duplicate nexthops as long as they
|
|
||||||
* have different IDs. We are ignoring those to prevent
|
|
||||||
* syncing problems with the kernel changes.
|
|
||||||
*/
|
|
||||||
flog_warn(
|
|
||||||
EC_ZEBRA_DUPLICATE_NHG_MESSAGE,
|
|
||||||
"Nexthop Group from with ID (%d) is a duplicate, ignoring",
|
|
||||||
id);
|
|
||||||
if (lookup.nhg_depends)
|
|
||||||
list_delete(&lookup.nhg_depends);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nhe;
|
return nhe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* zebra_nhg_free_group_depends() - Helper function for freeing nexthop_group
|
||||||
|
* struct and depends
|
||||||
|
*
|
||||||
|
* @nhg: Nexthop group
|
||||||
|
* @nhg_depends: Nexthop group hash entry dependency list
|
||||||
|
*/
|
||||||
|
void zebra_nhg_free_group_depends(struct nexthop_group *nhg,
|
||||||
|
struct list *nhg_depends)
|
||||||
|
{
|
||||||
|
if (nhg_depends)
|
||||||
|
list_delete(&nhg_depends);
|
||||||
|
if (nhg) {
|
||||||
|
if (nhg->nexthop)
|
||||||
|
nexthops_free(nhg->nexthop);
|
||||||
|
nexthop_group_delete(&nhg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* zebra_nhg_free_members() - Free all members in the hash entry struct
|
||||||
|
*
|
||||||
|
* @nhe: Nexthop group hash entry
|
||||||
|
*
|
||||||
|
* Just use this to free everything but the entry itself.
|
||||||
|
*/
|
||||||
|
void zebra_nhg_free_members(struct nhg_hash_entry *nhe)
|
||||||
|
{
|
||||||
|
zebra_nhg_free_group_depends(nhe->nhg, nhe->nhg_depends);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* zebra_nhg_free() - Free the nexthop group hash entry
|
* zebra_nhg_free() - Free the nexthop group hash entry
|
||||||
*
|
*
|
||||||
|
@ -104,6 +104,9 @@ extern struct nhg_hash_entry *
|
|||||||
zebra_nhg_find(struct nexthop_group *nhg, vrf_id_t vrf_id, afi_t afi,
|
zebra_nhg_find(struct nexthop_group *nhg, vrf_id_t vrf_id, afi_t afi,
|
||||||
uint32_t id, struct list *nhg_depends, int dep_count);
|
uint32_t id, struct list *nhg_depends, int dep_count);
|
||||||
|
|
||||||
|
void zebra_nhg_free_group_depends(struct nexthop_group *nhg,
|
||||||
|
struct list *nhg_depends);
|
||||||
|
void zebra_nhg_free_members(struct nhg_hash_entry *nhe);
|
||||||
void zebra_nhg_free(void *arg);
|
void zebra_nhg_free(void *arg);
|
||||||
void zebra_nhg_release(struct nhg_hash_entry *nhe);
|
void zebra_nhg_release(struct nhg_hash_entry *nhe);
|
||||||
void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe);
|
void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe);
|
||||||
|
Loading…
Reference in New Issue
Block a user