Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

seg6: add support for SRv6 H.L2Encaps.Red behavior

The SRv6 H.L2Encaps.Red behavior described in [1] is an optimization of
the SRv6 H.L2Encaps behavior [2].

H.L2Encaps.Red reduces the length of the SRH by excluding the first
segment (SID) in the SRH of the pushed IPv6 header. The first SID is
only placed in the IPv6 Destination Address field of the pushed IPv6
header.
When the SRv6 Policy only contains one SID the SRH is omitted, unless
there is an HMAC TLV to be carried.

[1] - https://datatracker.ietf.org/doc/html/rfc8986#section-5.4
[2] - https://datatracker.ietf.org/doc/html/rfc8986#section-5.3

Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
Signed-off-by: Anton Makarov <anton.makarov11235@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Andrea Mayer and committed by
David S. Miller
13f0296b b07c8cdb

+12 -1
+1
include/uapi/linux/seg6_iptunnel.h
··· 36 36 SEG6_IPTUN_MODE_ENCAP, 37 37 SEG6_IPTUN_MODE_L2ENCAP, 38 38 SEG6_IPTUN_MODE_ENCAP_RED, 39 + SEG6_IPTUN_MODE_L2ENCAP_RED, 39 40 }; 40 41 41 42 #endif
+11 -1
net/ipv6/seg6_iptunnel.c
··· 40 40 head = sizeof(struct ipv6hdr); 41 41 break; 42 42 case SEG6_IPTUN_MODE_L2ENCAP: 43 + case SEG6_IPTUN_MODE_L2ENCAP_RED: 43 44 return 0; 44 45 } 45 46 ··· 414 413 skb->protocol = htons(ETH_P_IPV6); 415 414 break; 416 415 case SEG6_IPTUN_MODE_L2ENCAP: 416 + case SEG6_IPTUN_MODE_L2ENCAP_RED: 417 417 if (!skb_mac_header_was_set(skb)) 418 418 return -EINVAL; 419 419 ··· 424 422 skb_mac_header_rebuild(skb); 425 423 skb_push(skb, skb->mac_len); 426 424 427 - err = seg6_do_srh_encap(skb, tinfo->srh, IPPROTO_ETHERNET); 425 + if (tinfo->mode == SEG6_IPTUN_MODE_L2ENCAP) 426 + err = seg6_do_srh_encap(skb, tinfo->srh, 427 + IPPROTO_ETHERNET); 428 + else 429 + err = seg6_do_srh_encap_red(skb, tinfo->srh, 430 + IPPROTO_ETHERNET); 431 + 428 432 if (err) 429 433 return err; 430 434 ··· 650 642 case SEG6_IPTUN_MODE_L2ENCAP: 651 643 break; 652 644 case SEG6_IPTUN_MODE_ENCAP_RED: 645 + break; 646 + case SEG6_IPTUN_MODE_L2ENCAP_RED: 653 647 break; 654 648 default: 655 649 return -EINVAL;