Skip to content

Commit

Permalink
seg6: add support for SRv6 H.L2Encaps.Red behavior
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
skorpion17 authored and davem330 committed Jul 29, 2022
1 parent b07c8cd commit 13f0296
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/uapi/linux/seg6_iptunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum {
SEG6_IPTUN_MODE_ENCAP,
SEG6_IPTUN_MODE_L2ENCAP,
SEG6_IPTUN_MODE_ENCAP_RED,
SEG6_IPTUN_MODE_L2ENCAP_RED,
};

#endif
12 changes: 11 additions & 1 deletion net/ipv6/seg6_iptunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static size_t seg6_lwt_headroom(struct seg6_iptunnel_encap *tuninfo)
head = sizeof(struct ipv6hdr);
break;
case SEG6_IPTUN_MODE_L2ENCAP:
case SEG6_IPTUN_MODE_L2ENCAP_RED:
return 0;
}

Expand Down Expand Up @@ -413,6 +414,7 @@ static int seg6_do_srh(struct sk_buff *skb)
skb->protocol = htons(ETH_P_IPV6);
break;
case SEG6_IPTUN_MODE_L2ENCAP:
case SEG6_IPTUN_MODE_L2ENCAP_RED:
if (!skb_mac_header_was_set(skb))
return -EINVAL;

Expand All @@ -422,7 +424,13 @@ static int seg6_do_srh(struct sk_buff *skb)
skb_mac_header_rebuild(skb);
skb_push(skb, skb->mac_len);

err = seg6_do_srh_encap(skb, tinfo->srh, IPPROTO_ETHERNET);
if (tinfo->mode == SEG6_IPTUN_MODE_L2ENCAP)
err = seg6_do_srh_encap(skb, tinfo->srh,
IPPROTO_ETHERNET);
else
err = seg6_do_srh_encap_red(skb, tinfo->srh,
IPPROTO_ETHERNET);

if (err)
return err;

Expand Down Expand Up @@ -643,6 +651,8 @@ static int seg6_build_state(struct net *net, struct nlattr *nla,
break;
case SEG6_IPTUN_MODE_ENCAP_RED:
break;
case SEG6_IPTUN_MODE_L2ENCAP_RED:
break;
default:
return -EINVAL;
}
Expand Down

0 comments on commit 13f0296

Please sign in to comment.