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

Re: [libvirt] compile fail on FreeBSD



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.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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