Skip to content

Commit 68dc022

Browse files
lxinklassert
authored andcommitted
xfrm: BEET mode doesn't support fragments for inner packets
BEET mode replaces the IP(6) Headers with new IP(6) Headers when sending packets. However, when it's a fragment before the replacement, currently kernel keeps the fragment flag and replace the address field then encaps it with ESP. It would cause in RX side the fragments to get reassembled before decapping with ESP, which is incorrect. In Xiumei's testing, these fragments went over an xfrm interface and got encapped with ESP in the device driver, and the traffic was broken. I don't have a good way to fix it, but only to warn this out in dmesg. Reported-by: Xiumei Mu <[email protected]> Signed-off-by: Xin Long <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 154deab commit 68dc022

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

net/xfrm/xfrm_output.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,12 @@ static int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb)
660660
{
661661
int err;
662662

663+
if (x->outer_mode.encap == XFRM_MODE_BEET &&
664+
ip_is_fragment(ip_hdr(skb))) {
665+
net_warn_ratelimited("BEET mode doesn't support inner IPv4 fragments\n");
666+
return -EAFNOSUPPORT;
667+
}
668+
663669
err = xfrm4_tunnel_check_size(skb);
664670
if (err)
665671
return err;
@@ -705,8 +711,15 @@ static int xfrm6_tunnel_check_size(struct sk_buff *skb)
705711
static int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb)
706712
{
707713
#if IS_ENABLED(CONFIG_IPV6)
714+
unsigned int ptr = 0;
708715
int err;
709716

717+
if (x->outer_mode.encap == XFRM_MODE_BEET &&
718+
ipv6_find_hdr(skb, &ptr, NEXTHDR_FRAGMENT, NULL, NULL) >= 0) {
719+
net_warn_ratelimited("BEET mode doesn't support inner IPv6 fragments\n");
720+
return -EAFNOSUPPORT;
721+
}
722+
710723
err = xfrm6_tunnel_check_size(skb);
711724
if (err)
712725
return err;

0 commit comments

Comments
 (0)