]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: Resolved nh change, inc refcnt by rt refcnt
authorStephen Worley <sworley@cumulusnetworks.com>
Tue, 2 Jul 2019 05:04:29 +0000 (01:04 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:40 +0000 (11:13 -0400)
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>
zebra/zebra_nhg.c

index ebe507a73c5a07469d590d68fa050994bd66a828..436783065d7f9a7423adb1866259edc488461286 100644 (file)
@@ -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