summaryrefslogtreecommitdiff
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-06-08 00:20:01 -0700
committerDavid S. Miller <davem@davemloft.net>2009-06-08 00:20:01 -0700
commit4909122fb8350e70c347f1201256908a92058044 (patch)
treece87843cec44a1671bacff61b2c4fd25960efa6a /drivers/net/tun.c
parentb82f08ea162edeee6c2c70c6c4321bea4763fa35 (diff)
downloadlinux-3.10-4909122fb8350e70c347f1201256908a92058044.tar.gz
linux-3.10-4909122fb8350e70c347f1201256908a92058044.tar.bz2
linux-3.10-4909122fb8350e70c347f1201256908a92058044.zip
tun: Optimise handling of bogus gso->hdr_len
As all current versions of virtio_net generate a value for the header length that's too small, we should optimise this so that we don't copy it twice. This can be done by ensuring that it is at least as large as the place where we'll write the checksum. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 3f0cdc14be8..8d82511aa1b 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -565,6 +565,10 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun,
if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))
return -EFAULT;
+ if ((gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
+ gso.csum_start + gso.csum_offset + 2 > gso.hdr_len)
+ gso.hdr_len = gso.csum_start + gso.csum_offset + 2;
+
if (gso.hdr_len > len)
return -EINVAL;
offset += sizeof(pi);