summaryrefslogtreecommitdiff
path: root/lib/nexthop_group.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-05-14 15:27:40 -0700
committerStephen Worley <sworley@cumulusnetworks.com>2019-10-25 11:13:40 -0400
commit98cda54a9543ea125e5e1eea6621c453f407edb2 (patch)
tree39d132983b105b883c40fe2d07a6c7a55b36eefe /lib/nexthop_group.c
parent1c3d2890408e05f60b4864a93a1dff0c23ab346c (diff)
zebra: Add recursive functionality to NHE's
Add the ability to recursively resolve nexthop group hash entries and resolve them when sending to the kernel. When copying over nexthops into an NHE, copy resolved info as well. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'lib/nexthop_group.c')
-rw-r--r--lib/nexthop_group.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c
index 463ab0b881..c9a8f1af51 100644
--- a/lib/nexthop_group.c
+++ b/lib/nexthop_group.c
@@ -81,6 +81,17 @@ uint8_t nexthop_group_nexthop_num(const struct nexthop_group *nhg)
return num;
}
+uint8_t nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg)
+{
+ struct nexthop *nhop;
+ uint8_t num = 0;
+
+ for (nhop = nhg->nexthop; nhop; nhop = nhop->next)
+ num++;
+
+ return num;
+}
+
uint8_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg)
{
struct nexthop *nhop;
@@ -94,6 +105,20 @@ uint8_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg)
return num;
}
+uint8_t
+nexthop_group_active_nexthop_num_no_recurse(const struct nexthop_group *nhg)
+{
+ struct nexthop *nhop;
+ uint8_t num = 0;
+
+ for (nhop = nhg->nexthop; nhop; nhop = nhop->next) {
+ if (CHECK_FLAG(nhop->flags, NEXTHOP_FLAG_ACTIVE))
+ num++;
+ }
+
+ return num;
+}
+
struct nexthop *nexthop_exists(const struct nexthop_group *nhg,
const struct nexthop *nh)
{
@@ -118,10 +143,11 @@ bool nexthop_group_equal(const struct nexthop_group *nhg1,
if (!nhg1 && !nhg2)
return false;
- if (nexthop_group_nexthop_num(nhg1) != nexthop_group_nexthop_num(nhg2))
+ if (nexthop_group_nexthop_num_no_recurse(nhg1)
+ != nexthop_group_nexthop_num_no_recurse(nhg2))
return false;
- for (ALL_NEXTHOPS_PTR(nhg1, nh)) {
+ for (nh = nhg1->nexthop; nh; nh = nh->next) {
if (!nexthop_exists(nhg2, nh))
return false;
}