netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: weichunc@plumgrid.com
Cc: eric.dumazet@gmail.com, ast@plumgrid.com, netdev@vger.kernel.org,
	joseph.gasparakis@intel.com, or.gerlitz@gmail.com
Subject: Re: [PATCH net-next] ipv4: fix tunneled VM traffic over hw VXLAN/GRE GSO NIC
Date: Thu, 26 Dec 2013 13:10:59 -0500 (EST)	[thread overview]
Message-ID: <20131226.131059.774046353564501606.davem@davemloft.net> (raw)
In-Reply-To: <1387393368-1028-1-git-send-email-weichunc@plumgrid.com>

From: Wei-Chun Chao <weichunc@plumgrid.com>
Date: Wed, 18 Dec 2013 11:02:48 -0800

> This is also seen on 'net'.
> 
> VM to VM GSO traffic is broken if it goes through VXLAN or GRE
> tunnel and the physical NIC on the host supports hardware VXLAN/GRE
> GSO offload (e.g. bnx2x and next-gen mlx4).
> 
> Two issues -
> (VXLAN) VM traffic has SKB_GSO_DODGY and SKB_GSO_UDP_TUNNEL with
> SKB_GSO_TCP/UDP set depending on the inner protocol. GSO header
> integrity check fails in udp4_ufo_fragment if inner protocol is
> TCP. Also gso_segs is calculated incorrectly using skb->len that
> includes tunnel header. Fix: robust check should only be applied
> to the inner packet.
> 
> (VXLAN & GRE) Once GSO header integrity check passes, NULL segs
> is returned and the original skb is sent to hardware. However the
> tunnel header is already pulled. Fix: tunnel header needs to be
> restored so that hardware can perform GSO properly on the original
> packet.
> 
> Signed-off-by: Wei-Chun Chao <weichunc@plumgrid.com>

I'd like to see some changes to this patch:

> @@ -73,7 +74,19 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
>  	/* segment inner packet. */
>  	enc_features = skb->dev->hw_enc_features & netif_skb_features(skb);
>  	segs = skb_mac_gso_segment(skb, enc_features);
> -	if (!segs || IS_ERR(segs))
> +	/* Verifying header integrity only. */
> +	if (!segs) {
> +		skb->protocol = protocol;
> +		skb->encapsulation = 1;
> +		skb_push(skb, ghl);
> +		skb_reset_transport_header(skb);
> +		skb->mac_header = mac_offset;
> +		skb->network_header = skb->mac_header + mac_len;
> +		skb->mac_len = mac_len;
> +		goto out;
> +	}
> +
> +	if (IS_ERR(segs))
>  		goto out;
>  
>  	skb = segs;
 ...
> @@ -2493,7 +2494,19 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
>  	/* segment inner packet. */
>  	enc_features = skb->dev->hw_enc_features & netif_skb_features(skb);
>  	segs = skb_mac_gso_segment(skb, enc_features);
> -	if (!segs || IS_ERR(segs))
> +	/* Verifying header integrity only. */
> +	if (!segs) {
> +		skb->encapsulation = 1;
> +		skb_push(skb, tnl_hlen);
> +		skb_reset_transport_header(skb);
> +		skb->mac_header = mac_offset;
> +		skb->network_header = skb->mac_header + mac_len;
> +		skb->mac_len = mac_len;
> +		skb->protocol = protocol;
> +		goto out;
> +	}
> +

These two code blocks are identical, please make a helper function that
does something like:

static inline void skb_gso_error_unwind(struct sk_buff *skb, __be16 protocol,
					int pulled_hlen, u16 mac_offset, int mac_len)
{
	skb->protocol = protocol;
	skb->encapsulation = 1;
	skb_push(skb, pulled_hlen);
	skb_reset_transport_header(skb);
	skb->mac_header = mac_offset;
	skb->network_header = skb->mac_header + mac_len;
	skb->mac_len = mac_len;
}

And call it from the two spots above.

Secondly, in gre_gso_segment(), we clear skb->encapsulation and set the
skb->protocol too early, for if:

	if (unlikely(!pskb_may_pull(skb, ghl)))
		goto out;

fails, we will not unwind those changes.  I'd suggest simply moving the:

	skb->protocol = greh->protocol;
	skb->encapsulation = 0;

after the pskb_may_pull() check.  That way this function will leave the
skb unmodified if the pskb_may_pull() fails.

skb_udp_tunnel_segment() already gets this right.

I'd like to apply this to 'net' so please make your patch against that
tree, thanks.

      parent reply	other threads:[~2013-12-26 18:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18 19:02 [PATCH net-next] ipv4: fix tunneled VM traffic over hw VXLAN/GRE GSO NIC Wei-Chun Chao
2013-12-19  0:35 ` Stephen Hemminger
2013-12-19  1:51   ` Wei-Chun Chao
2013-12-19  2:05     ` Stephen Hemminger
2013-12-19  6:20       ` Or Gerlitz
2013-12-22 13:25 ` Or Gerlitz
2013-12-26 18:10 ` David Miller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131226.131059.774046353564501606.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=ast@plumgrid.com \
    --cc=eric.dumazet@gmail.com \
    --cc=joseph.gasparakis@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=or.gerlitz@gmail.com \
    --cc=weichunc@plumgrid.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).