qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Christoph Egger <Christoph.Egger@amd.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] fix network interface tap backend
Date: Sat, 23 Jul 2011 11:17:13 -0500	[thread overview]
Message-ID: <4E2AF409.5010909@codemonkey.ws> (raw)
In-Reply-To: <4DFB16B2.7020302@amd.com>

On 06/17/2011 03:56 AM, Christoph Egger wrote:
>
> Fix network interface tap backend work on NetBSD.
> It uses an ioctl to get the tap name.
>
>  From Manuel Bouyer <bouyer@netbsd.org>
> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
>
> diff --git a/net/tap-bsd.c b/net/tap-bsd.c
> index 2f3efde..577aafe 100644
> --- a/net/tap-bsd.c
> +++ b/net/tap-bsd.c
> @@ -28,6 +28,8 @@
> #include "qemu-error.h"
>
> #ifdef __NetBSD__
> +#include <sys/ioctl.h>

Your mailer munged this patch.

Regards,

Anthony Liguori

> +#include <net/if.h>
> #include <net/if_tap.h>
> #endif
>
> @@ -40,8 +42,12 @@
> int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int
> vnet_hdr_required)
> {
> int fd;
> +#ifdef TAPGIFNAME
> + struct ifreq ifr;
> +#else
> char *dev;
> struct stat s;
> +#endif
>
> #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) ||
> defined(__OpenBSD__)
> /* if no ifname is given, always start the search from tap0/tun0. */
> @@ -77,14 +83,30 @@ int tap_open(char *ifname, int ifname_size, int
> *vnet_hdr, int vnet_hdr_required
> #else
> TFR(fd = open("/dev/tap", O_RDWR));
> if (fd < 0) {
> - fprintf(stderr, "warning: could not open /dev/tap: no virtual network
> emulation\n");
> + fprintf(stderr,
> + "warning: could not open /dev/tap: no virtual network emulation: %s\n",
> + strerror(errno));
> return -1;
> }
> #endif
>
> - fstat(fd, &s);
> +#ifdef TAPGIFNAME
> + if (ioctl(fd, TAPGIFNAME, (void *)&ifr) < 0) {
> + fprintf(stderr, "warning: could not get tap name: %s\n",
> + strerror(errno));
> + return -1;
> + }
> + pstrcpy(ifname, ifname_size, ifr.ifr_name);
> +#else
> + if (fstat(fd, &s) < 0) {
> + fprintf(stderr,
> + "warning: could not stat /dev/tap: no virtual network emulation: %s\n",
> + strerror(errno));
> + return -1;
> + }
> dev = devname(s.st_rdev, S_IFCHR);
> pstrcpy(ifname, ifname_size, dev);
> +#endif
>
> if (*vnet_hdr) {
> /* BSD doesn't have IFF_VNET_HDR */
>
>

  reply	other threads:[~2011-07-23 16:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-17  8:56 [Qemu-devel] [PATCH] fix network interface tap backend Christoph Egger
2011-07-23 16:17 ` Anthony Liguori [this message]
2011-07-25  9:03   ` Christoph Egger
2011-08-07  9:54     ` Blue Swirl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E2AF409.5010909@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=Christoph.Egger@amd.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).