mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 15:43:55 +00:00
lib: Separate nexthop_group_equal() into recursive
Separate nexthop_group_equal() into two versions. One that compares verses recurisvely resolved nexthops and one that doesn't. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
This commit is contained in:
parent
9ef49038d5
commit
2171b19c5a
@ -133,8 +133,8 @@ struct nexthop *nexthop_exists(const struct nexthop_group *nhg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This assumes ordered */
|
/* This assumes ordered */
|
||||||
bool nexthop_group_equal(const struct nexthop_group *nhg1,
|
bool nexthop_group_equal_no_recurse(const struct nexthop_group *nhg1,
|
||||||
const struct nexthop_group *nhg2)
|
const struct nexthop_group *nhg2)
|
||||||
{
|
{
|
||||||
struct nexthop *nh1 = NULL;
|
struct nexthop *nh1 = NULL;
|
||||||
struct nexthop *nh2 = NULL;
|
struct nexthop *nh2 = NULL;
|
||||||
@ -149,7 +149,7 @@ bool nexthop_group_equal(const struct nexthop_group *nhg1,
|
|||||||
!= nexthop_group_nexthop_num_no_recurse(nhg2))
|
!= nexthop_group_nexthop_num_no_recurse(nhg2))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (nh1 = nhg1->nexthop, nh2 = nhg2->nexthop; nh1 && nh2;
|
for (nh1 = nhg1->nexthop, nh2 = nhg2->nexthop; nh1 || nh2;
|
||||||
nh1 = nh1->next, nh2 = nh2->next) {
|
nh1 = nh1->next, nh2 = nh2->next) {
|
||||||
if (!nexthop_same(nh1, nh2))
|
if (!nexthop_same(nh1, nh2))
|
||||||
return false;
|
return false;
|
||||||
@ -158,6 +158,30 @@ bool nexthop_group_equal(const struct nexthop_group *nhg1,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This assumes ordered */
|
||||||
|
bool nexthop_group_equal(const struct nexthop_group *nhg1,
|
||||||
|
const struct nexthop_group *nhg2)
|
||||||
|
{
|
||||||
|
struct nexthop *nh1 = NULL;
|
||||||
|
struct nexthop *nh2 = NULL;
|
||||||
|
|
||||||
|
if (nhg1 && !nhg2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!nhg1 && !nhg2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (nexthop_group_nexthop_num(nhg1) != nexthop_group_nexthop_num(nhg2))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (nh1 = nhg1->nexthop, nh2 = nhg2->nexthop; nh1 || nh2;
|
||||||
|
nh1 = nexthop_next(nh1), nh2 = nexthop_next(nh2)) {
|
||||||
|
if (!nexthop_same(nh1, nh2))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
struct nexthop_group *nexthop_group_new(void)
|
struct nexthop_group *nexthop_group_new(void)
|
||||||
{
|
{
|
||||||
return XCALLOC(MTYPE_NEXTHOP_GROUP, sizeof(struct nexthop_group));
|
return XCALLOC(MTYPE_NEXTHOP_GROUP, sizeof(struct nexthop_group));
|
||||||
|
@ -115,6 +115,11 @@ void nexthop_group_interface_state_change(struct interface *ifp,
|
|||||||
|
|
||||||
extern struct nexthop *nexthop_exists(const struct nexthop_group *nhg,
|
extern struct nexthop *nexthop_exists(const struct nexthop_group *nhg,
|
||||||
const struct nexthop *nh);
|
const struct nexthop *nh);
|
||||||
|
/* This assumes ordered */
|
||||||
|
extern bool nexthop_group_equal_no_recurse(const struct nexthop_group *nhg1,
|
||||||
|
const struct nexthop_group *nhg2);
|
||||||
|
|
||||||
|
/* This assumes ordered */
|
||||||
extern bool nexthop_group_equal(const struct nexthop_group *nhg1,
|
extern bool nexthop_group_equal(const struct nexthop_group *nhg1,
|
||||||
const struct nexthop_group *nhg2);
|
const struct nexthop_group *nhg2);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user