From b265d1981b6ba47211c47b193b7aa8ac2f12b587 Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Fri, 21 Feb 2025 13:38:15 +0100 Subject: [PATCH] lib: Add encap behavior to SRv6 nexthop This commit introduces the `encap_behavior` field to the SRv6 nexthop data structure and update the compare, hash, and copy functions to handle this new field. The `encap_behavior` field allows daemons to specify one of the encapsulation behaviors defined in RFC 8986 when installing an SRv6 nexthop in the RIB. Signed-off-by: Carmine Scarpitta --- lib/nexthop.c | 7 +++++++ lib/srv6.h | 1 + 2 files changed, 8 insertions(+) diff --git a/lib/nexthop.c b/lib/nexthop.c index c377b9cb00..7850827f4a 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -100,6 +100,12 @@ static int _nexthop_srv6_cmp(const struct nexthop *nh1, break; } + if (nh1->nh_srv6->seg6_segs->encap_behavior > nh2->nh_srv6->seg6_segs->encap_behavior) + return 1; + + if (nh1->nh_srv6->seg6_segs->encap_behavior < nh2->nh_srv6->seg6_segs->encap_behavior) + return -1; + return ret; } @@ -823,6 +829,7 @@ uint32_t nexthop_hash(const struct nexthop *nexthop) segs_num -= 1; i += 1; } + key = jhash_1word(nexthop->nh_srv6->seg6_segs->encap_behavior, key); } } } diff --git a/lib/srv6.h b/lib/srv6.h index b25241adfa..acc828e456 100644 --- a/lib/srv6.h +++ b/lib/srv6.h @@ -108,6 +108,7 @@ struct seg6local_flavors_info { }; struct seg6_seg_stack { + enum srv6_headend_behavior encap_behavior; uint8_t num_segs; struct in6_addr seg[0]; /* 1 or more segs */ }; -- 2.39.5