Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: nexthop code should use uint16_t for nexthop counting #16967

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions lib/nexthop_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,33 +70,32 @@ 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++;

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++;

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))
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions lib/nexthop_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading