Patchwork [1/3] Fix tap breakage on BSD hosts (no IFF_VNET_HDR)

login
register
mail settings
Submitter Juergen Lock
Date Nov. 20, 2009, 10:19 p.m.
Message ID <20091120221953.GA16319@triton8.kn-bremen.de>
Download mbox | patch
Permalink /patch/38944/
State New
Headers show

Comments

Juergen Lock - Nov. 20, 2009, 10:19 p.m.
net/tap-bsd.c was assuming IFF_VNET_HDR was always available, which
I think isn't true on any BSD.

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
Juergen Lock - Nov. 20, 2009, 10:58 p.m.
Hi!

 I made another experimental FreeBSD qemu git snapshot port update
(see other mail), and came up with these patches when getting tap back
to working order again:

1. Fix tap breakage on BSD hosts (no IFF_VNET_HDR)
2. Avoid segfault on net_tap_init() failure
3. tap-bsd: handle ifname on FreeBSD hosts

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>

Patch

--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -87,6 +87,17 @@  int tap_open(char *ifname, int ifname_si
     dev = devname(s.st_rdev, S_IFCHR);
     pstrcpy(ifname, ifname_size, dev);
 
+    if (*vnet_hdr) {
+        /* BSD doesn't have IFF_VNET_HDR */
+        *vnet_hdr = 0;
+
+        if (vnet_hdr_required && !*vnet_hdr) {
+            qemu_error("vnet_hdr=1 requested, but no kernel "
+                       "support for IFF_VNET_HDR available");
+            close(fd);
+            return -1;
+        }
+    }
     fcntl(fd, F_SETFL, O_NONBLOCK);
     return fd;
 }