Skip to content

Commit

Permalink
esp: choose the correct inner protocol for GSO on inter address famil…
Browse files Browse the repository at this point in the history
…y tunnels

Commit 23c7f8d ("net: Fix esp GSO on inter address family
tunnels.") is incomplete. It passes to skb_eth_gso_segment the
protocol for the outer IP version, instead of the inner IP version, so
we end up calling inet_gso_segment on an inner IPv6 packet and
ipv6_gso_segment on an inner IPv4 packet and the packets are dropped.

This patch completes the fix by selecting the correct protocol based
on the inner mode's family.

Fixes: c35fe41 ("xfrm: Add mode handlers for IPsec on layer 2")
Signed-off-by: Sabrina Dubroca <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
  • Loading branch information
qsn authored and klassert committed Aug 29, 2022
1 parent ebe5555 commit 26dbd66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion net/ipv4/esp4_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ static struct sk_buff *xfrm4_tunnel_gso_segment(struct xfrm_state *x,
struct sk_buff *skb,
netdev_features_t features)
{
return skb_eth_gso_segment(skb, features, htons(ETH_P_IP));
__be16 type = x->inner_mode.family == AF_INET6 ? htons(ETH_P_IPV6)
: htons(ETH_P_IP);

return skb_eth_gso_segment(skb, features, type);
}

static struct sk_buff *xfrm4_transport_gso_segment(struct xfrm_state *x,
Expand Down
5 changes: 4 additions & 1 deletion net/ipv6/esp6_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ static struct sk_buff *xfrm6_tunnel_gso_segment(struct xfrm_state *x,
struct sk_buff *skb,
netdev_features_t features)
{
return skb_eth_gso_segment(skb, features, htons(ETH_P_IPV6));
__be16 type = x->inner_mode.family == AF_INET ? htons(ETH_P_IP)
: htons(ETH_P_IPV6);

return skb_eth_gso_segment(skb, features, type);
}

static struct sk_buff *xfrm6_transport_gso_segment(struct xfrm_state *x,
Expand Down

0 comments on commit 26dbd66

Please sign in to comment.