All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 1/2] Set skb->protocol properly before calling dst_output()
@ 2016-11-29  2:35 Eli Cooper
  2016-11-29  2:35 ` [PATCH net 2/2] Revert: "ip6_tunnel: Update skb->protocol to ETH_P_IPV6 in ip6_tnl_xmit()" Eli Cooper
  2016-11-30 17:38 ` [PATCH net 1/2] Set skb->protocol properly before calling dst_output() David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Eli Cooper @ 2016-11-29  2:35 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Eric Dumazet

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.

Cc: stable@vger.kernel.org
Signed-off-by: Eli Cooper <elicooper@gmx.com>
---
 net/ipv4/ip_output.c   | 4 +++-
 net/ipv6/output_core.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 105908d..0180e44 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -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;
 }
diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
index 7cca8ac..d6e850d 100644
--- a/net/ipv6/output_core.c
+++ b/net/ipv6/output_core.c
@@ -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;
 }
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH net 2/2] Revert: "ip6_tunnel: Update skb->protocol to ETH_P_IPV6 in ip6_tnl_xmit()"
  2016-11-29  2:35 [PATCH net 1/2] Set skb->protocol properly before calling dst_output() Eli Cooper
@ 2016-11-29  2:35 ` Eli Cooper
  2016-11-30 17:38 ` [PATCH net 1/2] Set skb->protocol properly before calling dst_output() David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Eli Cooper @ 2016-11-29  2:35 UTC (permalink / raw)
  To: netdev, David S . Miller; +Cc: Eric Dumazet

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.

Cc: stable@vger.kernel.org
Signed-off-by: Eli Cooper <elicooper@gmx.com>
---
 net/ipv6/ip6_tunnel.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 0a4759b..d76674e 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -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);
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net 1/2] Set skb->protocol properly before calling dst_output()
  2016-11-29  2:35 [PATCH net 1/2] Set skb->protocol properly before calling dst_output() Eli Cooper
  2016-11-29  2:35 ` [PATCH net 2/2] Revert: "ip6_tunnel: Update skb->protocol to ETH_P_IPV6 in ip6_tnl_xmit()" Eli Cooper
@ 2016-11-30 17:38 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-11-30 17:38 UTC (permalink / raw)
  To: elicooper; +Cc: netdev, eric.dumazet

From: Eli Cooper <elicooper@gmx.com>
Date: Tue, 29 Nov 2016 10:35:28 +0800

> 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.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Eli Cooper <elicooper@gmx.com>
> ---
>  net/ipv4/ip_output.c   | 4 +++-
>  net/ipv6/output_core.c | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
> index 105908d..0180e44 100644
> --- a/net/ipv4/ip_output.c
> +++ b/net/ipv4/ip_output.c
> @@ -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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-30 17:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-29  2:35 [PATCH net 1/2] Set skb->protocol properly before calling dst_output() Eli Cooper
2016-11-29  2:35 ` [PATCH net 2/2] Revert: "ip6_tunnel: Update skb->protocol to ETH_P_IPV6 in ip6_tnl_xmit()" Eli Cooper
2016-11-30 17:38 ` [PATCH net 1/2] Set skb->protocol properly before calling dst_output() David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.