netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] tun: fix csum generation for tap devices
@ 2016-06-13 22:00 Paolo Abeni
  2016-06-14  5:31 ` Mike Rapoport
  2016-06-15 21:00 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Abeni @ 2016-06-13 22:00 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Michael S. Tsirkin, Mike Rapoport,
	Hannes Frederic Sowa

The commit 34166093639b ("tuntap: use common code for virtio_net_hdr
and skb GSO conversion") replaced the tun code for header manipulation
with the generic helpers. While doing so, it implictly moved the
skb_partial_csum_set() invocation after eth_type_trans(), which
invalidate the current gso start/offset values.
Fix it by moving the helper invocation before the mac pulling.

Fixes: 34166093639 ("tuntap: use common code for virtio_net_hdr and skb GSO conversion")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/tun.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 8cc6bf4..4884802 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1254,6 +1254,13 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 		return -EFAULT;
 	}
 
+	err = virtio_net_hdr_to_skb(skb, &gso, tun_is_little_endian(tun));
+	if (err) {
+		this_cpu_inc(tun->pcpu_stats->rx_frame_errors);
+		kfree_skb(skb);
+		return -EINVAL;
+	}
+
 	switch (tun->flags & TUN_TYPE_MASK) {
 	case IFF_TUN:
 		if (tun->flags & IFF_NO_PI) {
@@ -1280,13 +1287,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 		break;
 	}
 
-	err = virtio_net_hdr_to_skb(skb, &gso, tun_is_little_endian(tun));
-	if (err) {
-		this_cpu_inc(tun->pcpu_stats->rx_frame_errors);
-		kfree_skb(skb);
-		return -EINVAL;
-	}
-
 	/* copy skb_ubuf_info for callback when skb has no error */
 	if (zerocopy) {
 		skb_shinfo(skb)->destructor_arg = msg_control;
-- 
1.8.3.1

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

* Re: [PATCH net-next] tun: fix csum generation for tap devices
  2016-06-13 22:00 [PATCH net-next] tun: fix csum generation for tap devices Paolo Abeni
@ 2016-06-14  5:31 ` Mike Rapoport
  2016-06-15 21:00 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Rapoport @ 2016-06-14  5:31 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: netdev, David S. Miller, Michael S. Tsirkin, Hannes Frederic Sowa

On Tue, Jun 14, 2016 at 12:00:04AM +0200, Paolo Abeni wrote:
> The commit 34166093639b ("tuntap: use common code for virtio_net_hdr
> and skb GSO conversion") replaced the tun code for header manipulation
> with the generic helpers. While doing so, it implictly moved the
> skb_partial_csum_set() invocation after eth_type_trans(), which
> invalidate the current gso start/offset values.
> Fix it by moving the helper invocation before the mac pulling.
> 
> Fixes: 34166093639 ("tuntap: use common code for virtio_net_hdr and skb GSO conversion")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>

> ---
>  drivers/net/tun.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 8cc6bf4..4884802 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1254,6 +1254,13 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
>  		return -EFAULT;
>  	}
> 
> +	err = virtio_net_hdr_to_skb(skb, &gso, tun_is_little_endian(tun));
> +	if (err) {
> +		this_cpu_inc(tun->pcpu_stats->rx_frame_errors);
> +		kfree_skb(skb);
> +		return -EINVAL;
> +	}
> +
>  	switch (tun->flags & TUN_TYPE_MASK) {
>  	case IFF_TUN:
>  		if (tun->flags & IFF_NO_PI) {
> @@ -1280,13 +1287,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
>  		break;
>  	}
> 
> -	err = virtio_net_hdr_to_skb(skb, &gso, tun_is_little_endian(tun));
> -	if (err) {
> -		this_cpu_inc(tun->pcpu_stats->rx_frame_errors);
> -		kfree_skb(skb);
> -		return -EINVAL;
> -	}
> -
>  	/* copy skb_ubuf_info for callback when skb has no error */
>  	if (zerocopy) {
>  		skb_shinfo(skb)->destructor_arg = msg_control;
> -- 
> 1.8.3.1
> 

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

* Re: [PATCH net-next] tun: fix csum generation for tap devices
  2016-06-13 22:00 [PATCH net-next] tun: fix csum generation for tap devices Paolo Abeni
  2016-06-14  5:31 ` Mike Rapoport
@ 2016-06-15 21:00 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-06-15 21:00 UTC (permalink / raw)
  To: pabeni; +Cc: netdev, mst, rppt, hannes

From: Paolo Abeni <pabeni@redhat.com>
Date: Tue, 14 Jun 2016 00:00:04 +0200

> The commit 34166093639b ("tuntap: use common code for virtio_net_hdr
> and skb GSO conversion") replaced the tun code for header manipulation
> with the generic helpers. While doing so, it implictly moved the
> skb_partial_csum_set() invocation after eth_type_trans(), which
> invalidate the current gso start/offset values.
> Fix it by moving the helper invocation before the mac pulling.
> 
> Fixes: 34166093639 ("tuntap: use common code for virtio_net_hdr and skb GSO conversion")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Applied.

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

end of thread, other threads:[~2016-06-15 21:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-13 22:00 [PATCH net-next] tun: fix csum generation for tap devices Paolo Abeni
2016-06-14  5:31 ` Mike Rapoport
2016-06-15 21:00 ` David Miller

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).