diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/nexthop.h | 1 | ||||
| -rw-r--r-- | lib/nexthop_group.c | 30 | ||||
| -rw-r--r-- | lib/nexthop_group.h | 4 |
3 files changed, 33 insertions, 2 deletions
diff --git a/lib/nexthop.h b/lib/nexthop.h index 9dd5fc6fd3..5558e857f6 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -154,6 +154,7 @@ extern int nexthop_same_firsthop(struct nexthop *next1, struct nexthop *next2); extern const char *nexthop2str(const struct nexthop *nexthop, char *str, int size); extern struct nexthop *nexthop_next(struct nexthop *nexthop); +extern struct nexthop *nexthop_recursive_next(struct nexthop *nexthop); extern unsigned int nexthop_level(struct nexthop *nexthop); /* Copies to an already allocated nexthop struct */ extern void nexthop_copy(struct nexthop *copy, const struct nexthop *nexthop, 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; } diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h index be6f50d8a0..57a5a97599 100644 --- a/lib/nexthop_group.h +++ b/lib/nexthop_group.h @@ -123,7 +123,11 @@ extern void nexthop_group_write_nexthop(struct vty *vty, struct nexthop *nh); /* Return the number of nexthops in this nhg */ extern uint8_t nexthop_group_nexthop_num(const struct nexthop_group *nhg); extern uint8_t +nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg); +extern uint8_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg); +extern uint8_t +nexthop_group_active_nexthop_num_no_recurse(const struct nexthop_group *nhg); #ifdef __cplusplus } |
