diff options
| author | Stephen Worley <sworley@cumulusnetworks.com> | 2019-07-02 01:04:29 -0400 |
|---|---|---|
| committer | Stephen Worley <sworley@cumulusnetworks.com> | 2019-10-25 11:13:40 -0400 |
| commit | 9834bb52aebb46fc4ba85e959cc98adda996a4b3 (patch) | |
| tree | 5807fe69cf0cb45a50fb8b8bda59f971867b6205 | |
| parent | 1e9aad82ba65df9c50eb819334cb2caace57df6c (diff) | |
zebra: Resolved nh change, inc refcnt by rt refcnt
When the resolved nexthop changes, we should increment the new
resolved NHE by the refcnt for the unresolved NHE being used
by the routes and decrement the old one by the same amount.
Before, we were simple incrementing by one, causing incorrect refcnts
to occur.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
| -rw-r--r-- | zebra/zebra_nhg.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index ebe507a73c..436783065d 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -1364,13 +1364,12 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re) /* Add new resolved */ zebra_nhg_depends_add(nhe, new_resolved); zebra_nhg_dependents_add(new_resolved, nhe); - /* - * In case the new == old, we increment - * first and then decrement - */ - zebra_nhg_increment_ref(new_resolved); - if (old_resolved) - zebra_nhg_decrement_ref(old_resolved); + + if (old_resolved && new_resolved->id != old_resolved->id) { + new_resolved->refcnt+=nhe->refcnt; + old_resolved->refcnt-=nhe->refcnt; + } else if (!old_resolved) + zebra_nhg_increment_ref(new_resolved); SET_FLAG(nhe->flags, NEXTHOP_GROUP_RECURSIVE); } else |
