summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/nexthop_group.c18
-rw-r--r--lib/nexthop_group.h1
-rw-r--r--zebra/zebra_nhg.c4
-rw-r--r--zebra/zebra_rib.c16
4 files changed, 24 insertions, 15 deletions
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c
index fb569360c4..8bb6fc9593 100644
--- a/lib/nexthop_group.c
+++ b/lib/nexthop_group.c
@@ -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;
diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h
index a765b4b76b..291a259f93 100644
--- a/lib/nexthop_group.h
+++ b/lib/nexthop_group.h
@@ -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.
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index 3a2efacd9b..9e19c8d0e3 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -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);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 1440171584..52cc019d7c 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -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.
*/