]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: nexthop code should use uint16_t for nexthop counting 16967/head
authorDonald Sharp <sharpd@nvidia.com>
Tue, 1 Oct 2024 18:31:08 +0000 (14:31 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 1 Oct 2024 19:38:14 +0000 (15:38 -0400)
It's possible to specify via the cli and configure how many
nexthops that are allowed on the system.  If you happen to
have > 255 then things are about to get interesting otherwise.

Let's allow up to 65k nexthops (ha!)

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lib/nexthop_group.c
lib/nexthop_group.h

index 3f408e0a71f921c15b4a8610a06a62b1d608ec94..cb1ebb5d09b9aec2b2a28672ab69a324b1398d9e 100644 (file)
@@ -70,10 +70,10 @@ static struct nexthop *nexthop_group_tail(const struct nexthop_group *nhg)
        return nexthop;
 }
 
-uint8_t nexthop_group_nexthop_num(const struct nexthop_group *nhg)
+uint16_t nexthop_group_nexthop_num(const struct nexthop_group *nhg)
 {
        struct nexthop *nhop;
-       uint8_t num = 0;
+       uint16_t num = 0;
 
        for (ALL_NEXTHOPS_PTR(nhg, nhop))
                num++;
@@ -81,11 +81,10 @@ uint8_t nexthop_group_nexthop_num(const struct nexthop_group *nhg)
        return num;
 }
 
-static uint8_t
-nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg)
+static uint16_t nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg)
 {
        struct nexthop *nhop;
-       uint8_t num = 0;
+       uint16_t num = 0;
 
        for (nhop = nhg->nexthop; nhop; nhop = nhop->next)
                num++;
@@ -93,10 +92,10 @@ nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg)
        return num;
 }
 
-uint8_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg)
+uint16_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg)
 {
        struct nexthop *nhop;
-       uint8_t num = 0;
+       uint16_t num = 0;
 
        for (ALL_NEXTHOPS_PTR(nhg, nhop)) {
                if (CHECK_FLAG(nhop->flags, NEXTHOP_FLAG_ACTIVE))
@@ -184,11 +183,9 @@ static struct nexthop *nhg_nh_find(const struct nexthop_group *nhg,
        return NULL;
 }
 
-static bool
-nexthop_group_equal_common(const struct nexthop_group *nhg1,
-                          const struct nexthop_group *nhg2,
-                          uint8_t (*nexthop_group_nexthop_num_func)(
-                                  const struct nexthop_group *nhg))
+static bool nexthop_group_equal_common(
+       const struct nexthop_group *nhg1, const struct nexthop_group *nhg2,
+       uint16_t (*nexthop_group_nexthop_num_func)(const struct nexthop_group *nhg))
 {
        if (nhg1 && !nhg2)
                return false;
index 822a35439cc08703a68b4a2a3bedc3e80fd39899..9103299418840788287a3846592b74e897ff38e4 100644 (file)
@@ -149,9 +149,8 @@ extern void nexthop_group_json_nexthop(json_object *j,
                                       const 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_active_nexthop_num(const struct nexthop_group *nhg);
+extern uint16_t nexthop_group_nexthop_num(const struct nexthop_group *nhg);
+extern uint16_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg);
 
 extern bool nexthop_group_has_label(const struct nexthop_group *nhg);