mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 11:24:24 +00:00
lib: Add a counter for number of nexthops
Add a ability to count the number of nexthops in a nexthop_group. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
73587535ff
commit
454192f46f
@ -59,6 +59,30 @@ nexthop_group_cmd_compare(const struct nexthop_group_cmd *nhgc1,
|
||||
return strcmp(nhgc1->name, nhgc2->name);
|
||||
}
|
||||
|
||||
uint8_t nexthop_group_nexthop_num(const struct nexthop_group *nhg)
|
||||
{
|
||||
struct nexthop *nhop;
|
||||
uint8_t num = 0;
|
||||
|
||||
for (ALL_NEXTHOPS_PTR(nhg, nhop))
|
||||
num++;
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
uint8_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg)
|
||||
{
|
||||
struct nexthop *nhop;
|
||||
uint8_t num = 0;
|
||||
|
||||
for (ALL_NEXTHOPS_PTR(nhg, nhop)) {
|
||||
if (CHECK_FLAG(nhop->flags, NEXTHOP_FLAG_ACTIVE))
|
||||
num++;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
struct nexthop *nexthop_exists(struct nexthop_group *nhg, struct nexthop *nh)
|
||||
{
|
||||
struct nexthop *nexthop;
|
||||
|
@ -117,6 +117,11 @@ extern struct nexthop_group_cmd *nhgc_find(const char *name);
|
||||
|
||||
extern void nexthop_group_write_nexthop(struct vty *vty, 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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user