All of lore.kernel.org
 help / color / mirror / Atom feed
* tun: Optimise handling of bogus gso->hdr_len
@ 2009-06-04 11:06 Herbert Xu
  2009-06-04 11:22 ` net: Ensure partial checksum offset is inside the skb head Herbert Xu
  2009-06-08  7:22 ` tun: Optimise handling of bogus gso->hdr_len David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Herbert Xu @ 2009-06-04 11:06 UTC (permalink / raw)
  To: David S. Miller, netdev

Hi:

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>

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 735bf41..00d00ad 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -563,6 +563,10 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun,
 		if (memcpy_fromiovec((void *)&gso, iv, 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;
 	}

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2009-06-08  7:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-04 11:06 tun: Optimise handling of bogus gso->hdr_len Herbert Xu
2009-06-04 11:22 ` net: Ensure partial checksum offset is inside the skb head Herbert Xu
2009-06-05  4:22   ` Rusty Russell
2009-06-08  7:23   ` David Miller
2009-06-08  7:22 ` tun: Optimise handling of bogus gso->hdr_len 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.