mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-29 10:32:00 +00:00
commit
9bbf785892
@ -1035,15 +1035,12 @@ static void lsp_processq_del(struct work_queue *wq, void *data)
|
|||||||
struct zebra_lsp *lsp;
|
struct zebra_lsp *lsp;
|
||||||
struct hash *lsp_table;
|
struct hash *lsp_table;
|
||||||
struct zebra_nhlfe *nhlfe;
|
struct zebra_nhlfe *nhlfe;
|
||||||
bool in_shutdown = false;
|
|
||||||
|
|
||||||
/* If zebra is shutting down, don't delete any structs,
|
/* If zebra is shutting down, don't delete any structs,
|
||||||
* just ignore this callback. The LSPs will be cleaned up
|
* just ignore this callback. The LSPs will be cleaned up
|
||||||
* during the shutdown processing.
|
* during the shutdown processing.
|
||||||
*/
|
*/
|
||||||
in_shutdown = atomic_load_explicit(&zrouter.in_shutdown,
|
if (zebra_router_in_shutdown())
|
||||||
memory_order_relaxed);
|
|
||||||
if (in_shutdown)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
zvrf = vrf_info_lookup(VRF_DEFAULT);
|
zvrf = vrf_info_lookup(VRF_DEFAULT);
|
||||||
|
@ -1058,7 +1058,7 @@ static void zebra_nhg_set_invalid(struct nhg_hash_entry *nhe)
|
|||||||
/* If we're in shutdown, this interface event needs to clean
|
/* If we're in shutdown, this interface event needs to clean
|
||||||
* up installed NHGs, so don't clear that flag directly.
|
* up installed NHGs, so don't clear that flag directly.
|
||||||
*/
|
*/
|
||||||
if (!zrouter.in_shutdown)
|
if (!zebra_router_in_shutdown())
|
||||||
UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
|
UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
|
||||||
|
|
||||||
/* Update validity of nexthops depending on it */
|
/* Update validity of nexthops depending on it */
|
||||||
@ -1621,10 +1621,61 @@ void zebra_nhg_free(struct nhg_hash_entry *nhe)
|
|||||||
XFREE(MTYPE_NHG, nhe);
|
XFREE(MTYPE_NHG, nhe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Let's just drop the memory associated with each item
|
||||||
|
*/
|
||||||
void zebra_nhg_hash_free(void *p)
|
void zebra_nhg_hash_free(void *p)
|
||||||
{
|
{
|
||||||
zebra_nhg_release_all_deps((struct nhg_hash_entry *)p);
|
struct nhg_hash_entry *nhe = p;
|
||||||
zebra_nhg_free((struct nhg_hash_entry *)p);
|
|
||||||
|
if (IS_ZEBRA_DEBUG_NHG_DETAIL) {
|
||||||
|
/* Group or singleton? */
|
||||||
|
if (nhe->nhg.nexthop && nhe->nhg.nexthop->next)
|
||||||
|
zlog_debug("%s: nhe %p (%u), refcnt %d", __func__, nhe,
|
||||||
|
nhe->id, nhe->refcnt);
|
||||||
|
else
|
||||||
|
zlog_debug("%s: nhe %p (%pNG), refcnt %d, NH %pNHv",
|
||||||
|
__func__, nhe, nhe, nhe->refcnt,
|
||||||
|
nhe->nhg.nexthop);
|
||||||
|
}
|
||||||
|
|
||||||
|
THREAD_OFF(nhe->timer);
|
||||||
|
|
||||||
|
nexthops_free(nhe->nhg.nexthop);
|
||||||
|
|
||||||
|
XFREE(MTYPE_NHG, nhe);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On cleanup there are nexthop groups that have not
|
||||||
|
* been resolved at all( a nhe->id of 0 ). As such
|
||||||
|
* zebra needs to clean up the memory associated with
|
||||||
|
* those entries.
|
||||||
|
*/
|
||||||
|
void zebra_nhg_hash_free_zero_id(struct hash_bucket *b, void *arg)
|
||||||
|
{
|
||||||
|
struct nhg_hash_entry *nhe = b->data;
|
||||||
|
struct nhg_connected *dep;
|
||||||
|
|
||||||
|
while ((dep = nhg_connected_tree_pop(&nhe->nhg_depends))) {
|
||||||
|
if (dep->nhe->id == 0)
|
||||||
|
zebra_nhg_hash_free(dep->nhe);
|
||||||
|
|
||||||
|
nhg_connected_free(dep);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((dep = nhg_connected_tree_pop(&nhe->nhg_dependents)))
|
||||||
|
nhg_connected_free(dep);
|
||||||
|
|
||||||
|
if (nhe->backup_info && nhe->backup_info->nhe->id == 0) {
|
||||||
|
while ((dep = nhg_connected_tree_pop(
|
||||||
|
&nhe->backup_info->nhe->nhg_depends)))
|
||||||
|
nhg_connected_free(dep);
|
||||||
|
|
||||||
|
zebra_nhg_hash_free(nhe->backup_info->nhe);
|
||||||
|
|
||||||
|
XFREE(MTYPE_NHG, nhe->backup_info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zebra_nhg_timer(struct thread *thread)
|
static void zebra_nhg_timer(struct thread *thread)
|
||||||
@ -1646,13 +1697,14 @@ void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe)
|
|||||||
|
|
||||||
nhe->refcnt--;
|
nhe->refcnt--;
|
||||||
|
|
||||||
if (!zrouter.in_shutdown && nhe->refcnt <= 0 &&
|
if (!zebra_router_in_shutdown() && nhe->refcnt <= 0 &&
|
||||||
CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED) &&
|
CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED) &&
|
||||||
!CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_KEEP_AROUND)) {
|
!CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_KEEP_AROUND)) {
|
||||||
nhe->refcnt = 1;
|
nhe->refcnt = 1;
|
||||||
SET_FLAG(nhe->flags, NEXTHOP_GROUP_KEEP_AROUND);
|
SET_FLAG(nhe->flags, NEXTHOP_GROUP_KEEP_AROUND);
|
||||||
thread_add_timer(zrouter.master, zebra_nhg_timer, nhe,
|
thread_add_timer(zrouter.master, zebra_nhg_timer, nhe,
|
||||||
zrouter.nhg_keep, &nhe->timer);
|
zrouter.nhg_keep, &nhe->timer);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!zebra_nhg_depends_is_empty(nhe))
|
if (!zebra_nhg_depends_is_empty(nhe))
|
||||||
|
@ -256,6 +256,7 @@ struct nhg_hash_entry *zebra_nhg_alloc(void);
|
|||||||
void zebra_nhg_free(struct nhg_hash_entry *nhe);
|
void zebra_nhg_free(struct nhg_hash_entry *nhe);
|
||||||
/* In order to clear a generic hash, we need a generic api, sigh. */
|
/* In order to clear a generic hash, we need a generic api, sigh. */
|
||||||
void zebra_nhg_hash_free(void *p);
|
void zebra_nhg_hash_free(void *p);
|
||||||
|
void zebra_nhg_hash_free_zero_id(struct hash_bucket *b, void *arg);
|
||||||
|
|
||||||
/* Init an nhe, for use in a hash lookup for example. There's some fuzziness
|
/* Init an nhe, for use in a hash lookup for example. There's some fuzziness
|
||||||
* if the nhe represents only a single nexthop, so we try to capture that
|
* if the nhe represents only a single nexthop, so we try to capture that
|
||||||
|
@ -246,6 +246,7 @@ void zebra_router_terminate(void)
|
|||||||
zebra_neigh_terminate();
|
zebra_neigh_terminate();
|
||||||
|
|
||||||
/* Free NHE in ID table only since it has unhashable entries as well */
|
/* Free NHE in ID table only since it has unhashable entries as well */
|
||||||
|
hash_iterate(zrouter.nhgs_id, zebra_nhg_hash_free_zero_id, NULL);
|
||||||
hash_clean(zrouter.nhgs_id, zebra_nhg_hash_free);
|
hash_clean(zrouter.nhgs_id, zebra_nhg_hash_free);
|
||||||
hash_free(zrouter.nhgs_id);
|
hash_free(zrouter.nhgs_id);
|
||||||
hash_clean(zrouter.nhgs, NULL);
|
hash_clean(zrouter.nhgs, NULL);
|
||||||
|
@ -285,6 +285,11 @@ static inline void zebra_router_set_supports_nhgs(bool support)
|
|||||||
zrouter.supports_nhgs = support;
|
zrouter.supports_nhgs = support;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool zebra_router_in_shutdown(void)
|
||||||
|
{
|
||||||
|
return atomic_load_explicit(&zrouter.in_shutdown, memory_order_relaxed);
|
||||||
|
}
|
||||||
|
|
||||||
/* zebra_northbound.c */
|
/* zebra_northbound.c */
|
||||||
extern const struct frr_yang_module_info frr_zebra_info;
|
extern const struct frr_yang_module_info frr_zebra_info;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user