Patchwork [1/3] Add support for OpenBSD to QEMU's tap driver.

login
register
mail settings
Submitter Brad
Date Dec. 21, 2010, 2:23 a.m.
Message ID <20101221022314.GA9844@rox.home.comstyle.com>
Download mbox | patch
Permalink /patch/76253/
State New
Headers show

Comments

Brad - Dec. 21, 2010, 2:23 a.m.
Signed-off-by: Brad Smith <brad@comstyle.com>

---
 net/tap-bsd.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
Blue Swirl - Dec. 21, 2010, 9:17 p.m.
Thanks, applied all three.

On Tue, Dec 21, 2010 at 2:23 AM, Brad <brad@comstyle.com> wrote:
> Signed-off-by: Brad Smith <brad@comstyle.com>
>
> ---
>  net/tap-bsd.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/tap-bsd.c b/net/tap-bsd.c
> index efccfe0..2f3efde 100644
> --- a/net/tap-bsd.c
> +++ b/net/tap-bsd.c
> @@ -43,8 +43,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
>     char *dev;
>     struct stat s;
>
> -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
> -    /* if no ifname is given, always start the search from tap0. */
> +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
> +    /* if no ifname is given, always start the search from tap0/tun0. */
>     int i;
>     char dname[100];
>
> @@ -52,7 +52,11 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
>         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) {
> --
> 1.7.3.2
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>
>

Patch

diff --git a/net/tap-bsd.c b/net/tap-bsd.c
index efccfe0..2f3efde 100644
--- a/net/tap-bsd.c
+++ b/net/tap-bsd.c
@@ -43,8 +43,8 @@  int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
     char *dev;
     struct stat s;
 
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-    /* if no ifname is given, always start the search from tap0. */
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+    /* if no ifname is given, always start the search from tap0/tun0. */
     int i;
     char dname[100];
 
@@ -52,7 +52,11 @@  int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
         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) {