summaryrefslogtreecommitdiff
path: root/zebra/zebra_rib.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-05-30 16:14:42 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-09-12 10:05:07 -0400
commit25b9cb0cc834df7966338f76746e90bca8586161 (patch)
tree4ecaf2667b187f715aec7574bbd9e3f5dd0d310a /zebra/zebra_rib.c
parent953d97fc4aef0c7715e8d42d7d52ebc18d873ac6 (diff)
zebra: deduplicate nexthops
There exists situations where it is possible to have duplicate nexthops passed from a higher level protocol into zebra. This code notices this duplication of nexthops and marks the duplicates as DUPLICATE so we don't attempt to install it into the kernel. This is important on *BSD as I understand it because passing duplicate nexthops will cause the route to be rejected. Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_rib.c')
-rw-r--r--zebra/zebra_rib.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index c4c80b156b..f88e594a99 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1000,8 +1000,24 @@ int rib_install_kernel(struct route_node *rn, struct route_entry *re,
for (ALL_NEXTHOPS(re->nexthop, nexthop))
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB);
return ret;
+ } else {
+ struct nexthop *prev;
+
+ for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
+ UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_DUPLICATE);
+ for (ALL_NEXTHOPS(re->nexthop, prev)) {
+ if (prev == nexthop)
+ break;
+ if (nexthop_same_firsthop (nexthop, prev))
+ {
+ SET_FLAG (nexthop->flags, NEXTHOP_FLAG_DUPLICATE);
+ break;
+ }
+ }
+ }
}
+
/*
* Make sure we update the FPM any time we send new information to
* the kernel.