diff mbox

tap: Use numbered tap/tun devices on all *BSD OS's

Message ID 20130804022040.GA15404@rox.home.comstyle.com
State New
Headers show

Commit Message

Brad Smith Aug. 4, 2013, 2:20 a.m. UTC
The following patch simplifies the *BSD tap/tun code and makes use of numbered
tap/tun interfaces on all *BSD OS's. NetBSD has a patch in their pkgsrc tree
to make use of this feature and DragonFly also supports this as well.

Signed-off-by: Brad Smith <brad@comstyle.com>

Comments

Stefan Hajnoczi Aug. 5, 2013, 11:57 a.m. UTC | #1
On Sat, Aug 03, 2013 at 10:20:41PM -0400, Brad Smith wrote:
> The following patch simplifies the *BSD tap/tun code and makes use of numbered
> tap/tun interfaces on all *BSD OS's. NetBSD has a patch in their pkgsrc tree
> to make use of this feature and DragonFly also supports this as well.
> 
> Signed-off-by: Brad Smith <brad@comstyle.com>

I confirmed that the NetBSD tun driver does use /dev/tap%d by default.
There are not other CONFIG_BSD=y targets listed in ./configure besides
FreeBSD/kFreeBSD, OpenBSD, and Darwin.  Therefore this patch is safe.

Thanks, applied to my net-next tree:
https://github.com/stefanha/qemu/commits/net-next

Stefan
Brad Smith Aug. 8, 2013, 6:12 a.m. UTC | #2
On 05/08/13 7:57 AM, Stefan Hajnoczi wrote:
> On Sat, Aug 03, 2013 at 10:20:41PM -0400, Brad Smith wrote:
>> The following patch simplifies the *BSD tap/tun code and makes use of numbered
>> tap/tun interfaces on all *BSD OS's. NetBSD has a patch in their pkgsrc tree
>> to make use of this feature and DragonFly also supports this as well.
>>
>> Signed-off-by: Brad Smith <brad@comstyle.com>
>
> I confirmed that the NetBSD tun driver does use /dev/tap%d by default.
> There are not other CONFIG_BSD=y targets listed in ./configure besides
> FreeBSD/kFreeBSD, OpenBSD, and Darwin.  Therefore this patch is safe.
>
> Thanks, applied to my net-next tree:
> https://github.com/stefanha/qemu/commits/net-next

And when will this be merged to master?
Stefan Hajnoczi Aug. 8, 2013, 8:15 a.m. UTC | #3
On Thu, Aug 08, 2013 at 02:12:20AM -0400, Brad Smith wrote:
> On 05/08/13 7:57 AM, Stefan Hajnoczi wrote:
> >On Sat, Aug 03, 2013 at 10:20:41PM -0400, Brad Smith wrote:
> >>The following patch simplifies the *BSD tap/tun code and makes use of numbered
> >>tap/tun interfaces on all *BSD OS's. NetBSD has a patch in their pkgsrc tree
> >>to make use of this feature and DragonFly also supports this as well.
> >>
> >>Signed-off-by: Brad Smith <brad@comstyle.com>
> >
> >I confirmed that the NetBSD tun driver does use /dev/tap%d by default.
> >There are not other CONFIG_BSD=y targets listed in ./configure besides
> >FreeBSD/kFreeBSD, OpenBSD, and Darwin.  Therefore this patch is safe.
> >
> >Thanks, applied to my net-next tree:
> >https://github.com/stefanha/qemu/commits/net-next
> 
> And when will this be merged to master?

qemu.git/master will open up on or after 2013-08-15.  I will send a pull
request then.  This is part of the release cycle:

http://qemu-project.org/Planning/1.6

QEMU is currently in hard freeze:

"After the hard feature freeze, the master branch in git is no longer
open for general development. Only bug fixes will be accepted until the
next release."
http://qemu-project.org/Planning/HardFeatureFreeze

Stefan
diff mbox

Patch

diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index f61d580..90f8a02 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -44,8 +44,6 @@  int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
     struct stat s;
 #endif
 
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
-    defined(__OpenBSD__) || defined(__APPLE__)
     /* if no ifname is given, always start the search from tap0/tun0. */
     int i;
     char dname[100];
@@ -76,15 +74,6 @@  int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
                    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: %s\n",
-            strerror(errno));
-        return -1;
-    }
-#endif
 
 #ifdef TAPGIFNAME
     if (ioctl(fd, TAPGIFNAME, (void *)&ifr) < 0) {