Re: compile fail on FreeBSD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 15, 2011 at 03:24:11PM -0700, Eric Blake wrote:
> On 11/15/2011 04:08 AM, Daniel P. Berrange wrote:
> > On Fri, Nov 11, 2011 at 05:31:14PM -0700, Eric Blake wrote:
> >> This failure on FreeBSD 8.2 popped up this week, and I suspect Dan's
> >> virnetdev refactoring, but haven't had time to further investigate and
> >> fix it:
> >>
> >> util/virnetdev.c: In function 'virNetDevExists':
> >> util/virnetdev.c:93: error: storage size of 'ifr' isn't known
> >> util/virnetdev.c:95: warning: implicit declaration of function
> >> 'virNetDevSetupControl'
> >>
> >> and so on.  Probably some conditional compilation going wrong when on a
> >> non-Linux machine.
> > 
> > This code is protected by a
> > 
> > #ifdef HAVE_NET_IF_H
> > 
> > 
> > So if BSD's net/if.h does not provide any 'struct ifreq' then we need to
> > fix things.
> 
> <net/if.h> is standardized by POSIX, but 'struct ifreq' is not (the only
> portable struct in that header is 'struct if_nameindex').
> 
> > 
> > Does anyone know if the 'struct ifreq'  / SIOCGIFHWADDR / SIOCGIFMTU / etc
> > ioctl() stuff is entirely Linux specific, or is it semi portable to other
> > UNIX ?  
> 
> Solaris 10 has struct ifreq, also provided by <net/if.h>, but with
> different fields:
> 
> Linux:
> struct ifreq
>   {
>     union
>       {
> 	char ifrn_name[16];
>       } ifr_ifrn;
>     union
>       {
> 	struct sockaddr ifru_addr;
> 	struct sockaddr ifru_dstaddr;
> 	struct sockaddr ifru_broadaddr;
> 	struct sockaddr ifru_netmask;
> 	struct sockaddr ifru_hwaddr;
> 	short int ifru_flags;
> 	int ifru_ivalue;
> 	int ifru_mtu;
> 	struct ifmap ifru_map;
> 	char ifru_slave[16];
> 	char ifru_newname[16];
> 	__caddr_t ifru_data;
>       } ifr_ifru;
>   };
> 
> Solaris:
> struct ifreq {
> 
>  char ifr_name[16];
>  union {
>   struct sockaddr ifru_addr;
>   struct sockaddr ifru_dstaddr;
>   char ifru_oname[16];
>   struct sockaddr ifru_broadaddr;
>   int ifru_index;
>   short ifru_flags;
>   int ifru_metric;
>   char ifru_data[1];
>   char ifru_enaddr[6];
>   int if_muxid[2];
>   struct ifr_ppaflags {
>    short ifrup_flags;
>    short ifrup_filler;
>    uint_t ifrup_ppa;
>   } ifru_ppaflags;
>   struct ifr_dnld_reqs {
>    uint32_t v_addr;
>    uint32_t m_addr;
>    uint32_t ex_addr;
>    uint32_t size;
>   } ifru_dnld_req;
>   struct ifr_fddi_stats {
>    uint32_t stat_size;
>    uint32_t fddi_stats;
>   } ifru_fddi_stat;
>   struct ifr_netmapents {
>    uint32_t map_ent_size,
>     entry_number;
>    uint32_t fddi_map_ent;
>   } ifru_netmapent;
>   struct ifr_fddi_gen_struct {
>    uint32_t ifru_fddi_gioctl;
>    uint32_t ifru_fddi_gaddr;
>   } ifru_fddi_gstruct;
>  } ifr_ifru;
> };
> 
> ifr_name is common between the two, but I'm thinking the ioctl's are
> going to be Linux-specific, so we're better off conditionalizing the
> code to not even attempt use of 'struct ifreq' outside Linux.

Ok, lets just change it to #ifdef __linux__ then, and if someone wants
to port it to Solaris / BSD they can figure out the better approach :-)

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]