All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/3] Fix tap breakage on BSD hosts (no IFF_VNET_HDR)
@ 2009-11-20 22:19 Juergen Lock
  2009-11-20 22:23 ` [Qemu-devel] [PATCH 2/3] Avoid segfault on net_tap_init() failure Juergen Lock
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Juergen Lock @ 2009-11-20 22:19 UTC (permalink / raw)
  To: qemu-devel

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>

--- 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;
 }

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

* [Qemu-devel] [PATCH 2/3] Avoid segfault on net_tap_init() failure
  2009-11-20 22:19 [Qemu-devel] [PATCH 1/3] Fix tap breakage on BSD hosts (no IFF_VNET_HDR) Juergen Lock
@ 2009-11-20 22:23 ` Juergen Lock
  2009-11-20 22:31 ` [Qemu-devel] [PATCH 3/3] tap-bsd: handle ifname on FreeBSD hosts Juergen Lock
  2009-11-20 22:58 ` [Qemu-devel] [PATCH 0/3] Misc tap fixes found on FreeBSD Juergen Lock
  2 siblings, 0 replies; 4+ messages in thread
From: Juergen Lock @ 2009-11-20 22:23 UTC (permalink / raw)
  To: qemu-devel

Check for fd == -1 there.

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

--- a/net/tap.c
+++ b/net/tap.c
@@ -400,6 +400,9 @@ int net_init_tap(QemuOpts *opts, Monitor
         }
 
         fd = net_tap_init(opts, &vnet_hdr);
+        if (fd == -1) {
+            return -1;
+        }
     }
 
     s = net_tap_fd_init(vlan, "tap", name, fd, vnet_hdr);

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

* [Qemu-devel] [PATCH 3/3] tap-bsd: handle ifname on FreeBSD hosts
  2009-11-20 22:19 [Qemu-devel] [PATCH 1/3] Fix tap breakage on BSD hosts (no IFF_VNET_HDR) Juergen Lock
  2009-11-20 22:23 ` [Qemu-devel] [PATCH 2/3] Avoid segfault on net_tap_init() failure Juergen Lock
@ 2009-11-20 22:31 ` Juergen Lock
  2009-11-20 22:58 ` [Qemu-devel] [PATCH 0/3] Misc tap fixes found on FreeBSD Juergen Lock
  2 siblings, 0 replies; 4+ messages in thread
From: Juergen Lock @ 2009-11-20 22:31 UTC (permalink / raw)
  To: qemu-devel

Handle ifname on FreeBSD hosts; if no ifname is given, always start
the search from tap0.  (Simplified/cleaned up version of what has been
in the FreeBSD ports for a long time.)

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

--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -49,11 +49,39 @@ int tap_open(char *ifname, int ifname_si
     char *dev;
     struct stat s;
 
+#ifdef __FreeBSD__
+    /* if no ifname is given, always start the search from tap0. */
+    int i;
+    char dname[100];
+
+    for (i = 0; i < 10; i++) {
+        if (*ifname) {
+            snprintf(dname, sizeof dname, "/dev/%s", ifname);
+        } else {
+            snprintf(dname, sizeof dname, "/dev/tap%d", i);
+        }
+        TFR(fd = open(dname, O_RDWR));
+        if (fd >= 0) {
+            break;
+        }
+        else if (errno == ENXIO || errno == ENOENT) {
+            break;
+        }
+        if (*ifname) {
+            break;
+        }
+    }
+    if (fd < 0) {
+        qemu_error("warning: could not open %s (%s): no virtual network emulation\n", dname, strerror(errno));
+        return -1;
+    }
+#else
     TFR(fd = open("/dev/tap", O_RDWR));
     if (fd < 0) {
         fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
         return -1;
     }
+#endif
 
     fstat(fd, &s);
     dev = devname(s.st_rdev, S_IFCHR);

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

* [Qemu-devel] [PATCH 0/3] Misc tap fixes found on FreeBSD
  2009-11-20 22:19 [Qemu-devel] [PATCH 1/3] Fix tap breakage on BSD hosts (no IFF_VNET_HDR) Juergen Lock
  2009-11-20 22:23 ` [Qemu-devel] [PATCH 2/3] Avoid segfault on net_tap_init() failure Juergen Lock
  2009-11-20 22:31 ` [Qemu-devel] [PATCH 3/3] tap-bsd: handle ifname on FreeBSD hosts Juergen Lock
@ 2009-11-20 22:58 ` Juergen Lock
  2 siblings, 0 replies; 4+ messages in thread
From: Juergen Lock @ 2009-11-20 22:58 UTC (permalink / raw)
  To: qemu-devel

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>

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

end of thread, other threads:[~2009-11-21  0:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-20 22:19 [Qemu-devel] [PATCH 1/3] Fix tap breakage on BSD hosts (no IFF_VNET_HDR) Juergen Lock
2009-11-20 22:23 ` [Qemu-devel] [PATCH 2/3] Avoid segfault on net_tap_init() failure Juergen Lock
2009-11-20 22:31 ` [Qemu-devel] [PATCH 3/3] tap-bsd: handle ifname on FreeBSD hosts Juergen Lock
2009-11-20 22:58 ` [Qemu-devel] [PATCH 0/3] Misc tap fixes found on FreeBSD Juergen Lock

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.