mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 11:20:51 +00:00
lib: adapt nexthop_cmp to handle multiple segs SIDs
Extend nexthop_cmp function to process multiple segs SIDs. Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
This commit is contained in:
parent
857945ad1a
commit
74fb8a2d18
@ -56,6 +56,7 @@ static int _nexthop_srv6_cmp(const struct nexthop *nh1,
|
||||
const struct nexthop *nh2)
|
||||
{
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
|
||||
if (!nh1->nh_srv6 && !nh2->nh_srv6)
|
||||
return 0;
|
||||
@ -78,9 +79,26 @@ static int _nexthop_srv6_cmp(const struct nexthop *nh1,
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = memcmp(&nh1->nh_srv6->seg6_segs,
|
||||
&nh2->nh_srv6->seg6_segs,
|
||||
sizeof(struct in6_addr));
|
||||
if (!nh1->nh_srv6->seg6_segs && !nh2->nh_srv6->seg6_segs)
|
||||
return 0;
|
||||
|
||||
if (!nh1->nh_srv6->seg6_segs && nh2->nh_srv6->seg6_segs)
|
||||
return -1;
|
||||
|
||||
if (nh1->nh_srv6->seg6_segs && !nh2->nh_srv6->seg6_segs)
|
||||
return 1;
|
||||
|
||||
if (nh1->nh_srv6->seg6_segs->num_segs !=
|
||||
nh2->nh_srv6->seg6_segs->num_segs)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < nh1->nh_srv6->seg6_segs->num_segs; i++) {
|
||||
ret = memcmp(&nh1->nh_srv6->seg6_segs->seg[i],
|
||||
&nh2->nh_srv6->seg6_segs->seg[i],
|
||||
sizeof(struct in6_addr));
|
||||
if (ret != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user