* [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-25 14:30 ` [PATCH 3/4] tun: Allow GSO using virtio_net_hdr Rusty Russell
@ 2008-06-25 14:32 ` Rusty Russell
2008-06-25 19:07 ` Anthony Liguori
2008-06-25 19:07 ` Anthony Liguori
2008-06-25 14:32 ` Rusty Russell
` (5 subsequent siblings)
6 siblings, 2 replies; 34+ messages in thread
From: Rusty Russell @ 2008-06-25 14:32 UTC (permalink / raw)
To: Max Krasnyansky; +Cc: markmc, netdev, Herbert Xu, virtualization
(Might not apply cleanly to current Linus, there are other lguest things
going on, but this gives you the idea at least).
Guest -> Host 1GB TCP:
Before: Seconds 16.6282 xmit 250498 recv 3 timeout 248355
After: Seconds 9.86102 xmit 241989 recv 192014 timeout 231224
Host -> Guest 1GB TCP:
Before: Seconds 11.0831 xmit 324742 recv 1910 timeout 323429
After: Seconds 10.6626 xmit 342489 recv 24 timeout 341173
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
Documentation/lguest/lguest.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff -r 7358caf10bd8 Documentation/lguest/lguest.c
--- a/Documentation/lguest/lguest.c Tue Jun 24 16:15:36 2008 +1000
+++ b/Documentation/lguest/lguest.c Wed Jun 25 00:29:31 2008 +1000
@@ -928,11 +928,9 @@ static void handle_net_output(int fd, st
while ((head = get_vq_desc(vq, iov, &out, &in)) != vq->vring.num) {
if (in)
errx(1, "Input buffers in output queue?");
- /* Check header, but otherwise ignore it (we told the Guest we
- * supported no features, so it shouldn't have anything
- * interesting). */
- (void)convert(&iov[0], struct virtio_net_hdr);
- len = writev(vq->dev->fd, iov+1, out-1);
+ len = writev(vq->dev->fd, iov, out);
+ if (len < 0)
+ err(1, "Writing network packet to tun");
add_used_and_trigger(fd, vq, head, len);
num++;
}
@@ -949,7 +947,6 @@ static bool handle_tun_input(int fd, str
unsigned int head, in_num, out_num;
int len;
struct iovec iov[dev->vq->vring.num];
- struct virtio_net_hdr *hdr;
/* First we need a network buffer from the Guests's recv virtqueue. */
head = get_vq_desc(dev->vq, iov, &out_num, &in_num);
@@ -970,18 +969,13 @@ static bool handle_tun_input(int fd, str
} else if (out_num)
errx(1, "Output buffers in network recv queue?");
- /* First element is the header: we set it to 0 (no features). */
- hdr = convert(&iov[0], struct virtio_net_hdr);
- hdr->flags = 0;
- hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
-
/* Read the packet from the device directly into the Guest's buffer. */
- len = readv(dev->fd, iov+1, in_num-1);
+ len = readv(dev->fd, iov, in_num);
if (len <= 0)
err(1, "reading network");
/* Tell the Guest about the new packet. */
- add_used_and_trigger(fd, dev->vq, head, sizeof(*hdr) + len);
+ add_used_and_trigger(fd, dev->vq, head, len);
verbose("tun input packet len %i [%02x %02x] (%s)\n", len,
((u8 *)iov[1].iov_base)[0], ((u8 *)iov[1].iov_base)[1],
@@ -1492,10 +1486,14 @@ static int get_tun_device(char tapif[IFN
* the truth, I completely blundered my way through this code, but it
* works now! */
netfd = open_or_die("/dev/net/tun", O_RDWR);
- ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
+ ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_VNET_HDR;
strcpy(ifr.ifr_name, "tap%d");
if (ioctl(netfd, TUNSETIFF, &ifr) != 0)
err(1, "configuring /dev/net/tun");
+
+ if (ioctl(netfd, TUNSETFEATURES,
+ TUN_F_CSUM|TUN_F_TSO4|TUN_F_TSO6|TUN_F_TSO_ECN) != 0)
+ err(1, "Could not set features for tun device");
/* We don't need checksums calculated for packets coming in this
* device: trust us! */
@@ -1563,6 +1561,16 @@ static void setup_tun_net(char *arg)
/* Tell Guest what MAC address to use. */
add_feature(dev, VIRTIO_NET_F_MAC);
add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
+ /* Expect Guest to handle everything except UFO */
+ add_feature(dev, VIRTIO_NET_F_CSUM);
+ add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
+ add_feature(dev, VIRTIO_NET_F_MAC);
+ add_feature(dev, VIRTIO_NET_F_GUEST_TSO4);
+ add_feature(dev, VIRTIO_NET_F_GUEST_TSO6);
+ add_feature(dev, VIRTIO_NET_F_GUEST_ECN);
+ add_feature(dev, VIRTIO_NET_F_HOST_TSO4);
+ add_feature(dev, VIRTIO_NET_F_HOST_TSO6);
+ add_feature(dev, VIRTIO_NET_F_HOST_ECN);
set_config(dev, sizeof(conf), &conf);
/* We don't need the socket any more; setup is done. */
^ permalink raw reply [flat|nested] 34+ messages in thread* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-25 14:32 ` [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap Rusty Russell
@ 2008-06-25 19:07 ` Anthony Liguori
2008-06-25 19:07 ` Anthony Liguori
1 sibling, 0 replies; 34+ messages in thread
From: Anthony Liguori @ 2008-06-25 19:07 UTC (permalink / raw)
To: Rusty Russell; +Cc: markmc, virtualization, Herbert Xu, Max Krasnyansky, netdev
Rusty Russell wrote:
> @@ -1563,6 +1561,16 @@ static void setup_tun_net(char *arg)
> /* Tell Guest what MAC address to use. */
> add_feature(dev, VIRTIO_NET_F_MAC);
> add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
> + /* Expect Guest to handle everything except UFO */
> + add_feature(dev, VIRTIO_NET_F_CSUM);
You're setting this feature twice.
> + add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
You set this feature, but I never see the virtio-net driver acknowledge
the feature. Curiously, my implementation with KVM is struggling
because UDP packet checksums are not correct so the DHCP client is
ignoring them. If I disable CSUM offload, things it works fine (using
the virtio-net header). The problem is only host=>guest, guest=>host is
fine.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-25 14:32 ` [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap Rusty Russell
2008-06-25 19:07 ` Anthony Liguori
@ 2008-06-25 19:07 ` Anthony Liguori
2008-06-26 4:40 ` Rusty Russell
2008-06-26 4:40 ` Rusty Russell
1 sibling, 2 replies; 34+ messages in thread
From: Anthony Liguori @ 2008-06-25 19:07 UTC (permalink / raw)
To: Rusty Russell; +Cc: Max Krasnyansky, markmc, netdev, Herbert Xu, virtualization
Rusty Russell wrote:
> @@ -1563,6 +1561,16 @@ static void setup_tun_net(char *arg)
> /* Tell Guest what MAC address to use. */
> add_feature(dev, VIRTIO_NET_F_MAC);
> add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
> + /* Expect Guest to handle everything except UFO */
> + add_feature(dev, VIRTIO_NET_F_CSUM);
You're setting this feature twice.
> + add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
You set this feature, but I never see the virtio-net driver acknowledge
the feature. Curiously, my implementation with KVM is struggling
because UDP packet checksums are not correct so the DHCP client is
ignoring them. If I disable CSUM offload, things it works fine (using
the virtio-net header). The problem is only host=>guest, guest=>host is
fine.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-25 19:07 ` Anthony Liguori
@ 2008-06-26 4:40 ` Rusty Russell
2008-06-26 4:40 ` Rusty Russell
1 sibling, 0 replies; 34+ messages in thread
From: Rusty Russell @ 2008-06-26 4:40 UTC (permalink / raw)
To: Anthony Liguori
Cc: markmc, virtualization, Herbert Xu, Max Krasnyansky, netdev
On Thursday 26 June 2008 05:07:18 Anthony Liguori wrote:
> Rusty Russell wrote:
> > @@ -1563,6 +1561,16 @@ static void setup_tun_net(char *arg)
> > /* Tell Guest what MAC address to use. */
> > add_feature(dev, VIRTIO_NET_F_MAC);
> > add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
> > + /* Expect Guest to handle everything except UFO */
> > + add_feature(dev, VIRTIO_NET_F_CSUM);
>
> You're setting this feature twice.
Hmm, not in the version here?
> > + add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
>
> You set this feature, but I never see the virtio-net driver acknowledge
> the feature. Curiously, my implementation with KVM is struggling
> because UDP packet checksums are not correct so the DHCP client is
> ignoring them. If I disable CSUM offload, things it works fine (using
> the virtio-net header). The problem is only host=>guest, guest=>host is
> fine.
OK, found this: wrong args to skb_partial_csum_set. It was found by Mark
McLoughlin before, I just lost the fix when I extracted this into a separate
patch. I chose to move the call to skb_partial_csum_set(), rather than use
his fix (which assumed a tap not tun device).
Here's two fixes on top of previous patch:
diff -u b/drivers/net/tun.c b/drivers/net/tun.c
--- b/drivers/net/tun.c Thu Jun 26 00:21:59 2008 +1000
+++ b/drivers/net/tun.c Thu Jun 26 14:35:03 2008 +1000
@@ -298,11 +298,11 @@
if ((len -= sizeof(gso)) > count)
return -EINVAL;
- if (gso.hdr_len > len)
- return -EINVAL;
-
if (memcpy_fromiovec((void *)&gso, iv, sizeof(gso)))
return -EFAULT;
+
+ if (gso.hdr_len > len)
+ return -EINVAL;
}
if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) {
@@ -324,6 +324,16 @@
return -EFAULT;
}
+ if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
+ if (!skb_partial_csum_set(skb, gso.csum_start,
+ gso.csum_offset)) {
+ tun->dev->stats.rx_dropped++;
+ kfree_skb(skb);
+ return -EINVAL;
+ }
+ } else if (tun->flags & TUN_NOCHECKSUM)
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+
switch (tun->flags & TUN_TYPE_MASK) {
case TUN_TUN_DEV:
skb_reset_mac_header(skb);
@@ -335,16 +345,6 @@
break;
};
- if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
- if (!skb_partial_csum_set(skb, gso.csum_start,
- gso.csum_offset)) {
- tun->dev->stats.rx_dropped++;
- kfree_skb(skb);
- return -EINVAL;
- }
- } else if (tun->flags & TUN_NOCHECKSUM)
- skb->ip_summed = CHECKSUM_UNNECESSARY;
-
if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
pr_debug("GSO!\n");
switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
^ permalink raw reply [flat|nested] 34+ messages in thread* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-25 19:07 ` Anthony Liguori
2008-06-26 4:40 ` Rusty Russell
@ 2008-06-26 4:40 ` Rusty Russell
2008-06-26 18:16 ` Anthony Liguori
` (3 more replies)
1 sibling, 4 replies; 34+ messages in thread
From: Rusty Russell @ 2008-06-26 4:40 UTC (permalink / raw)
To: Anthony Liguori
Cc: Max Krasnyansky, markmc, netdev, Herbert Xu, virtualization
On Thursday 26 June 2008 05:07:18 Anthony Liguori wrote:
> Rusty Russell wrote:
> > @@ -1563,6 +1561,16 @@ static void setup_tun_net(char *arg)
> > /* Tell Guest what MAC address to use. */
> > add_feature(dev, VIRTIO_NET_F_MAC);
> > add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
> > + /* Expect Guest to handle everything except UFO */
> > + add_feature(dev, VIRTIO_NET_F_CSUM);
>
> You're setting this feature twice.
Hmm, not in the version here?
> > + add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
>
> You set this feature, but I never see the virtio-net driver acknowledge
> the feature. Curiously, my implementation with KVM is struggling
> because UDP packet checksums are not correct so the DHCP client is
> ignoring them. If I disable CSUM offload, things it works fine (using
> the virtio-net header). The problem is only host=>guest, guest=>host is
> fine.
OK, found this: wrong args to skb_partial_csum_set. It was found by Mark
McLoughlin before, I just lost the fix when I extracted this into a separate
patch. I chose to move the call to skb_partial_csum_set(), rather than use
his fix (which assumed a tap not tun device).
Here's two fixes on top of previous patch:
diff -u b/drivers/net/tun.c b/drivers/net/tun.c
--- b/drivers/net/tun.c Thu Jun 26 00:21:59 2008 +1000
+++ b/drivers/net/tun.c Thu Jun 26 14:35:03 2008 +1000
@@ -298,11 +298,11 @@
if ((len -= sizeof(gso)) > count)
return -EINVAL;
- if (gso.hdr_len > len)
- return -EINVAL;
-
if (memcpy_fromiovec((void *)&gso, iv, sizeof(gso)))
return -EFAULT;
+
+ if (gso.hdr_len > len)
+ return -EINVAL;
}
if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) {
@@ -324,6 +324,16 @@
return -EFAULT;
}
+ if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
+ if (!skb_partial_csum_set(skb, gso.csum_start,
+ gso.csum_offset)) {
+ tun->dev->stats.rx_dropped++;
+ kfree_skb(skb);
+ return -EINVAL;
+ }
+ } else if (tun->flags & TUN_NOCHECKSUM)
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+
switch (tun->flags & TUN_TYPE_MASK) {
case TUN_TUN_DEV:
skb_reset_mac_header(skb);
@@ -335,16 +345,6 @@
break;
};
- if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
- if (!skb_partial_csum_set(skb, gso.csum_start,
- gso.csum_offset)) {
- tun->dev->stats.rx_dropped++;
- kfree_skb(skb);
- return -EINVAL;
- }
- } else if (tun->flags & TUN_NOCHECKSUM)
- skb->ip_summed = CHECKSUM_UNNECESSARY;
-
if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
pr_debug("GSO!\n");
switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
^ permalink raw reply [flat|nested] 34+ messages in thread* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-26 4:40 ` Rusty Russell
@ 2008-06-26 18:16 ` Anthony Liguori
2008-06-27 3:50 ` Rusty Russell
2008-06-27 3:50 ` Rusty Russell
2008-06-26 18:16 ` Anthony Liguori
` (2 subsequent siblings)
3 siblings, 2 replies; 34+ messages in thread
From: Anthony Liguori @ 2008-06-26 18:16 UTC (permalink / raw)
To: Rusty Russell; +Cc: Max Krasnyansky, markmc, netdev, Herbert Xu, virtualization
Rusty Russell wrote:
> On Thursday 26 June 2008 05:07:18 Anthony Liguori wrote:
>
>> Rusty Russell wrote:
>>
>>> @@ -1563,6 +1561,16 @@ static void setup_tun_net(char *arg)
>>> /* Tell Guest what MAC address to use. */
>>> add_feature(dev, VIRTIO_NET_F_MAC);
>>> add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
>>> + /* Expect Guest to handle everything except UFO */
>>> + add_feature(dev, VIRTIO_NET_F_CSUM);
>>>
>> You're setting this feature twice.
>>
>
> Hmm, not in the version here?
>
Sorry, misread apparently.
>>> + add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
>>>
>> You set this feature, but I never see the virtio-net driver acknowledge
>> the feature.
I still don't see GUEST_CSUM ever get referenced in virtio_net.c.
What's the intention of this feature bit? Could I be missing a
virtio_net patch? I'm using the latest bits in Linus' tree.
>> Curiously, my implementation with KVM is struggling
>> because UDP packet checksums are not correct so the DHCP client is
>> ignoring them. If I disable CSUM offload, things it works fine (using
>> the virtio-net header). The problem is only host=>guest, guest=>host is
>> fine.
>>
>
> OK, found this: wrong args to skb_partial_csum_set. It was found by Mark
> McLoughlin before, I just lost the fix when I extracted this into a separate
> patch. I chose to move the call to skb_partial_csum_set(), rather than use
> his fix (which assumed a tap not tun device).
>
This still doesn't fix the problem. I can manually assign an IP address
and even do netperf runs but I cannot get a dhcp address (dhclient is
picky about the udp csum). Also, the RX performance is so low that I'm
sure a ton of packets are getting dropped. However, this patchset is
extremely promising, here are the results with KVM for TX:
w/o gso
[ 3] 0.0-10.0 sec 593 MBytes 498 Mbits/sec
w/gso
[ 5] 0.0-10.0 sec 1.86 GBytes 1.60 Gbits/sec
So that's a huge increase. Unfortunately, RX drops from 1.04 Gbits/sec
to only a few hundred Kbit/sec. I'm pretty sure this is the
checksumming issue.
Also, when I exit KVM, QEMU zombies and I notice:
Message from syslogd@squirrel at Jun 26 13:02:07 ...
kernel: unregister_netdevice: waiting for tap0 to become free. Usage
count = 3
Message from syslogd@squirrel at Jun 26 13:02:17 ...
kernel: unregister_netdevice: waiting for tap0 to become free. Usage
count = 0
Once the refcount drops to 0, the process exits. It looks fishy to me
though.
Regards,
Anthony Liguori
> Here's two fixes on top of previous patch:
>
> diff -u b/drivers/net/tun.c b/drivers/net/tun.c
> --- b/drivers/net/tun.c Thu Jun 26 00:21:59 2008 +1000
> +++ b/drivers/net/tun.c Thu Jun 26 14:35:03 2008 +1000
> @@ -298,11 +298,11 @@
> if ((len -= sizeof(gso)) > count)
> return -EINVAL;
>
> - if (gso.hdr_len > len)
> - return -EINVAL;
> -
> if (memcpy_fromiovec((void *)&gso, iv, sizeof(gso)))
> return -EFAULT;
> +
> + if (gso.hdr_len > len)
> + return -EINVAL;
> }
>
> if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) {
> @@ -324,6 +324,16 @@
> return -EFAULT;
> }
>
> + if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> + if (!skb_partial_csum_set(skb, gso.csum_start,
> + gso.csum_offset)) {
> + tun->dev->stats.rx_dropped++;
> + kfree_skb(skb);
> + return -EINVAL;
> + }
> + } else if (tun->flags & TUN_NOCHECKSUM)
> + skb->ip_summed = CHECKSUM_UNNECESSARY;
> +
> switch (tun->flags & TUN_TYPE_MASK) {
> case TUN_TUN_DEV:
> skb_reset_mac_header(skb);
> @@ -335,16 +345,6 @@
> break;
> };
>
> - if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> - if (!skb_partial_csum_set(skb, gso.csum_start,
> - gso.csum_offset)) {
> - tun->dev->stats.rx_dropped++;
> - kfree_skb(skb);
> - return -EINVAL;
> - }
> - } else if (tun->flags & TUN_NOCHECKSUM)
> - skb->ip_summed = CHECKSUM_UNNECESSARY;
> -
> if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
> pr_debug("GSO!\n");
> switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
>
^ permalink raw reply [flat|nested] 34+ messages in thread* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-26 18:16 ` Anthony Liguori
@ 2008-06-27 3:50 ` Rusty Russell
2008-06-27 3:50 ` Rusty Russell
1 sibling, 0 replies; 34+ messages in thread
From: Rusty Russell @ 2008-06-27 3:50 UTC (permalink / raw)
To: Anthony Liguori
Cc: markmc, virtualization, Herbert Xu, Max Krasnyansky, netdev
On Friday 27 June 2008 04:16:25 Anthony Liguori wrote:
> Rusty Russell wrote:
> > On Thursday 26 June 2008 05:07:18 Anthony Liguori wrote:
> >> Rusty Russell wrote:
> >>> + add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
> >>
> >> You set this feature, but I never see the virtio-net driver acknowledge
> >> the feature.
>
> I still don't see GUEST_CSUM ever get referenced in virtio_net.c.
> What's the intention of this feature bit? Could I be missing a
> virtio_net patch? I'm using the latest bits in Linus' tree.
It says that the guest can does csum offload. It's not advertised in the
current Linus tree (it got snuck in by Mark after the large-packets patches
still sitting in my tree). It should be tho, since the driver can handle it.
See patch at end.
> >> Curiously, my implementation with KVM is struggling
> >> because UDP packet checksums are not correct so the DHCP client is
> >> ignoring them. If I disable CSUM offload, things it works fine (using
> >> the virtio-net header). The problem is only host=>guest, guest=>host is
> >> fine.
> >
> > OK, found this: wrong args to skb_partial_csum_set. It was found by Mark
> > McLoughlin before, I just lost the fix when I extracted this into a
> > separate patch. I chose to move the call to skb_partial_csum_set(),
> > rather than use his fix (which assumed a tap not tun device).
>
> This still doesn't fix the problem. I can manually assign an IP address
> and even do netperf runs but I cannot get a dhcp address (dhclient is
> picky about the udp csum).
I'll retest this when I'm back home with my machines. Perhaps it's something
to do with the csum issue.
> Also, when I exit KVM, QEMU zombies and I notice:
>
> Message from syslogd@squirrel at Jun 26 13:02:07 ...
> kernel: unregister_netdevice: waiting for tap0 to become free. Usage
> count = 3
That seems odd; there is a leak in the vringfd interface which I know about,
but this looks like a GSO packet from the tun device is sticking around
somehow.
Cheers,
Rusty.
Subject: virtio_net: Set VIRTIO_NET_F_GUEST_CSUM feature
Date: Fri, 13 Jun 2008 14:27:34 +0100
From: Mark McLoughlin <markmc@redhat.com>
We can handle receiving partial csums, so set the
appropriate feature bit.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
drivers/net/virtio_net.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -550,7 +550,8 @@ static struct virtio_device_id id_table[
};
static unsigned int features[] = {
- VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
+ VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
+ VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
VIRTIO_NET_F_HOST_ECN, VIRTIO_F_NOTIFY_ON_EMPTY,
};
^ permalink raw reply [flat|nested] 34+ messages in thread* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-26 18:16 ` Anthony Liguori
2008-06-27 3:50 ` Rusty Russell
@ 2008-06-27 3:50 ` Rusty Russell
1 sibling, 0 replies; 34+ messages in thread
From: Rusty Russell @ 2008-06-27 3:50 UTC (permalink / raw)
To: Anthony Liguori
Cc: Max Krasnyansky, markmc, netdev, Herbert Xu, virtualization
On Friday 27 June 2008 04:16:25 Anthony Liguori wrote:
> Rusty Russell wrote:
> > On Thursday 26 June 2008 05:07:18 Anthony Liguori wrote:
> >> Rusty Russell wrote:
> >>> + add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
> >>
> >> You set this feature, but I never see the virtio-net driver acknowledge
> >> the feature.
>
> I still don't see GUEST_CSUM ever get referenced in virtio_net.c.
> What's the intention of this feature bit? Could I be missing a
> virtio_net patch? I'm using the latest bits in Linus' tree.
It says that the guest can does csum offload. It's not advertised in the
current Linus tree (it got snuck in by Mark after the large-packets patches
still sitting in my tree). It should be tho, since the driver can handle it.
See patch at end.
> >> Curiously, my implementation with KVM is struggling
> >> because UDP packet checksums are not correct so the DHCP client is
> >> ignoring them. If I disable CSUM offload, things it works fine (using
> >> the virtio-net header). The problem is only host=>guest, guest=>host is
> >> fine.
> >
> > OK, found this: wrong args to skb_partial_csum_set. It was found by Mark
> > McLoughlin before, I just lost the fix when I extracted this into a
> > separate patch. I chose to move the call to skb_partial_csum_set(),
> > rather than use his fix (which assumed a tap not tun device).
>
> This still doesn't fix the problem. I can manually assign an IP address
> and even do netperf runs but I cannot get a dhcp address (dhclient is
> picky about the udp csum).
I'll retest this when I'm back home with my machines. Perhaps it's something
to do with the csum issue.
> Also, when I exit KVM, QEMU zombies and I notice:
>
> Message from syslogd@squirrel at Jun 26 13:02:07 ...
> kernel: unregister_netdevice: waiting for tap0 to become free. Usage
> count = 3
That seems odd; there is a leak in the vringfd interface which I know about,
but this looks like a GSO packet from the tun device is sticking around
somehow.
Cheers,
Rusty.
Subject: virtio_net: Set VIRTIO_NET_F_GUEST_CSUM feature
Date: Fri, 13 Jun 2008 14:27:34 +0100
From: Mark McLoughlin <markmc@redhat.com>
We can handle receiving partial csums, so set the
appropriate feature bit.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
drivers/net/virtio_net.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -550,7 +550,8 @@ static struct virtio_device_id id_table[
};
static unsigned int features[] = {
- VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
+ VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
+ VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
VIRTIO_NET_F_HOST_ECN, VIRTIO_F_NOTIFY_ON_EMPTY,
};
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-26 4:40 ` Rusty Russell
2008-06-26 18:16 ` Anthony Liguori
@ 2008-06-26 18:16 ` Anthony Liguori
2008-07-02 5:25 ` Max Krasnyansky
2008-07-02 5:25 ` Max Krasnyansky
3 siblings, 0 replies; 34+ messages in thread
From: Anthony Liguori @ 2008-06-26 18:16 UTC (permalink / raw)
To: Rusty Russell; +Cc: markmc, virtualization, Herbert Xu, Max Krasnyansky, netdev
Rusty Russell wrote:
> On Thursday 26 June 2008 05:07:18 Anthony Liguori wrote:
>
>> Rusty Russell wrote:
>>
>>> @@ -1563,6 +1561,16 @@ static void setup_tun_net(char *arg)
>>> /* Tell Guest what MAC address to use. */
>>> add_feature(dev, VIRTIO_NET_F_MAC);
>>> add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
>>> + /* Expect Guest to handle everything except UFO */
>>> + add_feature(dev, VIRTIO_NET_F_CSUM);
>>>
>> You're setting this feature twice.
>>
>
> Hmm, not in the version here?
>
Sorry, misread apparently.
>>> + add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
>>>
>> You set this feature, but I never see the virtio-net driver acknowledge
>> the feature.
I still don't see GUEST_CSUM ever get referenced in virtio_net.c.
What's the intention of this feature bit? Could I be missing a
virtio_net patch? I'm using the latest bits in Linus' tree.
>> Curiously, my implementation with KVM is struggling
>> because UDP packet checksums are not correct so the DHCP client is
>> ignoring them. If I disable CSUM offload, things it works fine (using
>> the virtio-net header). The problem is only host=>guest, guest=>host is
>> fine.
>>
>
> OK, found this: wrong args to skb_partial_csum_set. It was found by Mark
> McLoughlin before, I just lost the fix when I extracted this into a separate
> patch. I chose to move the call to skb_partial_csum_set(), rather than use
> his fix (which assumed a tap not tun device).
>
This still doesn't fix the problem. I can manually assign an IP address
and even do netperf runs but I cannot get a dhcp address (dhclient is
picky about the udp csum). Also, the RX performance is so low that I'm
sure a ton of packets are getting dropped. However, this patchset is
extremely promising, here are the results with KVM for TX:
w/o gso
[ 3] 0.0-10.0 sec 593 MBytes 498 Mbits/sec
w/gso
[ 5] 0.0-10.0 sec 1.86 GBytes 1.60 Gbits/sec
So that's a huge increase. Unfortunately, RX drops from 1.04 Gbits/sec
to only a few hundred Kbit/sec. I'm pretty sure this is the
checksumming issue.
Also, when I exit KVM, QEMU zombies and I notice:
Message from syslogd@squirrel at Jun 26 13:02:07 ...
kernel: unregister_netdevice: waiting for tap0 to become free. Usage
count = 3
Message from syslogd@squirrel at Jun 26 13:02:17 ...
kernel: unregister_netdevice: waiting for tap0 to become free. Usage
count = 0
Once the refcount drops to 0, the process exits. It looks fishy to me
though.
Regards,
Anthony Liguori
> Here's two fixes on top of previous patch:
>
> diff -u b/drivers/net/tun.c b/drivers/net/tun.c
> --- b/drivers/net/tun.c Thu Jun 26 00:21:59 2008 +1000
> +++ b/drivers/net/tun.c Thu Jun 26 14:35:03 2008 +1000
> @@ -298,11 +298,11 @@
> if ((len -= sizeof(gso)) > count)
> return -EINVAL;
>
> - if (gso.hdr_len > len)
> - return -EINVAL;
> -
> if (memcpy_fromiovec((void *)&gso, iv, sizeof(gso)))
> return -EFAULT;
> +
> + if (gso.hdr_len > len)
> + return -EINVAL;
> }
>
> if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) {
> @@ -324,6 +324,16 @@
> return -EFAULT;
> }
>
> + if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> + if (!skb_partial_csum_set(skb, gso.csum_start,
> + gso.csum_offset)) {
> + tun->dev->stats.rx_dropped++;
> + kfree_skb(skb);
> + return -EINVAL;
> + }
> + } else if (tun->flags & TUN_NOCHECKSUM)
> + skb->ip_summed = CHECKSUM_UNNECESSARY;
> +
> switch (tun->flags & TUN_TYPE_MASK) {
> case TUN_TUN_DEV:
> skb_reset_mac_header(skb);
> @@ -335,16 +345,6 @@
> break;
> };
>
> - if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> - if (!skb_partial_csum_set(skb, gso.csum_start,
> - gso.csum_offset)) {
> - tun->dev->stats.rx_dropped++;
> - kfree_skb(skb);
> - return -EINVAL;
> - }
> - } else if (tun->flags & TUN_NOCHECKSUM)
> - skb->ip_summed = CHECKSUM_UNNECESSARY;
> -
> if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
> pr_debug("GSO!\n");
> switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
>
^ permalink raw reply [flat|nested] 34+ messages in thread* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-26 4:40 ` Rusty Russell
2008-06-26 18:16 ` Anthony Liguori
2008-06-26 18:16 ` Anthony Liguori
@ 2008-07-02 5:25 ` Max Krasnyansky
2008-07-02 5:25 ` Max Krasnyansky
3 siblings, 0 replies; 34+ messages in thread
From: Max Krasnyansky @ 2008-07-02 5:25 UTC (permalink / raw)
To: Rusty Russell; +Cc: Anthony Liguori, markmc, netdev, Herbert Xu, virtualization
Rusty Russell wrote:
> On Thursday 26 June 2008 05:07:18 Anthony Liguori wrote:
>> Rusty Russell wrote:
>>> @@ -1563,6 +1561,16 @@ static void setup_tun_net(char *arg)
>>> /* Tell Guest what MAC address to use. */
>>> add_feature(dev, VIRTIO_NET_F_MAC);
>>> add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
>>> + /* Expect Guest to handle everything except UFO */
>>> + add_feature(dev, VIRTIO_NET_F_CSUM);
>> You're setting this feature twice.
>
> Hmm, not in the version here?
>
>>> + add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
>> You set this feature, but I never see the virtio-net driver acknowledge
>> the feature. Curiously, my implementation with KVM is struggling
>> because UDP packet checksums are not correct so the DHCP client is
>> ignoring them. If I disable CSUM offload, things it works fine (using
>> the virtio-net header). The problem is only host=>guest, guest=>host is
>> fine.
>
> OK, found this: wrong args to skb_partial_csum_set. It was found by Mark
> McLoughlin before, I just lost the fix when I extracted this into a separate
> patch. I chose to move the call to skb_partial_csum_set(), rather than use
> his fix (which assumed a tap not tun device).
>
> Here's two fixes on top of previous patch:
>
> diff -u b/drivers/net/tun.c b/drivers/net/tun.c
> --- b/drivers/net/tun.c Thu Jun 26 00:21:59 2008 +1000
> +++ b/drivers/net/tun.c Thu Jun 26 14:35:03 2008 +1000
> @@ -298,11 +298,11 @@
> if ((len -= sizeof(gso)) > count)
> return -EINVAL;
>
> - if (gso.hdr_len > len)
> - return -EINVAL;
> -
> if (memcpy_fromiovec((void *)&gso, iv, sizeof(gso)))
> return -EFAULT;
> +
> + if (gso.hdr_len > len)
> + return -EINVAL;
> }
Yep, looks better now.
>
> if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) {
> @@ -324,6 +324,16 @@
> return -EFAULT;
> }
>
> + if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> + if (!skb_partial_csum_set(skb, gso.csum_start,
> + gso.csum_offset)) {
> + tun->dev->stats.rx_dropped++;
> + kfree_skb(skb);
> + return -EINVAL;
> + }
> + } else if (tun->flags & TUN_NOCHECKSUM)
> + skb->ip_summed = CHECKSUM_UNNECESSARY;
> +
> switch (tun->flags & TUN_TYPE_MASK) {
> case TUN_TUN_DEV:
> skb_reset_mac_header(skb);
> @@ -335,16 +345,6 @@
> break;
> };
>
> - if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> - if (!skb_partial_csum_set(skb, gso.csum_start,
> - gso.csum_offset)) {
> - tun->dev->stats.rx_dropped++;
> - kfree_skb(skb);
> - return -EINVAL;
> - }
> - } else if (tun->flags & TUN_NOCHECKSUM)
> - skb->ip_summed = CHECKSUM_UNNECESSARY;
> -
> if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
> pr_debug("GSO!\n");
> switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
Do you want to resent the GSO patch with all the latest fixes ? ie other
things (stat counters) I pointed out in the prev email.
I'll ack it.
Thanx
Max
^ permalink raw reply [flat|nested] 34+ messages in thread* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-26 4:40 ` Rusty Russell
` (2 preceding siblings ...)
2008-07-02 5:25 ` Max Krasnyansky
@ 2008-07-02 5:25 ` Max Krasnyansky
3 siblings, 0 replies; 34+ messages in thread
From: Max Krasnyansky @ 2008-07-02 5:25 UTC (permalink / raw)
To: Rusty Russell; +Cc: markmc, virtualization, Herbert Xu, Anthony Liguori, netdev
Rusty Russell wrote:
> On Thursday 26 June 2008 05:07:18 Anthony Liguori wrote:
>> Rusty Russell wrote:
>>> @@ -1563,6 +1561,16 @@ static void setup_tun_net(char *arg)
>>> /* Tell Guest what MAC address to use. */
>>> add_feature(dev, VIRTIO_NET_F_MAC);
>>> add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
>>> + /* Expect Guest to handle everything except UFO */
>>> + add_feature(dev, VIRTIO_NET_F_CSUM);
>> You're setting this feature twice.
>
> Hmm, not in the version here?
>
>>> + add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
>> You set this feature, but I never see the virtio-net driver acknowledge
>> the feature. Curiously, my implementation with KVM is struggling
>> because UDP packet checksums are not correct so the DHCP client is
>> ignoring them. If I disable CSUM offload, things it works fine (using
>> the virtio-net header). The problem is only host=>guest, guest=>host is
>> fine.
>
> OK, found this: wrong args to skb_partial_csum_set. It was found by Mark
> McLoughlin before, I just lost the fix when I extracted this into a separate
> patch. I chose to move the call to skb_partial_csum_set(), rather than use
> his fix (which assumed a tap not tun device).
>
> Here's two fixes on top of previous patch:
>
> diff -u b/drivers/net/tun.c b/drivers/net/tun.c
> --- b/drivers/net/tun.c Thu Jun 26 00:21:59 2008 +1000
> +++ b/drivers/net/tun.c Thu Jun 26 14:35:03 2008 +1000
> @@ -298,11 +298,11 @@
> if ((len -= sizeof(gso)) > count)
> return -EINVAL;
>
> - if (gso.hdr_len > len)
> - return -EINVAL;
> -
> if (memcpy_fromiovec((void *)&gso, iv, sizeof(gso)))
> return -EFAULT;
> +
> + if (gso.hdr_len > len)
> + return -EINVAL;
> }
Yep, looks better now.
>
> if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) {
> @@ -324,6 +324,16 @@
> return -EFAULT;
> }
>
> + if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> + if (!skb_partial_csum_set(skb, gso.csum_start,
> + gso.csum_offset)) {
> + tun->dev->stats.rx_dropped++;
> + kfree_skb(skb);
> + return -EINVAL;
> + }
> + } else if (tun->flags & TUN_NOCHECKSUM)
> + skb->ip_summed = CHECKSUM_UNNECESSARY;
> +
> switch (tun->flags & TUN_TYPE_MASK) {
> case TUN_TUN_DEV:
> skb_reset_mac_header(skb);
> @@ -335,16 +345,6 @@
> break;
> };
>
> - if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> - if (!skb_partial_csum_set(skb, gso.csum_start,
> - gso.csum_offset)) {
> - tun->dev->stats.rx_dropped++;
> - kfree_skb(skb);
> - return -EINVAL;
> - }
> - } else if (tun->flags & TUN_NOCHECKSUM)
> - skb->ip_summed = CHECKSUM_UNNECESSARY;
> -
> if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
> pr_debug("GSO!\n");
> switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
Do you want to resent the GSO patch with all the latest fixes ? ie other
things (stat counters) I pointed out in the prev email.
I'll ack it.
Thanx
Max
^ permalink raw reply [flat|nested] 34+ messages in thread
* [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-25 14:30 ` [PATCH 3/4] tun: Allow GSO using virtio_net_hdr Rusty Russell
2008-06-25 14:32 ` [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap Rusty Russell
@ 2008-06-25 14:32 ` Rusty Russell
2008-06-25 14:32 ` Rusty Russell
` (4 subsequent siblings)
6 siblings, 0 replies; 34+ messages in thread
From: Rusty Russell @ 2008-06-25 14:32 UTC (permalink / raw)
To: Max Krasnyansky; +Cc: markmc, netdev, Herbert Xu, virtualization
(Might not apply cleanly to current Linus, there are other lguest things
going on, but this gives you the idea at least).
Guest -> Host 1GB TCP:
Before: Seconds 16.6282 xmit 250498 recv 3 timeout 248355
After: Seconds 9.86102 xmit 241989 recv 192014 timeout 231224
Host -> Guest 1GB TCP:
Before: Seconds 11.0831 xmit 324742 recv 1910 timeout 323429
After: Seconds 10.6626 xmit 342489 recv 24 timeout 341173
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
Documentation/lguest/lguest.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff -r 7358caf10bd8 Documentation/lguest/lguest.c
--- a/Documentation/lguest/lguest.c Tue Jun 24 16:15:36 2008 +1000
+++ b/Documentation/lguest/lguest.c Wed Jun 25 00:29:31 2008 +1000
@@ -928,11 +928,9 @@ static void handle_net_output(int fd, st
while ((head = get_vq_desc(vq, iov, &out, &in)) != vq->vring.num) {
if (in)
errx(1, "Input buffers in output queue?");
- /* Check header, but otherwise ignore it (we told the Guest we
- * supported no features, so it shouldn't have anything
- * interesting). */
- (void)convert(&iov[0], struct virtio_net_hdr);
- len = writev(vq->dev->fd, iov+1, out-1);
+ len = writev(vq->dev->fd, iov, out);
+ if (len < 0)
+ err(1, "Writing network packet to tun");
add_used_and_trigger(fd, vq, head, len);
num++;
}
@@ -949,7 +947,6 @@ static bool handle_tun_input(int fd, str
unsigned int head, in_num, out_num;
int len;
struct iovec iov[dev->vq->vring.num];
- struct virtio_net_hdr *hdr;
/* First we need a network buffer from the Guests's recv virtqueue. */
head = get_vq_desc(dev->vq, iov, &out_num, &in_num);
@@ -970,18 +969,13 @@ static bool handle_tun_input(int fd, str
} else if (out_num)
errx(1, "Output buffers in network recv queue?");
- /* First element is the header: we set it to 0 (no features). */
- hdr = convert(&iov[0], struct virtio_net_hdr);
- hdr->flags = 0;
- hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
-
/* Read the packet from the device directly into the Guest's buffer. */
- len = readv(dev->fd, iov+1, in_num-1);
+ len = readv(dev->fd, iov, in_num);
if (len <= 0)
err(1, "reading network");
/* Tell the Guest about the new packet. */
- add_used_and_trigger(fd, dev->vq, head, sizeof(*hdr) + len);
+ add_used_and_trigger(fd, dev->vq, head, len);
verbose("tun input packet len %i [%02x %02x] (%s)\n", len,
((u8 *)iov[1].iov_base)[0], ((u8 *)iov[1].iov_base)[1],
@@ -1492,10 +1486,14 @@ static int get_tun_device(char tapif[IFN
* the truth, I completely blundered my way through this code, but it
* works now! */
netfd = open_or_die("/dev/net/tun", O_RDWR);
- ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
+ ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_VNET_HDR;
strcpy(ifr.ifr_name, "tap%d");
if (ioctl(netfd, TUNSETIFF, &ifr) != 0)
err(1, "configuring /dev/net/tun");
+
+ if (ioctl(netfd, TUNSETFEATURES,
+ TUN_F_CSUM|TUN_F_TSO4|TUN_F_TSO6|TUN_F_TSO_ECN) != 0)
+ err(1, "Could not set features for tun device");
/* We don't need checksums calculated for packets coming in this
* device: trust us! */
@@ -1563,6 +1561,16 @@ static void setup_tun_net(char *arg)
/* Tell Guest what MAC address to use. */
add_feature(dev, VIRTIO_NET_F_MAC);
add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
+ /* Expect Guest to handle everything except UFO */
+ add_feature(dev, VIRTIO_NET_F_CSUM);
+ add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
+ add_feature(dev, VIRTIO_NET_F_MAC);
+ add_feature(dev, VIRTIO_NET_F_GUEST_TSO4);
+ add_feature(dev, VIRTIO_NET_F_GUEST_TSO6);
+ add_feature(dev, VIRTIO_NET_F_GUEST_ECN);
+ add_feature(dev, VIRTIO_NET_F_HOST_TSO4);
+ add_feature(dev, VIRTIO_NET_F_HOST_TSO6);
+ add_feature(dev, VIRTIO_NET_F_HOST_ECN);
set_config(dev, sizeof(conf), &conf);
/* We don't need the socket any more; setup is done. */
^ permalink raw reply [flat|nested] 34+ messages in thread* [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-25 14:30 ` [PATCH 3/4] tun: Allow GSO using virtio_net_hdr Rusty Russell
2008-06-25 14:32 ` [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap Rusty Russell
2008-06-25 14:32 ` Rusty Russell
@ 2008-06-25 14:32 ` Rusty Russell
2008-06-25 15:45 ` Rusty Russell
2008-06-25 15:45 ` Rusty Russell
2008-07-02 5:13 ` [PATCH 3/4] tun: Allow GSO using virtio_net_hdr Max Krasnyansky
` (3 subsequent siblings)
6 siblings, 2 replies; 34+ messages in thread
From: Rusty Russell @ 2008-06-25 14:32 UTC (permalink / raw)
To: Max Krasnyansky; +Cc: Herbert Xu, netdev, virtualization, markmc
(Might not apply cleanly to current Linus, there are other lguest things
going on, but this gives you the idea at least).
Guest -> Host 1GB TCP:
Before: Seconds 16.6282 xmit 250498 recv 3 timeout 248355
After: Seconds 9.86102 xmit 241989 recv 192014 timeout 231224
Host -> Guest 1GB TCP:
Before: Seconds 11.0831 xmit 324742 recv 1910 timeout 323429
After: Seconds 10.6626 xmit 342489 recv 24 timeout 341173
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
Documentation/lguest/lguest.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff -r 7358caf10bd8 Documentation/lguest/lguest.c
--- a/Documentation/lguest/lguest.c Tue Jun 24 16:15:36 2008 +1000
+++ b/Documentation/lguest/lguest.c Wed Jun 25 00:29:31 2008 +1000
@@ -928,11 +928,9 @@ static void handle_net_output(int fd, st
while ((head = get_vq_desc(vq, iov, &out, &in)) != vq->vring.num) {
if (in)
errx(1, "Input buffers in output queue?");
- /* Check header, but otherwise ignore it (we told the Guest we
- * supported no features, so it shouldn't have anything
- * interesting). */
- (void)convert(&iov[0], struct virtio_net_hdr);
- len = writev(vq->dev->fd, iov+1, out-1);
+ len = writev(vq->dev->fd, iov, out);
+ if (len < 0)
+ err(1, "Writing network packet to tun");
add_used_and_trigger(fd, vq, head, len);
num++;
}
@@ -949,7 +947,6 @@ static bool handle_tun_input(int fd, str
unsigned int head, in_num, out_num;
int len;
struct iovec iov[dev->vq->vring.num];
- struct virtio_net_hdr *hdr;
/* First we need a network buffer from the Guests's recv virtqueue. */
head = get_vq_desc(dev->vq, iov, &out_num, &in_num);
@@ -970,18 +969,13 @@ static bool handle_tun_input(int fd, str
} else if (out_num)
errx(1, "Output buffers in network recv queue?");
- /* First element is the header: we set it to 0 (no features). */
- hdr = convert(&iov[0], struct virtio_net_hdr);
- hdr->flags = 0;
- hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
-
/* Read the packet from the device directly into the Guest's buffer. */
- len = readv(dev->fd, iov+1, in_num-1);
+ len = readv(dev->fd, iov, in_num);
if (len <= 0)
err(1, "reading network");
/* Tell the Guest about the new packet. */
- add_used_and_trigger(fd, dev->vq, head, sizeof(*hdr) + len);
+ add_used_and_trigger(fd, dev->vq, head, len);
verbose("tun input packet len %i [%02x %02x] (%s)\n", len,
((u8 *)iov[1].iov_base)[0], ((u8 *)iov[1].iov_base)[1],
@@ -1492,10 +1486,14 @@ static int get_tun_device(char tapif[IFN
* the truth, I completely blundered my way through this code, but it
* works now! */
netfd = open_or_die("/dev/net/tun", O_RDWR);
- ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
+ ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_VNET_HDR;
strcpy(ifr.ifr_name, "tap%d");
if (ioctl(netfd, TUNSETIFF, &ifr) != 0)
err(1, "configuring /dev/net/tun");
+
+ if (ioctl(netfd, TUNSETFEATURES,
+ TUN_F_CSUM|TUN_F_TSO4|TUN_F_TSO6|TUN_F_TSO_ECN) != 0)
+ err(1, "Could not set features for tun device");
/* We don't need checksums calculated for packets coming in this
* device: trust us! */
@@ -1563,6 +1561,16 @@ static void setup_tun_net(char *arg)
/* Tell Guest what MAC address to use. */
add_feature(dev, VIRTIO_NET_F_MAC);
add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);
+ /* Expect Guest to handle everything except UFO */
+ add_feature(dev, VIRTIO_NET_F_CSUM);
+ add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
+ add_feature(dev, VIRTIO_NET_F_MAC);
+ add_feature(dev, VIRTIO_NET_F_GUEST_TSO4);
+ add_feature(dev, VIRTIO_NET_F_GUEST_TSO6);
+ add_feature(dev, VIRTIO_NET_F_GUEST_ECN);
+ add_feature(dev, VIRTIO_NET_F_HOST_TSO4);
+ add_feature(dev, VIRTIO_NET_F_HOST_TSO6);
+ add_feature(dev, VIRTIO_NET_F_HOST_ECN);
set_config(dev, sizeof(conf), &conf);
/* We don't need the socket any more; setup is done. */
^ permalink raw reply [flat|nested] 34+ messages in thread* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-25 14:32 ` Rusty Russell
@ 2008-06-25 15:45 ` Rusty Russell
2008-06-25 15:45 ` Rusty Russell
1 sibling, 0 replies; 34+ messages in thread
From: Rusty Russell @ 2008-06-25 15:45 UTC (permalink / raw)
To: virtualization; +Cc: Max Krasnyansky, markmc, netdev, Herbert Xu
On Thursday 26 June 2008 00:32:12 Rusty Russell wrote:
> (Might not apply cleanly to current Linus, there are other lguest things
> going on, but this gives you the idea at least).
...
> + if (ioctl(netfd, TUNSETFEATURES,
> + TUN_F_CSUM|TUN_F_TSO4|TUN_F_TSO6|TUN_F_TSO_ECN) != 0)
> + err(1, "Could not set features for tun device");
This should be TUNSETOFFLOAD of course. I renamed it at the last minute,
because TUNSETFEATURES implies symmetry with TUNGETFEATURES, which is
completely different.
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH 4/4] lguest: Use GSO/IFF_VNET_HDR extensions on tun/tap
2008-06-25 14:32 ` Rusty Russell
2008-06-25 15:45 ` Rusty Russell
@ 2008-06-25 15:45 ` Rusty Russell
1 sibling, 0 replies; 34+ messages in thread
From: Rusty Russell @ 2008-06-25 15:45 UTC (permalink / raw)
To: virtualization; +Cc: markmc, Herbert Xu, Max Krasnyansky, netdev
On Thursday 26 June 2008 00:32:12 Rusty Russell wrote:
> (Might not apply cleanly to current Linus, there are other lguest things
> going on, but this gives you the idea at least).
...
> + if (ioctl(netfd, TUNSETFEATURES,
> + TUN_F_CSUM|TUN_F_TSO4|TUN_F_TSO6|TUN_F_TSO_ECN) != 0)
> + err(1, "Could not set features for tun device");
This should be TUNSETOFFLOAD of course. I renamed it at the last minute,
because TUNSETFEATURES implies symmetry with TUNGETFEATURES, which is
completely different.
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH 3/4] tun: Allow GSO using virtio_net_hdr
2008-06-25 14:30 ` [PATCH 3/4] tun: Allow GSO using virtio_net_hdr Rusty Russell
` (2 preceding siblings ...)
2008-06-25 14:32 ` Rusty Russell
@ 2008-07-02 5:13 ` Max Krasnyansky
2008-07-02 7:00 ` Rusty Russell
2008-07-02 7:00 ` Rusty Russell
2008-07-02 5:13 ` Max Krasnyansky
` (2 subsequent siblings)
6 siblings, 2 replies; 34+ messages in thread
From: Max Krasnyansky @ 2008-07-02 5:13 UTC (permalink / raw)
To: Rusty Russell; +Cc: Herbert Xu, netdev, virtualization, markmc
Rusty Russell wrote:
> Add a IFF_VNET_HDR flag. This uses the same ABI as virtio_net (ie. prepending
> struct virtio_net_hdr to packets) to indicate GSO and checksum information.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
> drivers/net/tun.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++-
> include/linux/if_tun.h | 2 +
> 2 files changed, 91 insertions(+), 1 deletion(-)
>
> diff -r d94590c1550a drivers/net/tun.c
> --- a/drivers/net/tun.c Thu Jun 26 00:21:11 2008 +1000
> +++ b/drivers/net/tun.c Thu Jun 26 00:21:59 2008 +1000
> @@ -63,6 +63,7 @@
> #include <linux/if_tun.h>
> #include <linux/crc32.h>
> #include <linux/nsproxy.h>
> +#include <linux/virtio_net.h>
> #include <net/net_namespace.h>
> #include <net/netns/generic.h>
>
> @@ -283,12 +284,24 @@ static __inline__ ssize_t tun_get_user(s
> struct tun_pi pi = { 0, __constant_htons(ETH_P_IP) };
> struct sk_buff *skb;
> size_t len = count, align = 0;
> + struct virtio_net_hdr gso = { 0 };
>
> if (!(tun->flags & TUN_NO_PI)) {
> if ((len -= sizeof(pi)) > count)
> return -EINVAL;
>
> if(memcpy_fromiovec((void *)&pi, iv, sizeof(pi)))
> + return -EFAULT;
> + }
> +
> + if (tun->flags & TUN_VNET_HDR) {
> + if ((len -= sizeof(gso)) > count)
> + return -EINVAL;
> +
> + if (gso.hdr_len > len)
> + return -EINVAL;
> +
> + if (memcpy_fromiovec((void *)&gso, iv, sizeof(gso)))
> return -EFAULT;
> }
Unless I'm missing something the 'if (gso.hdr_len > len)' must be after
memcpy_fromiovec().
> @@ -322,8 +335,45 @@ static __inline__ ssize_t tun_get_user(s
> break;
> };
>
> - if (tun->flags & TUN_NOCHECKSUM)
> + if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> + if (!skb_partial_csum_set(skb, gso.csum_start,
> + gso.csum_offset)) {
> + tun->dev->stats.rx_dropped++;
> + kfree_skb(skb);
> + return -EINVAL;
> + }
> + } else if (tun->flags & TUN_NOCHECKSUM)
> skb->ip_summed = CHECKSUM_UNNECESSARY;
> +
> + if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
> + pr_debug("GSO!\n");
> + switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
> + case VIRTIO_NET_HDR_GSO_TCPV4:
> + skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
> + break;
> + case VIRTIO_NET_HDR_GSO_TCPV6:
> + skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
> + break;
> + default:
> + tun->dev->stats.rx_dropped++;
> + kfree_skb(skb);
> + return -EINVAL;
> + }
We should use stats.rx_frame_errors instead of stats.rx_dropped to indicated
that we dropped it because something was wrong with the framing (headers,
etc). Applies to both of the cases above.
> +
> + if (gso.gso_type & VIRTIO_NET_HDR_GSO_ECN)
> + skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
> +
> + skb_shinfo(skb)->gso_size = gso.gso_size;
> + if (skb_shinfo(skb)->gso_size == 0) {
> + tun->dev->stats.rx_dropped++;
> + kfree_skb(skb);
> + return -EINVAL;
> + }
Same here.
Everything else looks good.
Max
^ permalink raw reply [flat|nested] 34+ messages in thread* Re: [PATCH 3/4] tun: Allow GSO using virtio_net_hdr
2008-07-02 5:13 ` [PATCH 3/4] tun: Allow GSO using virtio_net_hdr Max Krasnyansky
@ 2008-07-02 7:00 ` Rusty Russell
2008-07-02 7:00 ` Rusty Russell
1 sibling, 0 replies; 34+ messages in thread
From: Rusty Russell @ 2008-07-02 7:00 UTC (permalink / raw)
To: Max Krasnyansky; +Cc: markmc, netdev, Herbert Xu, virtualization
On Wednesday 02 July 2008 15:13:59 Max Krasnyansky wrote:
> Rusty Russell wrote:
> > Add a IFF_VNET_HDR flag. This uses the same ABI as virtio_net (ie.
> > prepending struct virtio_net_hdr to packets) to indicate GSO and checksum
> > information.
> >
> > Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> > ---
> > drivers/net/tun.c | 90
> > ++++++++++++++++++++++++++++++++++++++++++++++++- include/linux/if_tun.h
> > | 2 +
> > 2 files changed, 91 insertions(+), 1 deletion(-)
> >
> > diff -r d94590c1550a drivers/net/tun.c
> > --- a/drivers/net/tun.c Thu Jun 26 00:21:11 2008 +1000
> > +++ b/drivers/net/tun.c Thu Jun 26 00:21:59 2008 +1000
> > @@ -63,6 +63,7 @@
> > #include <linux/if_tun.h>
> > #include <linux/crc32.h>
> > #include <linux/nsproxy.h>
> > +#include <linux/virtio_net.h>
> > #include <net/net_namespace.h>
> > #include <net/netns/generic.h>
> >
> > @@ -283,12 +284,24 @@ static __inline__ ssize_t tun_get_user(s
> > struct tun_pi pi = { 0, __constant_htons(ETH_P_IP) };
> > struct sk_buff *skb;
> > size_t len = count, align = 0;
> > + struct virtio_net_hdr gso = { 0 };
> >
> > if (!(tun->flags & TUN_NO_PI)) {
> > if ((len -= sizeof(pi)) > count)
> > return -EINVAL;
> >
> > if(memcpy_fromiovec((void *)&pi, iv, sizeof(pi)))
> > + return -EFAULT;
> > + }
> > +
> > + if (tun->flags & TUN_VNET_HDR) {
> > + if ((len -= sizeof(gso)) > count)
> > + return -EINVAL;
> > +
> > + if (gso.hdr_len > len)
> > + return -EINVAL;
> > +
> > + if (memcpy_fromiovec((void *)&gso, iv, sizeof(gso)))
> > return -EFAULT;
> > }
>
> Unless I'm missing something the 'if (gso.hdr_len > len)' must be after
> memcpy_fromiovec().
Yes, this was fixed in a followup... there was another bug picked up by markmc
too in this patch.
> > + case VIRTIO_NET_HDR_GSO_TCPV6:
> > + skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
> > + break;
> > + default:
> > + tun->dev->stats.rx_dropped++;
> > + kfree_skb(skb);
> > + return -EINVAL;
> > + }
>
> We should use stats.rx_frame_errors instead of stats.rx_dropped to
> indicated that we dropped it because something was wrong with the framing
> (headers, etc). Applies to both of the cases above.
OK, done (all three). Will repost.
Thanks,
Rusty.
^ permalink raw reply [flat|nested] 34+ messages in thread* Re: [PATCH 3/4] tun: Allow GSO using virtio_net_hdr
2008-07-02 5:13 ` [PATCH 3/4] tun: Allow GSO using virtio_net_hdr Max Krasnyansky
2008-07-02 7:00 ` Rusty Russell
@ 2008-07-02 7:00 ` Rusty Russell
1 sibling, 0 replies; 34+ messages in thread
From: Rusty Russell @ 2008-07-02 7:00 UTC (permalink / raw)
To: Max Krasnyansky; +Cc: Herbert Xu, netdev, virtualization, markmc
On Wednesday 02 July 2008 15:13:59 Max Krasnyansky wrote:
> Rusty Russell wrote:
> > Add a IFF_VNET_HDR flag. This uses the same ABI as virtio_net (ie.
> > prepending struct virtio_net_hdr to packets) to indicate GSO and checksum
> > information.
> >
> > Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> > ---
> > drivers/net/tun.c | 90
> > ++++++++++++++++++++++++++++++++++++++++++++++++- include/linux/if_tun.h
> > | 2 +
> > 2 files changed, 91 insertions(+), 1 deletion(-)
> >
> > diff -r d94590c1550a drivers/net/tun.c
> > --- a/drivers/net/tun.c Thu Jun 26 00:21:11 2008 +1000
> > +++ b/drivers/net/tun.c Thu Jun 26 00:21:59 2008 +1000
> > @@ -63,6 +63,7 @@
> > #include <linux/if_tun.h>
> > #include <linux/crc32.h>
> > #include <linux/nsproxy.h>
> > +#include <linux/virtio_net.h>
> > #include <net/net_namespace.h>
> > #include <net/netns/generic.h>
> >
> > @@ -283,12 +284,24 @@ static __inline__ ssize_t tun_get_user(s
> > struct tun_pi pi = { 0, __constant_htons(ETH_P_IP) };
> > struct sk_buff *skb;
> > size_t len = count, align = 0;
> > + struct virtio_net_hdr gso = { 0 };
> >
> > if (!(tun->flags & TUN_NO_PI)) {
> > if ((len -= sizeof(pi)) > count)
> > return -EINVAL;
> >
> > if(memcpy_fromiovec((void *)&pi, iv, sizeof(pi)))
> > + return -EFAULT;
> > + }
> > +
> > + if (tun->flags & TUN_VNET_HDR) {
> > + if ((len -= sizeof(gso)) > count)
> > + return -EINVAL;
> > +
> > + if (gso.hdr_len > len)
> > + return -EINVAL;
> > +
> > + if (memcpy_fromiovec((void *)&gso, iv, sizeof(gso)))
> > return -EFAULT;
> > }
>
> Unless I'm missing something the 'if (gso.hdr_len > len)' must be after
> memcpy_fromiovec().
Yes, this was fixed in a followup... there was another bug picked up by markmc
too in this patch.
> > + case VIRTIO_NET_HDR_GSO_TCPV6:
> > + skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
> > + break;
> > + default:
> > + tun->dev->stats.rx_dropped++;
> > + kfree_skb(skb);
> > + return -EINVAL;
> > + }
>
> We should use stats.rx_frame_errors instead of stats.rx_dropped to
> indicated that we dropped it because something was wrong with the framing
> (headers, etc). Applies to both of the cases above.
OK, done (all three). Will repost.
Thanks,
Rusty.
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH 3/4] tun: Allow GSO using virtio_net_hdr
2008-06-25 14:30 ` [PATCH 3/4] tun: Allow GSO using virtio_net_hdr Rusty Russell
` (3 preceding siblings ...)
2008-07-02 5:13 ` [PATCH 3/4] tun: Allow GSO using virtio_net_hdr Max Krasnyansky
@ 2008-07-02 5:13 ` Max Krasnyansky
2008-07-24 14:20 ` Herbert Xu
2008-07-24 14:20 ` Herbert Xu
6 siblings, 0 replies; 34+ messages in thread
From: Max Krasnyansky @ 2008-07-02 5:13 UTC (permalink / raw)
To: Rusty Russell; +Cc: markmc, netdev, Herbert Xu, virtualization
Rusty Russell wrote:
> Add a IFF_VNET_HDR flag. This uses the same ABI as virtio_net (ie. prepending
> struct virtio_net_hdr to packets) to indicate GSO and checksum information.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
> drivers/net/tun.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++-
> include/linux/if_tun.h | 2 +
> 2 files changed, 91 insertions(+), 1 deletion(-)
>
> diff -r d94590c1550a drivers/net/tun.c
> --- a/drivers/net/tun.c Thu Jun 26 00:21:11 2008 +1000
> +++ b/drivers/net/tun.c Thu Jun 26 00:21:59 2008 +1000
> @@ -63,6 +63,7 @@
> #include <linux/if_tun.h>
> #include <linux/crc32.h>
> #include <linux/nsproxy.h>
> +#include <linux/virtio_net.h>
> #include <net/net_namespace.h>
> #include <net/netns/generic.h>
>
> @@ -283,12 +284,24 @@ static __inline__ ssize_t tun_get_user(s
> struct tun_pi pi = { 0, __constant_htons(ETH_P_IP) };
> struct sk_buff *skb;
> size_t len = count, align = 0;
> + struct virtio_net_hdr gso = { 0 };
>
> if (!(tun->flags & TUN_NO_PI)) {
> if ((len -= sizeof(pi)) > count)
> return -EINVAL;
>
> if(memcpy_fromiovec((void *)&pi, iv, sizeof(pi)))
> + return -EFAULT;
> + }
> +
> + if (tun->flags & TUN_VNET_HDR) {
> + if ((len -= sizeof(gso)) > count)
> + return -EINVAL;
> +
> + if (gso.hdr_len > len)
> + return -EINVAL;
> +
> + if (memcpy_fromiovec((void *)&gso, iv, sizeof(gso)))
> return -EFAULT;
> }
Unless I'm missing something the 'if (gso.hdr_len > len)' must be after
memcpy_fromiovec().
> @@ -322,8 +335,45 @@ static __inline__ ssize_t tun_get_user(s
> break;
> };
>
> - if (tun->flags & TUN_NOCHECKSUM)
> + if (gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> + if (!skb_partial_csum_set(skb, gso.csum_start,
> + gso.csum_offset)) {
> + tun->dev->stats.rx_dropped++;
> + kfree_skb(skb);
> + return -EINVAL;
> + }
> + } else if (tun->flags & TUN_NOCHECKSUM)
> skb->ip_summed = CHECKSUM_UNNECESSARY;
> +
> + if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
> + pr_debug("GSO!\n");
> + switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
> + case VIRTIO_NET_HDR_GSO_TCPV4:
> + skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
> + break;
> + case VIRTIO_NET_HDR_GSO_TCPV6:
> + skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
> + break;
> + default:
> + tun->dev->stats.rx_dropped++;
> + kfree_skb(skb);
> + return -EINVAL;
> + }
We should use stats.rx_frame_errors instead of stats.rx_dropped to indicated
that we dropped it because something was wrong with the framing (headers,
etc). Applies to both of the cases above.
> +
> + if (gso.gso_type & VIRTIO_NET_HDR_GSO_ECN)
> + skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
> +
> + skb_shinfo(skb)->gso_size = gso.gso_size;
> + if (skb_shinfo(skb)->gso_size == 0) {
> + tun->dev->stats.rx_dropped++;
> + kfree_skb(skb);
> + return -EINVAL;
> + }
Same here.
Everything else looks good.
Max
^ permalink raw reply [flat|nested] 34+ messages in thread* Re: [PATCH 3/4] tun: Allow GSO using virtio_net_hdr
2008-06-25 14:30 ` [PATCH 3/4] tun: Allow GSO using virtio_net_hdr Rusty Russell
` (4 preceding siblings ...)
2008-07-02 5:13 ` Max Krasnyansky
@ 2008-07-24 14:20 ` Herbert Xu
2008-07-24 23:54 ` Rusty Russell
2008-07-24 23:54 ` Rusty Russell
2008-07-24 14:20 ` Herbert Xu
6 siblings, 2 replies; 34+ messages in thread
From: Herbert Xu @ 2008-07-24 14:20 UTC (permalink / raw)
To: Rusty Russell; +Cc: Max Krasnyansky, netdev, virtualization, markmc
On Thu, Jun 26, 2008 at 12:30:37AM +1000, Rusty Russell wrote:
> Add a IFF_VNET_HDR flag. This uses the same ABI as virtio_net (ie. prepending
> struct virtio_net_hdr to packets) to indicate GSO and checksum information.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
I just noticed that we still allocate a linear skb even when GSO
is enabled. Please fix this by allocating page frags where
necessary. Otherwise GSO is only going to work before memory
fragmentation sets in.
IIRC I'd sent out a patch to the virt mailing list with code
that did this.
Thanks,
--
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 [flat|nested] 34+ messages in thread* Re: [PATCH 3/4] tun: Allow GSO using virtio_net_hdr
2008-07-24 14:20 ` Herbert Xu
@ 2008-07-24 23:54 ` Rusty Russell
2008-07-24 23:54 ` Rusty Russell
1 sibling, 0 replies; 34+ messages in thread
From: Rusty Russell @ 2008-07-24 23:54 UTC (permalink / raw)
To: Herbert Xu; +Cc: markmc, netdev, Max Krasnyansky, virtualization
On Friday 25 July 2008 00:20:44 Herbert Xu wrote:
> On Thu, Jun 26, 2008 at 12:30:37AM +1000, Rusty Russell wrote:
> > Add a IFF_VNET_HDR flag. This uses the same ABI as virtio_net (ie.
> > prepending struct virtio_net_hdr to packets) to indicate GSO and checksum
> > information.
> >
> > Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>
> I just noticed that we still allocate a linear skb even when GSO
> is enabled. Please fix this by allocating page frags where
> necessary. Otherwise GSO is only going to work before memory
> fragmentation sets in.
>
> IIRC I'd sent out a patch to the virt mailing list with code
> that did this.
>
> Thanks,
Hi Herbert,
Thanks for the reminder. I have this code in the virtio_net patches which
Linus failed to pull. Will just need to share it with the tun code (maybe a
skb_alloc_large() helper).
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH 3/4] tun: Allow GSO using virtio_net_hdr
2008-07-24 14:20 ` Herbert Xu
2008-07-24 23:54 ` Rusty Russell
@ 2008-07-24 23:54 ` Rusty Russell
1 sibling, 0 replies; 34+ messages in thread
From: Rusty Russell @ 2008-07-24 23:54 UTC (permalink / raw)
To: Herbert Xu; +Cc: Max Krasnyansky, netdev, virtualization, markmc
On Friday 25 July 2008 00:20:44 Herbert Xu wrote:
> On Thu, Jun 26, 2008 at 12:30:37AM +1000, Rusty Russell wrote:
> > Add a IFF_VNET_HDR flag. This uses the same ABI as virtio_net (ie.
> > prepending struct virtio_net_hdr to packets) to indicate GSO and checksum
> > information.
> >
> > Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>
> I just noticed that we still allocate a linear skb even when GSO
> is enabled. Please fix this by allocating page frags where
> necessary. Otherwise GSO is only going to work before memory
> fragmentation sets in.
>
> IIRC I'd sent out a patch to the virt mailing list with code
> that did this.
>
> Thanks,
Hi Herbert,
Thanks for the reminder. I have this code in the virtio_net patches which
Linus failed to pull. Will just need to share it with the tun code (maybe a
skb_alloc_large() helper).
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH 3/4] tun: Allow GSO using virtio_net_hdr
2008-06-25 14:30 ` [PATCH 3/4] tun: Allow GSO using virtio_net_hdr Rusty Russell
` (5 preceding siblings ...)
2008-07-24 14:20 ` Herbert Xu
@ 2008-07-24 14:20 ` Herbert Xu
6 siblings, 0 replies; 34+ messages in thread
From: Herbert Xu @ 2008-07-24 14:20 UTC (permalink / raw)
To: Rusty Russell; +Cc: markmc, netdev, Max Krasnyansky, virtualization
On Thu, Jun 26, 2008 at 12:30:37AM +1000, Rusty Russell wrote:
> Add a IFF_VNET_HDR flag. This uses the same ABI as virtio_net (ie. prepending
> struct virtio_net_hdr to packets) to indicate GSO and checksum information.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
I just noticed that we still allocate a linear skb even when GSO
is enabled. Please fix this by allocating page frags where
necessary. Otherwise GSO is only going to work before memory
fragmentation sets in.
IIRC I'd sent out a patch to the virt mailing list with code
that did this.
Thanks,
--
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 [flat|nested] 34+ messages in thread