]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: add has_label function for nexthop groups
authorStephen Worley <sworley@nvidia.com>
Mon, 5 Apr 2021 21:13:01 +0000 (17:13 -0400)
committerStephen Worley <sworley@nvidia.com>
Mon, 13 Feb 2023 23:12:04 +0000 (18:12 -0500)
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 <sworley@nvidia.com>
lib/nexthop_group.c
lib/nexthop_group.h

index 41fe64606bfd217d93dabc3ebf4394d855e3bdea..44bddacd58ee6e6392df3cd4933eb73816de3b98 100644 (file)
@@ -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)
 {
index 0ea0b7c18526b2acbf7802cccf357900ba2faea1..4d560fc43896c2c4c1fa936f9bf88705790018de 100644 (file)
@@ -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