From f7c8bb133948bc538be0d55b004f028d926868cc Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Thu, 20 Feb 2025 11:02:19 +0100 Subject: [PATCH] zebra: Extend rt netlink encode functions to support encap behavior Previous commits introduced the encap_behavior field to the SRv6 nexthop, enabling the association of one of the encapsulation behaviors defined in RFC 8986 with an SRv6 nexthop. This commit extends Zebra rt netlink encoding functions by including the encapsulation behavior in the Netlink message sent to the kernel for nexthop installation. Signed-off-by: Carmine Scarpitta --- zebra/rt_netlink.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 477fbc455f..40209bd1f7 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1790,7 +1790,32 @@ static ssize_t fill_seg6ipt_encap(char *buffer, size_t buflen, memset(buffer, 0, buflen); ipt = (struct seg6_iptunnel_encap *)buffer; - ipt->mode = SEG6_IPTUN_MODE_ENCAP; + + /* + * Note: even if Zebra is capable of programming all the SRv6 + * Headend Behaviors defined in RFC 8986, FRR daemons support + * only a subset of them. + * Currently, STATIC currently supports H.Encaps and H.Encaps.Red. + * BGP supports only H.Encaps. + * Daemons need to be extended to support other behaviors. + */ + switch (segs->encap_behavior) { + case SRV6_HEADEND_BEHAVIOR_H_INSERT: + ipt->mode = SEG6_IPTUN_MODE_INLINE; + break; + case SRV6_HEADEND_BEHAVIOR_H_ENCAPS: + ipt->mode = SEG6_IPTUN_MODE_ENCAP; + break; + case SRV6_HEADEND_BEHAVIOR_H_ENCAPS_RED: + ipt->mode = SEG6_IPTUN_MODE_ENCAP_RED; + break; + case SRV6_HEADEND_BEHAVIOR_H_ENCAPS_L2: + ipt->mode = SEG6_IPTUN_MODE_L2ENCAP; + break; + case SRV6_HEADEND_BEHAVIOR_H_ENCAPS_L2_RED: + ipt->mode = SEG6_IPTUN_MODE_L2ENCAP_RED; + break; + } srh = (struct ipv6_sr_hdr *)&ipt->srh; srh->hdrlen = (srhlen >> 3) - 1; -- 2.39.5