From: Stephen Worley Date: Mon, 5 Apr 2021 21:13:01 +0000 (-0400) Subject: lib: add has_label function for nexthop groups X-Git-Tag: base_9.0~402^2~42 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=78d106e1cbb0af335409f60ababe5a2649da9704;p=matthieu%2Ffrr.git lib: add has_label function for nexthop groups Add a function nexthop_group_has_label() for determining if even a single nexthop in the group has a label on it. Signed-off-by: Stephen Worley --- diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 41fe64606b..44bddacd58 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -131,6 +131,18 @@ nexthop_group_active_nexthop_num_no_recurse(const struct nexthop_group *nhg) return num; } +bool nexthop_group_has_label(const struct nexthop_group *nhg) +{ + struct nexthop *nhop; + + for (ALL_NEXTHOPS_PTR(nhg, nhop)) { + if (nhop->nh_label) + return true; + } + + return false; +} + struct nexthop *nexthop_exists(const struct nexthop_group *nhg, const struct nexthop *nh) { diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h index 0ea0b7c185..4d560fc438 100644 --- a/lib/nexthop_group.h +++ b/lib/nexthop_group.h @@ -170,6 +170,8 @@ 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); +extern bool nexthop_group_has_label(const struct nexthop_group *nhg); + #ifdef __cplusplus } #endif