aboutsummaryrefslogtreecommitdiff
path: root/net/tap-linux.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-12-17 18:17:08 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-12-17 18:56:22 +0100
commit6f991980a5e96f93a9f676959df2dcba665665ef (patch)
treee6f46c0531e8a05b22be4c5adf7f7fb31afa6d13 /net/tap-linux.c
parenta8a826a3c3b8c8a1c4def0e9e22b46e78e6163a0 (diff)
parent1dd3a74d2ee2d873cde0b390b536e45420b3fe05 (diff)
Merge commit '1dd3a74d2ee2d873cde0b390b536e45420b3fe05' into HEAD
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'net/tap-linux.c')
-rw-r--r--net/tap-linux.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/tap-linux.c b/net/tap-linux.c
index c6521bec34..3eaedc40ad 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')