[libvirt] [PATCH] portability: handle ifreq differences in virnetdev

Eric Blake eblake at redhat.com
Tue Apr 30 15:22:39 UTC 2013


On 04/29/2013 11:48 AM, Eric Blake wrote:
> On 04/27/2013 09:50 AM, Roman Bogorodskiy wrote:
>> FreeBSD (and maybe other BSDs) have different member
>> names in struct ifreq when compared to Linux, such as:
>>
>>  - uses ifr_data instead of ifr_newname for setting
>>    interface names
>>  - uses ifr_index instead of ifr_ifindex for interface
>>    index
>>
>> Also, add a check for SIOCGIFHWADDR for virNetDevValidateConfig().
>>
>> Use AF_LOCAL if AF_PACKET is not available.
>> ---
> 
> Overall, looks sane; I'll probably apply the touchups mentioned and push
> later today after testing on my own FreeBSD VM.

With this patch, I'm getting a compile failure on FreeBSD 8.2:

util/virnetdev.c:667: error: 'struct ifreq' has no member named
'ifr_ifindex'

Looking further, I see <net/if.h> has:

struct ifreq {
...
 union {
  ...
  short ifru_index;
 } ifr_ifru;
#define ifr_index ifr_ifru.ifru_index
};

so it should have picked the ifreq.ifr_index path; next looking at
config.log, I see:

configure:67334: checking for struct ifreq.ifr_index
configure:67334: gcc -std=gnu99 -c -g  -D_THREAD_SAFE -D_THREAD_SAFE
conftest.c >&5
In file included from conftest.c:540:
/usr/include/net/if.h:305: error: field 'ifru_addr' has incomplete type

aha - BSD's <net/if.h> is not self-contained.

I'm now testing a minor tweak to configure.ac to include further pre-req
headers; I'll post the modified version of your patch that finally gets
things working for me.

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130430/2a2ad460/attachment-0001.sig>


More information about the libvir-list mailing list