On 01/20/2013 11:22 AM, Roman Bogorodskiy wrote: > --- > src/util/virnetdev.c | 20 ++++++++++++++++---- > 1 file changed, 16 insertions(+), 4 deletions(-) > ACK > diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c > index 7ffd3c2..dae267b 100644 > --- a/src/util/virnetdev.c > +++ b/src/util/virnetdev.c > @@ -44,7 +44,7 @@ > > #define VIR_FROM_THIS VIR_FROM_NONE > > -#if defined(HAVE_STRUCT_IFREQ) > +#if defined(HAVE_STRUCT_IFREQ) || defined(__FreeBSD__) > static int virNetDevSetupControlFull(const char *ifname, > struct ifreq *ifr, > int domain, > @@ -81,12 +81,15 @@ static int virNetDevSetupControlFull(const char *ifname, > static int virNetDevSetupControl(const char *ifname, > struct ifreq *ifr) > { > +#if defined(__FreeBSD__) > + return virNetDevSetupControlFull(ifname, ifr, AF_LOCAL, SOCK_DGRAM); > +#else > return virNetDevSetupControlFull(ifname, ifr, AF_PACKET, SOCK_DGRAM); > +#endif > } > #endif > > - > -#if defined(SIOCGIFFLAGS) && defined(HAVE_STRUCT_IFREQ) > +#if defined(SIOCGIFFLAGS) && (defined(HAVE_STRUCT_IFREQ) || defined(__FreeBSD__)) > /** > * virNetDevExists: > * @ifname > @@ -105,7 +108,12 @@ int virNetDevExists(const char *ifname) > return -1; > > if (ioctl(fd, SIOCGIFFLAGS, &ifr)) { > + /* FreeBSD throws ENXIO when interface doesn't exist */ > +#if defined(__FreeBSD__) > + if (errno == ENXIO) > +#else > if (errno == ENODEV) > +#endif > ret = 0; > else > virReportSystemError(errno, > @@ -459,7 +467,7 @@ int virNetDevSetNamespace(const char *ifname, pid_t pidInNs) > return rc; > } > > -#if defined(SIOCSIFNAME) && defined(HAVE_STRUCT_IFREQ) > +#if defined(SIOCSIFNAME) && (defined(HAVE_STRUCT_IFREQ) || defined(__FreeBSD__)) > /** > * virNetDevSetName: > * @ifname: name of device > @@ -478,12 +486,16 @@ int virNetDevSetName(const char* ifname, const char *newifname) > if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0) > return -1; > > +#if defined(__FreeBSD__) > + ifr.ifr_data = newifname; > +#else > if (virStrcpyStatic(ifr.ifr_newname, newifname) == NULL) { > virReportSystemError(ERANGE, > _("Network interface name '%s' is too long"), > newifname); > goto cleanup; > } > +#endif > > if (ioctl(fd, SIOCSIFNAME, &ifr)) { > virReportSystemError(errno, > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list