]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Extend rt netlink encode functions to support encap behavior
authorCarmine Scarpitta <cscarpit@cisco.com>
Thu, 20 Feb 2025 10:02:19 +0000 (11:02 +0100)
committerCarmine Scarpitta <cscarpit@cisco.com>
Wed, 30 Apr 2025 15:51:25 +0000 (15:51 +0000)
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 <cscarpit@cisco.com>
zebra/rt_netlink.c

index 477fbc455fa167164d59e7c1c03ad60a286e141c..40209bd1f78f3665f3bfb4f02b4877ab7d7bdce2 100644 (file)
@@ -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;