* [Qemu-devel] [PATCH] tap: reset vnet header size on open
@ 2012-11-12 7:19 Michael S. Tsirkin
2012-11-12 12:23 ` Stefan Hajnoczi
0 siblings, 1 reply; 2+ messages in thread
From: Michael S. Tsirkin @ 2012-11-12 7:19 UTC (permalink / raw)
To: qemu-devel, agraf; +Cc: Anthony Liguori, Stefan Hajnoczi
For tap, we currently assume the vnet header size is 10
(the default value) but that might not be the case
if tap is persistent and has been used by qemu previously.
To fix, set vnet header size correctly on open.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
This fixes the issue reported by Alexander Graf on the kvm forum.
Alexander, could you confirm please?
Thanks,
net/tap-linux.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/tap-linux.c b/net/tap-linux.c
index c6521be..3eaedc4 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -39,6 +39,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
{
struct ifreq ifr;
int fd, ret;
+ int len = sizeof(struct virtio_net_hdr);
TFR(fd = open(PATH_NET_TUN, O_RDWR));
if (fd < 0) {
@@ -65,6 +66,13 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
close(fd);
return -1;
}
+ /*
+ * Make sure vnet header size has the default value: for a persistent
+ * tap it might have been modified e.g. by another instance of qemu.
+ * Ignore errors since old kernels do not support this ioctl: in this
+ * case the header size implicitly has the correct value.
+ */
+ ioctl(fd, TUNSETVNETHDRSZ, &len);
}
if (ifname[0] != '\0')
--
MST
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] tap: reset vnet header size on open
2012-11-12 7:19 [Qemu-devel] [PATCH] tap: reset vnet header size on open Michael S. Tsirkin
@ 2012-11-12 12:23 ` Stefan Hajnoczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2012-11-12 12:23 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Anthony Liguori, qemu-devel, agraf
On Mon, Nov 12, 2012 at 09:19:18AM +0200, Michael S. Tsirkin wrote:
> For tap, we currently assume the vnet header size is 10
> (the default value) but that might not be the case
> if tap is persistent and has been used by qemu previously.
> To fix, set vnet header size correctly on open.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> This fixes the issue reported by Alexander Graf on the kvm forum.
> Alexander, could you confirm please?
> Thanks,
>
> net/tap-linux.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/net/tap-linux.c b/net/tap-linux.c
> index c6521be..3eaedc4 100644
> --- a/net/tap-linux.c
> +++ b/net/tap-linux.c
> @@ -39,6 +39,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
> {
> struct ifreq ifr;
> int fd, ret;
> + int len = sizeof(struct virtio_net_hdr);
We probably want the same behavior in the tap,fd= codepath. How about a
call to tap_set_vnet_hdr_len() in net_init_tap() instead?
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-12 12:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-12 7:19 [Qemu-devel] [PATCH] tap: reset vnet header size on open Michael S. Tsirkin
2012-11-12 12:23 ` Stefan Hajnoczi
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).