diff options
author | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2025-01-09 22:38:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-09 22:38:54 +0100 |
commit | 34431a38f192f32a4e357c2840e4cae434514201 (patch) | |
tree | e245384e0266ca5893401cf6c20ac894c3e6c654 | |
parent | Merge pull request #17801 from enkechen-panw/aggr-fix2 (diff) | |
parent | zebra: Fix leaked nhe (diff) | |
download | frr-34431a38f192f32a4e357c2840e4cae434514201.tar.xz frr-34431a38f192f32a4e357c2840e4cae434514201.zip |
Merge pull request #17809 from donaldsharp/nhg_fix
zebra: Fix leaked nhe
-rw-r--r-- | zebra/zebra_nhg.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index a32fc2bb1..6a43fe0c8 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -3089,7 +3089,7 @@ static struct nhg_hash_entry *zebra_nhg_rib_compare_old_nhe( int nexthop_active_update(struct route_node *rn, struct route_entry *re, struct route_entry *old_re) { - struct nhg_hash_entry *curr_nhe; + struct nhg_hash_entry *curr_nhe, *remove; uint32_t curr_active = 0, backup_active = 0; if (PROTO_OWNED(re->nhe)) @@ -3143,16 +3143,25 @@ backups_done: new_nhe = zebra_nhg_rib_find_nhe(curr_nhe, rt_afi); + remove = new_nhe; + if (old_re && old_re->type == re->type && old_re->instance == re->instance) new_nhe = zebra_nhg_rib_compare_old_nhe(rn, re, new_nhe, old_re->nhe); if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug( - "%s: re %p CHANGED: nhe %p (%pNG) => new_nhe %p (%pNG)", - __func__, re, re->nhe, re->nhe, new_nhe, - new_nhe); + zlog_debug("%s: re %p CHANGED: nhe %p (%pNG) => new_nhe %p (%pNG) rib_find_nhe returned %p (%pNG) refcnt: %d", + __func__, re, re->nhe, re->nhe, new_nhe, new_nhe, remove, remove, + remove ? remove->refcnt : 0); + + /* + * if the results from zebra_nhg_rib_find_nhe is being + * dropped and it was generated in that function + * (refcnt of 0) then we know we can clean it up + */ + if (remove && remove != new_nhe && remove != re->nhe && remove->refcnt == 0) + zebra_nhg_handle_uninstall(remove); route_entry_update_nhe(re, new_nhe); } |