]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib,zebra: Move nexthop dup marking into creation
authorStephen Worley <sworley@cumulusnetworks.com>
Wed, 7 Aug 2019 15:33:01 +0000 (11:33 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:42 +0000 (11:13 -0400)
We were waiting until install time to mark nexthops as duplicate.
Since they are immutable now and re-used, move this marking into
when they are actually created to save a bunch of cycles.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
lib/nexthop_group.c
lib/nexthop_group.h
zebra/zebra_nhg.c
zebra/zebra_rib.c

index fb569360c486430d78bb08521bf22978d3a27293..8bb6fc9593c8bea8cd04c2c82720ce7f9b37fb06 100644 (file)
@@ -302,6 +302,24 @@ uint32_t nexthop_group_hash(const struct nexthop_group *nhg)
        return key;
 }
 
+void nexthop_group_mark_duplicates(struct nexthop_group *nhg)
+{
+       struct nexthop *nexthop, *prev;
+
+       for (ALL_NEXTHOPS_PTR(nhg, nexthop)) {
+               UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE);
+               for (ALL_NEXTHOPS_PTR(nhg, prev)) {
+                       if (prev == nexthop)
+                               break;
+                       if (nexthop_same_firsthop(nexthop, prev)) {
+                               SET_FLAG(nexthop->flags,
+                                        NEXTHOP_FLAG_DUPLICATE);
+                               break;
+                       }
+               }
+       }
+}
+
 static void nhgc_delete_nexthops(struct nexthop_group_cmd *nhgc)
 {
        struct nexthop *nexthop;
index a765b4b76b130b6db05509a3297f455ccd69f8e2..291a259f935490822c593106888a514653684cf4 100644 (file)
@@ -50,6 +50,7 @@ void copy_nexthops(struct nexthop **tnh, const struct nexthop *nh,
 
 uint32_t nexthop_group_hash_no_recurse(const struct nexthop_group *nhg);
 uint32_t nexthop_group_hash(const struct nexthop_group *nhg);
+void nexthop_group_mark_duplicates(struct nexthop_group *nhg);
 
 /* The following for loop allows to iterate over the nexthop
  * structure of routes.
index 3a2efacd9beabbd1447f06a8ba6613a6a3f4c7d8..9e19c8d0e3655e532cb8a0e09821b4587309c818 100644 (file)
@@ -346,6 +346,10 @@ static void *zebra_nhg_hash_alloc(void *arg)
        struct nhg_hash_entry *copy = arg;
 
        nhe = zebra_nhg_copy(copy, copy->id);
+
+       /* Mark duplicate nexthops in a group at creation time. */
+       nexthop_group_mark_duplicates(nhe->nhg);
+
        zebra_nhg_connect_depends(nhe, copy->nhg_depends);
        zebra_nhg_insert_id(nhe);
 
index 1440171584b579c0906c15a3a85d31e1155c26e4..52cc019d7c7c70c4b21b19168643431c59b8c281 100644 (file)
@@ -528,23 +528,9 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re,
                for (ALL_NEXTHOPS_PTR(re->ng, nexthop))
                        SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
                return;
-       } else {
-               struct nexthop *prev;
-
-               for (ALL_NEXTHOPS_PTR(re->ng, nexthop)) {
-                       UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_DUPLICATE);
-                       for (ALL_NEXTHOPS_PTR(re->ng, prev)) {
-                               if (prev == nexthop)
-                                       break;
-                               if (nexthop_same_firsthop(nexthop, prev)) {
-                                       SET_FLAG(nexthop->flags,
-                                                NEXTHOP_FLAG_DUPLICATE);
-                                       break;
-                               }
-                       }
-               }
        }
 
+
        /*
         * Install the resolved nexthop object first.
         */