Message ID | 1400860669-21593-3-git-send-email-roger.pau@citrix.com |
---|---|
State | New |
Headers | show |
On Fri, May 23, 2014 at 05:57:48PM +0200, Roger Pau Monne wrote: > The current behaviour of tap_open for BSD systems differ greatly from > it's Linux counterpart. Since FreeBSD supports interface renaming and > tap device cloning by opening /dev/tap, implement a FreeBSD specific > version of tap_open that behaves like it's Linux counterpart. > > This is specially important for toolstacks that use Qemu (like Xen > libxl), in order to have a unified behaviour across suported > platforms. > > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> > Cc: xen-devel@lists.xenproject.org > Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > Cc: Anthony Liguori <aliguori@us.ibm.com> > Cc: Stefan Hajnoczi <stefanha@redhat.com> > --- > net/tap-bsd.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 files changed, 69 insertions(+), 1 deletions(-) Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
On 27/05/14 15:29, Stefan Hajnoczi wrote: > On Fri, May 23, 2014 at 05:57:48PM +0200, Roger Pau Monne wrote: >> The current behaviour of tap_open for BSD systems differ greatly from >> it's Linux counterpart. Since FreeBSD supports interface renaming and >> tap device cloning by opening /dev/tap, implement a FreeBSD specific >> version of tap_open that behaves like it's Linux counterpart. >> >> This is specially important for toolstacks that use Qemu (like Xen >> libxl), in order to have a unified behaviour across suported >> platforms. >> >> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> >> Cc: xen-devel@lists.xenproject.org >> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> >> Cc: Anthony Liguori <aliguori@us.ibm.com> >> Cc: Stefan Hajnoczi <stefanha@redhat.com> >> --- >> net/tap-bsd.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- >> 1 files changed, 69 insertions(+), 1 deletions(-) > > Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> I still don't see this committed to the repository, should I ping someone? Thanks, Roger.
On Tue, 22 Jul 2014, Roger Pau Monné wrote: > On 27/05/14 15:29, Stefan Hajnoczi wrote: > > On Fri, May 23, 2014 at 05:57:48PM +0200, Roger Pau Monne wrote: > >> The current behaviour of tap_open for BSD systems differ greatly from > >> it's Linux counterpart. Since FreeBSD supports interface renaming and > >> tap device cloning by opening /dev/tap, implement a FreeBSD specific > >> version of tap_open that behaves like it's Linux counterpart. > >> > >> This is specially important for toolstacks that use Qemu (like Xen > >> libxl), in order to have a unified behaviour across suported > >> platforms. > >> > >> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> > >> Cc: xen-devel@lists.xenproject.org > >> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > >> Cc: Anthony Liguori <aliguori@us.ibm.com> > >> Cc: Stefan Hajnoczi <stefanha@redhat.com> > >> --- > >> net/tap-bsd.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > >> 1 files changed, 69 insertions(+), 1 deletions(-) > > > > Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> > > I still don't see this committed to the repository, should I ping someone? I was assuming that this patch would go via some other tree. But if Stefan is OK I could pick it up and submit a pull request for both patch 1 and 2 of this series.
On Tue, Jul 22, 2014 at 01:26:00PM +0100, Stefano Stabellini wrote: > On Tue, 22 Jul 2014, Roger Pau Monné wrote: > > On 27/05/14 15:29, Stefan Hajnoczi wrote: > > > On Fri, May 23, 2014 at 05:57:48PM +0200, Roger Pau Monne wrote: > > >> The current behaviour of tap_open for BSD systems differ greatly from > > >> it's Linux counterpart. Since FreeBSD supports interface renaming and > > >> tap device cloning by opening /dev/tap, implement a FreeBSD specific > > >> version of tap_open that behaves like it's Linux counterpart. > > >> > > >> This is specially important for toolstacks that use Qemu (like Xen > > >> libxl), in order to have a unified behaviour across suported > > >> platforms. > > >> > > >> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> > > >> Cc: xen-devel@lists.xenproject.org > > >> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > > >> Cc: Anthony Liguori <aliguori@us.ibm.com> > > >> Cc: Stefan Hajnoczi <stefanha@redhat.com> > > >> --- > > >> net/tap-bsd.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > > >> 1 files changed, 69 insertions(+), 1 deletions(-) > > > > > > Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> > > > > I still don't see this committed to the repository, should I ping someone? > > I was assuming that this patch would go via some other tree. But if > Stefan is OK I could pick it up and submit a pull request for both patch > 1 and 2 of this series. I'm fine with that. I only reviewed this patch since it affects the net subsystem and left the series as a whole for someone to merge. Stefan
On 22/07/14 14:26, Stefano Stabellini wrote: > On Tue, 22 Jul 2014, Roger Pau Monné wrote: >> On 27/05/14 15:29, Stefan Hajnoczi wrote: >>> On Fri, May 23, 2014 at 05:57:48PM +0200, Roger Pau Monne wrote: >>>> The current behaviour of tap_open for BSD systems differ greatly from >>>> it's Linux counterpart. Since FreeBSD supports interface renaming and >>>> tap device cloning by opening /dev/tap, implement a FreeBSD specific >>>> version of tap_open that behaves like it's Linux counterpart. >>>> >>>> This is specially important for toolstacks that use Qemu (like Xen >>>> libxl), in order to have a unified behaviour across suported >>>> platforms. >>>> >>>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> >>>> Cc: xen-devel@lists.xenproject.org >>>> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> >>>> Cc: Anthony Liguori <aliguori@us.ibm.com> >>>> Cc: Stefan Hajnoczi <stefanha@redhat.com> >>>> --- >>>> net/tap-bsd.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- >>>> 1 files changed, 69 insertions(+), 1 deletions(-) >>> >>> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> >> >> I still don't see this committed to the repository, should I ping someone? > > I was assuming that this patch would go via some other tree. But if > Stefan is OK I could pick it up and submit a pull request for both patch > 1 and 2 of this series. Would you do the backport of those three patches (one is already committed as e02bc6) to the qemu-xen repo at the same time, or would you like me to remind you about this in a month or so? I would really like to have all this patches in Xen 4.5 if possible. Thanks, Roger.
On Wed, 23 Jul 2014, Roger Pau Monné wrote: > On 22/07/14 14:26, Stefano Stabellini wrote: > > On Tue, 22 Jul 2014, Roger Pau Monné wrote: > >> On 27/05/14 15:29, Stefan Hajnoczi wrote: > >>> On Fri, May 23, 2014 at 05:57:48PM +0200, Roger Pau Monne wrote: > >>>> The current behaviour of tap_open for BSD systems differ greatly from > >>>> it's Linux counterpart. Since FreeBSD supports interface renaming and > >>>> tap device cloning by opening /dev/tap, implement a FreeBSD specific > >>>> version of tap_open that behaves like it's Linux counterpart. > >>>> > >>>> This is specially important for toolstacks that use Qemu (like Xen > >>>> libxl), in order to have a unified behaviour across suported > >>>> platforms. > >>>> > >>>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> > >>>> Cc: xen-devel@lists.xenproject.org > >>>> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > >>>> Cc: Anthony Liguori <aliguori@us.ibm.com> > >>>> Cc: Stefan Hajnoczi <stefanha@redhat.com> > >>>> --- > >>>> net/tap-bsd.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > >>>> 1 files changed, 69 insertions(+), 1 deletions(-) > >>> > >>> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> > >> > >> I still don't see this committed to the repository, should I ping someone? > > > > I was assuming that this patch would go via some other tree. But if > > Stefan is OK I could pick it up and submit a pull request for both patch > > 1 and 2 of this series. > > Would you do the backport of those three patches (one is already > committed as e02bc6) to the qemu-xen repo at the same time, or would you > like me to remind you about this in a month or so? > > I would really like to have all this patches in Xen 4.5 if possible. I should remember when I'll send a pull request (when 2.1 will be out). But please remind me if I'll forget.
diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 90f8a02..bf91bd0 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -27,12 +27,13 @@ #include "sysemu/sysemu.h" #include "qemu/error-report.h" -#ifdef __NetBSD__ +#if defined(__NetBSD__) || defined(__FreeBSD__) #include <sys/ioctl.h> #include <net/if.h> #include <net/if_tap.h> #endif +#ifndef __FreeBSD__ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required, int mq_required) { @@ -108,6 +109,73 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, return fd; } +#else /* __FreeBSD__ */ + +#define PATH_NET_TAP "/dev/tap" + +int tap_open(char *ifname, int ifname_size, int *vnet_hdr, + int vnet_hdr_required, int mq_required) +{ + int fd, s, ret; + struct ifreq ifr; + + TFR(fd = open(PATH_NET_TAP, O_RDWR)); + if (fd < 0) { + error_report("could not open %s: %s", PATH_NET_TAP, strerror(errno)); + return -1; + } + + memset(&ifr, 0, sizeof(ifr)); + + ret = ioctl(fd, TAPGIFNAME, (void *)&ifr); + if (ret < 0) { + error_report("could not get tap interface name"); + goto error; + } + + if (ifname[0] != '\0') { + /* User requested the interface to have a specific name */ + s = socket(AF_LOCAL, SOCK_DGRAM, 0); + if (s < 0) { + error_report("could not open socket to set interface name"); + goto error; + } + ifr.ifr_data = ifname; + ret = ioctl(s, SIOCSIFNAME, (void *)&ifr); + close(s); + if (ret < 0) { + error_report("could not set tap interface name"); + goto error; + } + } else { + pstrcpy(ifname, ifname_size, ifr.ifr_name); + } + + if (*vnet_hdr) { + /* BSD doesn't have IFF_VNET_HDR */ + *vnet_hdr = 0; + + if (vnet_hdr_required && !*vnet_hdr) { + error_report("vnet_hdr=1 requested, but no kernel " + "support for IFF_VNET_HDR available"); + goto error; + } + } + if (mq_required) { + error_report("mq_required requested, but not kernel support" + "for IFF_MULTI_QUEUE available"); + goto error; + } + + fcntl(fd, F_SETFL, O_NONBLOCK); + return fd; + +error: + close(fd); + return -1; +} +#endif /* __FreeBSD__ */ + int tap_set_sndbuf(int fd, const NetdevTapOptions *tap) { return 0;
The current behaviour of tap_open for BSD systems differ greatly from it's Linux counterpart. Since FreeBSD supports interface renaming and tap device cloning by opening /dev/tap, implement a FreeBSD specific version of tap_open that behaves like it's Linux counterpart. This is specially important for toolstacks that use Qemu (like Xen libxl), in order to have a unified behaviour across suported platforms. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Cc: xen-devel@lists.xenproject.org Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Cc: Anthony Liguori <aliguori@us.ibm.com> Cc: Stefan Hajnoczi <stefanha@redhat.com> --- net/tap-bsd.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 69 insertions(+), 1 deletions(-)