Set skb->protocol properly before calling dst_output()
Subsystems (3)
PATCH 1/2 Set skb->protocol properly before calling dst_output()
When xfrm is applied to TSO/GSO packets, it follows this path:
xfrm_output() -> xfrm_output_gso() -> skb_gso_segment()
where skb_gso_segment() relies on skb->protocol to function properly.
This patch sets skb->protocol properly before dst_output() is called, fixing a bug where GSO packets sent through a sit or ipip6 tunnel are dropped when xfrm is involved.
--- net/ipv4/ip_output.c | 4 +++- net/ipv6/output_core.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
net/ipv4/ip_output.c +3 -1
@@ -117,8 +117,10 @@ int ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)int err; err =__ip_local_out (net, sk, skb); -if (likely (err ==1 )) +if (likely (err ==1 )) { + skb->protocol =htons (ETH_P_IP ); err =dst_output (net, sk, skb); + }return err; }
net/ipv6/output_core.c +3 -1
@@ -166,8 +166,10 @@ int ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)int err; err =__ip6_local_out (net, sk, skb); -if (likely (err ==1 )) +if (likely (err ==1 )) { + skb->protocol =htons (ETH_P_IPV6 ); err =dst_output (net, sk, skb); + }return err; }
Signature · 1 line
2.10.2
PATCH 2/2 Revert: "ip6_tunnel: Update skb->protocol to ETH_P_IPV6 in ip6_tnl_xmit()"
This reverts commit ae148b085876fa771d9ef2c05f85d4b4bf09ce0d ("ip6_tunnel: Update skb->protocol to ETH_P_IPV6 in ip6_tnl_xmit()").
skb->protocol is now set in ip_local_out() and ip6_local_out() right before dst_output() is called. It is no longer necessary to do it in each tunnel.
--- net/ipv6/ip6_tunnel.c | 1 - 1 file changed, 1 deletion(-)
net/ipv6/ip6_tunnel.c +0 -1
@@ -1181,7 +1181,6 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,if (err)return err; - skb->protocol =htons (ETH_P_IPV6 );skb_push (skb,sizeof (struct ipv6hdr ));skb_reset_network_header (skb); ipv6h =ipv6_hdr (skb);
Signature · 1 line
2.10.2
David Miller
maintainerFrom: Eli Cooper <[email protected]>
Date: Tue, 29 Nov 2016 10:35:28 +0800
Quoted 22 lines
When xfrm is applied to TSO/GSO packets, it follows this path:
xfrm_output() -> xfrm_output_gso() -> skb_gso_segment()where
skb_gso_segment()relies onskb->protocolto function properly.This patch sets
skb->protocolproperly beforedst_output()is called, fixing a bug where GSO packets sent through a sit or ipip6 tunnel are dropped when xfrm is involved.Signed-off-by Eli Cooper <[email protected]>--- net/ipv4/ip_output.c | 4 +++- net/ipv6/output_core.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)net/ipv4/ip_output.c +0
-0
net/ipv4/ip_output.c int ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb) · line 124
Quoted 9 lines
net/ipv4/ip_output.c +3
-1@@ -117,8 +117,10 @@ int ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)int err; err =__ip_local_out (net, sk, skb); -if (likely (err ==1 )) +if (likely (err ==1 )) { + skb->protocol =htons (ETH_P_IP ); err =dst_output (net, sk, skb); + }
__ip_local_out() potentially does a dst_output() call too via the netfilter hook, so you definitely need to place the skb->protocol assignment before that netfilter hook.