diff mbox

tap-bsd: OpenBSD uses tap(4) now

Message ID 20160926015829.GA71916@humpty.home.comstyle.com
State New
Headers show

Commit Message

Brad Smith Sept. 26, 2016, 1:58 a.m. UTC
Update the tap-bsd code now that OpenBSD uses tap(4).

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

Comments

Thomas Huth Sept. 26, 2016, 10:35 a.m. UTC | #1
On 26.09.2016 03:58, Brad Smith wrote:
> Update the tap-bsd code now that OpenBSD uses tap(4).
> 
> Signed-off-by: Brad Smith <brad@comstyle.com>
> 
> 
> diff --git a/net/tap-bsd.c b/net/tap-bsd.c
> index c506ac3..8d0f049 100644
> --- a/net/tap-bsd.c
> +++ b/net/tap-bsd.c
> @@ -55,11 +55,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
>          if (*ifname) {
>              snprintf(dname, sizeof dname, "/dev/%s", ifname);
>          } else {
> -#if defined(__OpenBSD__)
> -            snprintf(dname, sizeof dname, "/dev/tun%d", i);
> -#else
>              snprintf(dname, sizeof dname, "/dev/tap%d", i);
> -#endif
>          }
>          TFR(fd = open(dname, O_RDWR));
>          if (fd >= 0) {

Looking at http://man.openbsd.org/tap.4 it seems like OpenBSD is indeed
supporting /dev/tap nowadays, so:

Reviewed-by: Thomas Huth <thuth@redhat.com>


PS: Please make sure to CC: the QEMU subsystem maintainer (see
MAINTAINERS or use scripts/get_maintainer.pl) to make sure that your
patches do not get lost in the high traffic of the qemu-devel mailing list.
Jason Wang Sept. 29, 2016, 1:41 a.m. UTC | #2
On 2016年09月26日 18:35, Thomas Huth wrote:
> On 26.09.2016 03:58, Brad Smith wrote:
>> Update the tap-bsd code now that OpenBSD uses tap(4).
>>
>> Signed-off-by: Brad Smith <brad@comstyle.com>
>>
>>
>> diff --git a/net/tap-bsd.c b/net/tap-bsd.c
>> index c506ac3..8d0f049 100644
>> --- a/net/tap-bsd.c
>> +++ b/net/tap-bsd.c
>> @@ -55,11 +55,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
>>           if (*ifname) {
>>               snprintf(dname, sizeof dname, "/dev/%s", ifname);
>>           } else {
>> -#if defined(__OpenBSD__)
>> -            snprintf(dname, sizeof dname, "/dev/tun%d", i);
>> -#else
>>               snprintf(dname, sizeof dname, "/dev/tap%d", i);
>> -#endif
>>           }
>>           TFR(fd = open(dname, O_RDWR));
>>           if (fd >= 0) {
> Looking at http://man.openbsd.org/tap.4 it seems like OpenBSD is indeed
> supporting /dev/tap nowadays, so:

A question is what happens if we are using old version of OpenBSD which 
does not have tap?

>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
>
>
> PS: Please make sure to CC: the QEMU subsystem maintainer (see
> MAINTAINERS or use scripts/get_maintainer.pl) to make sure that your
> patches do not get lost in the high traffic of the qemu-devel mailing list.
>
>
Thomas Huth Sept. 29, 2016, 4:55 a.m. UTC | #3
On 29.09.2016 03:41, Jason Wang wrote:
> 
> 
> On 2016年09月26日 18:35, Thomas Huth wrote:
>> On 26.09.2016 03:58, Brad Smith wrote:
>>> Update the tap-bsd code now that OpenBSD uses tap(4).
>>>
>>> Signed-off-by: Brad Smith <brad@comstyle.com>
>>>
>>>
>>> diff --git a/net/tap-bsd.c b/net/tap-bsd.c
>>> index c506ac3..8d0f049 100644
>>> --- a/net/tap-bsd.c
>>> +++ b/net/tap-bsd.c
>>> @@ -55,11 +55,7 @@ int tap_open(char *ifname, int ifname_size, int
>>> *vnet_hdr,
>>>           if (*ifname) {
>>>               snprintf(dname, sizeof dname, "/dev/%s", ifname);
>>>           } else {
>>> -#if defined(__OpenBSD__)
>>> -            snprintf(dname, sizeof dname, "/dev/tun%d", i);
>>> -#else
>>>               snprintf(dname, sizeof dname, "/dev/tap%d", i);
>>> -#endif
>>>           }
>>>           TFR(fd = open(dname, O_RDWR));
>>>           if (fd >= 0) {
>> Looking at http://man.openbsd.org/tap.4 it seems like OpenBSD is indeed
>> supporting /dev/tap nowadays, so:
> 
> A question is what happens if we are using old version of OpenBSD which
> does not have tap?

You can still specify the ifname manually, can't you?

 Thomas
Jason Wang Sept. 30, 2016, 2:53 a.m. UTC | #4
On 2016年09月29日 12:55, Thomas Huth wrote:
> On 29.09.2016 03:41, Jason Wang wrote:
>>
>> On 2016年09月26日 18:35, Thomas Huth wrote:
>>> On 26.09.2016 03:58, Brad Smith wrote:
>>>> Update the tap-bsd code now that OpenBSD uses tap(4).
>>>>
>>>> Signed-off-by: Brad Smith <brad@comstyle.com>
>>>>
>>>>
>>>> diff --git a/net/tap-bsd.c b/net/tap-bsd.c
>>>> index c506ac3..8d0f049 100644
>>>> --- a/net/tap-bsd.c
>>>> +++ b/net/tap-bsd.c
>>>> @@ -55,11 +55,7 @@ int tap_open(char *ifname, int ifname_size, int
>>>> *vnet_hdr,
>>>>            if (*ifname) {
>>>>                snprintf(dname, sizeof dname, "/dev/%s", ifname);
>>>>            } else {
>>>> -#if defined(__OpenBSD__)
>>>> -            snprintf(dname, sizeof dname, "/dev/tun%d", i);
>>>> -#else
>>>>                snprintf(dname, sizeof dname, "/dev/tap%d", i);
>>>> -#endif
>>>>            }
>>>>            TFR(fd = open(dname, O_RDWR));
>>>>            if (fd >= 0) {
>>> Looking at http://man.openbsd.org/tap.4 it seems like OpenBSD is indeed
>>> supporting /dev/tap nowadays, so:
>> A question is what happens if we are using old version of OpenBSD which
>> does not have tap?
> You can still specify the ifname manually, can't you?
>
>   Thomas
>

Yes, but the codes were for cases that ifname were not given.

Thanks
diff mbox

Patch

diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index c506ac3..8d0f049 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -55,11 +55,7 @@  int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
         if (*ifname) {
             snprintf(dname, sizeof dname, "/dev/%s", ifname);
         } else {
-#if defined(__OpenBSD__)
-            snprintf(dname, sizeof dname, "/dev/tun%d", i);
-#else
             snprintf(dname, sizeof dname, "/dev/tap%d", i);
-#endif
         }
         TFR(fd = open(dname, O_RDWR));
         if (fd >= 0) {