diff options
Diffstat (limited to 'lib/nexthop_group.c')
| -rw-r--r-- | lib/nexthop_group.c | 30 |
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; } |
