diff options
author | Dmytro Shytyi <dmytro.shytyi@6wind.com> | 2023-07-27 11:40:22 +0200 |
---|---|---|
committer | Dmytro Shytyi <dmytro.shytyi@6wind.com> | 2023-09-20 15:07:15 +0200 |
commit | 74fb8a2d18ae496bf2c911fd23aadddaa4507d84 (patch) | |
tree | 97e01755b637d0a30b561073ecaec2e1adb059a6 | |
parent | lib: update del_srv6_seg6_local to handle seg6_segs (diff) | |
download | frr-74fb8a2d18ae496bf2c911fd23aadddaa4507d84.tar.xz frr-74fb8a2d18ae496bf2c911fd23aadddaa4507d84.zip |
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>
-rw-r--r-- | lib/nexthop.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c index e19c1d680..8df57e36a 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -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; } |