Skip to content

Commit 0bc79f5

Browse files
committed
lib: nexthop code should use uint16_t for nexthop counting
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>
1 parent 237152f commit 0bc79f5

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

lib/nexthop_group.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,33 +70,32 @@ static struct nexthop *nexthop_group_tail(const struct nexthop_group *nhg)
7070
return nexthop;
7171
}
7272

73-
uint8_t nexthop_group_nexthop_num(const struct nexthop_group *nhg)
73+
uint16_t nexthop_group_nexthop_num(const struct nexthop_group *nhg)
7474
{
7575
struct nexthop *nhop;
76-
uint8_t num = 0;
76+
uint16_t num = 0;
7777

7878
for (ALL_NEXTHOPS_PTR(nhg, nhop))
7979
num++;
8080

8181
return num;
8282
}
8383

84-
static uint8_t
85-
nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg)
84+
static uint16_t nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg)
8685
{
8786
struct nexthop *nhop;
88-
uint8_t num = 0;
87+
uint16_t num = 0;
8988

9089
for (nhop = nhg->nexthop; nhop; nhop = nhop->next)
9190
num++;
9291

9392
return num;
9493
}
9594

96-
uint8_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg)
95+
uint16_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg)
9796
{
9897
struct nexthop *nhop;
99-
uint8_t num = 0;
98+
uint16_t num = 0;
10099

101100
for (ALL_NEXTHOPS_PTR(nhg, nhop)) {
102101
if (CHECK_FLAG(nhop->flags, NEXTHOP_FLAG_ACTIVE))
@@ -184,11 +183,9 @@ static struct nexthop *nhg_nh_find(const struct nexthop_group *nhg,
184183
return NULL;
185184
}
186185

187-
static bool
188-
nexthop_group_equal_common(const struct nexthop_group *nhg1,
189-
const struct nexthop_group *nhg2,
190-
uint8_t (*nexthop_group_nexthop_num_func)(
191-
const struct nexthop_group *nhg))
186+
static bool nexthop_group_equal_common(
187+
const struct nexthop_group *nhg1, const struct nexthop_group *nhg2,
188+
uint16_t (*nexthop_group_nexthop_num_func)(const struct nexthop_group *nhg))
192189
{
193190
if (nhg1 && !nhg2)
194191
return false;

lib/nexthop_group.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,8 @@ extern void nexthop_group_json_nexthop(json_object *j,
149149
const struct nexthop *nh);
150150

151151
/* Return the number of nexthops in this nhg */
152-
extern uint8_t nexthop_group_nexthop_num(const struct nexthop_group *nhg);
153-
extern uint8_t
154-
nexthop_group_active_nexthop_num(const struct nexthop_group *nhg);
152+
extern uint16_t nexthop_group_nexthop_num(const struct nexthop_group *nhg);
153+
extern uint16_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg);
155154

156155
extern bool nexthop_group_has_label(const struct nexthop_group *nhg);
157156

0 commit comments

Comments
 (0)