Re: [RFC] use <linux/if.h> instead of <net/if.h>



I'm really no libc/kernel guru here, but since we hit this particular
kind of issue before in Ubuntu...

AFAIK, normally both headers shouldn't conflict. This however happened
IIRC early in the Natty release cycle due to a discrepancy between the
libc and kernel includes. This was fixed with a kernel update. [1]

I'm not saying it's the exact same thing, but maybe there's a hint in
there to the particular issue that was found. Note that having fewer
<linux/*.h> includes in userspace (where possible) remains a good
idea.

[1] https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/673073

Mathieu Trudel-Lapierre <mathieu tl gmail com>
Freenode: cyphermox, Jabber: mathieu tl gmail com
4096R/EE018C93 1967 8F7D 03A1 8F38 732E  FF82 C126 33E1 EE01 8C93



On Mon, Sep 12, 2011 at 5:38 PM, Dan Williams <dcbw redhat com> wrote:
> On Fri, 2011-09-09 at 11:50 +0200, Thomas Graf wrote:
>> Use of <net/if.h> conflicts with the use of <linux/if.h>. While users
>> of <net/if.h> can switch to <linux/if.h> it is not posible in the
>> other direction.
>>
>> The header <netlink/route/link.h> uses <linux/if.h> because it is part
>> of the API, therefore it conflicts with NM.
>>
>> Does NM rely on using <net/if.h> for some reason or can we switch over
>> to using <linux/if.h>?
>
> It's being used for some ioctls, it appears.  This patch fails like so:
>
> libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src -I../../src/logging -I../../include -I../../libnm-util -I../../marshallers -pthread -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/wimax -Wall -std=gnu89 -g -O2 -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wfloat-equal -Wno-unused-parameter -Wno-sign-compare -fno-strict-aliasing -Wno-unused-but-set-variable -Wundef -Werror -MT libwimax_la-nm-device-wimax.lo -MD -MP -MF .deps/libwimax_la-nm-device-wimax.Tpo -c nm-device-wimax.c  -fPIC -DPIC -o .libs/libwimax_la-nm-device-wimax.o
> In file included from nm-device-wimax.c:26:0:
> /usr/include/linux/if.h:178:19: error: field 'ifru_addr' has incomplete type
> /usr/include/linux/if.h:179:19: error: field 'ifru_dstaddr' has incomplete type
> /usr/include/linux/if.h:180:19: error: field 'ifru_broadaddr' has incomplete type
> /usr/include/linux/if.h:181:19: error: field 'ifru_netmask' has incomplete type
> /usr/include/linux/if.h:182:20: error: field 'ifru_hwaddr' has incomplete type
>
> and removing the include cause:
>
> nm-device-wimax.c: In function 'real_update_hw_address':
> nm-device-wimax.c:418:15: error: storage size of 'req' isn't known
> nm-device-wimax.c:430:27: error: invalid application of 'sizeof' to incomplete type 'struct ifreq'
> nm-device-wimax.c:418:15: error: unused variable 'req' [-Werror=unused-variable]
>
> because we're trying to:
>
>        if (ioctl (fd, SIOCGIFHWADDR, &req) < 0) {
>
> which is used in a couple other places. We could conceivably convert
> this to use libnl in synchronous mode.  There's other usage of ioctl()
> in the NM codebase, mainly for WEXT (which we should replace with
> nl80211, which is part of the reason for the libnl3 conversion) but also
> for SIOCETHTOOL, SIOCGMIIREG, SIOCGMIIPHY, and SIOCGPPPSTATS.
>
> What's the best course forward here?
>
> Dan
>
>> ---
>>  include/wireless-helper.h              |    2 +-
>>  src/nm-device.c                        |    2 +-
>>  src/nm-system.c                        |    2 +-
>>  src/ppp-manager/nm-ppp-manager.c       |    2 +-
>>  src/settings/plugins/ifcfg-rh/reader.c |    2 +-
>>  src/wimax/iwmxsdk.c                    |    2 +-
>>  src/wimax/nm-device-wimax.c            |    2 +-
>>  7 files changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/include/wireless-helper.h b/include/wireless-helper.h
>> index d150ef7..2e4509a 100644
>> --- a/include/wireless-helper.h
>> +++ b/include/wireless-helper.h
>> @@ -27,6 +27,6 @@
>>  #include <sys/types.h>
>>  #include <linux/types.h>
>>  #include <sys/socket.h>
>> -#include <net/if.h>
>> +#include <linux/if.h>
>>  #include <wireless.h>
>>
>> diff --git a/src/nm-device.c b/src/nm-device.c
>> index 3522ea4..a453c39 100644
>> --- a/src/nm-device.c
>> +++ b/src/nm-device.c
>> @@ -25,7 +25,7 @@
>>  #include <dbus/dbus.h>
>>  #include <netinet/in.h>
>>  #include <string.h>
>> -#include <net/if.h>
>> +#include <linux/if.h>
>>  #include <unistd.h>
>>  #include <errno.h>
>>  #include <sys/ioctl.h>
>> diff --git a/src/nm-system.c b/src/nm-system.c
>> index 0b29468..473fcec 100644
>> --- a/src/nm-system.c
>> +++ b/src/nm-system.c
>> @@ -40,7 +40,7 @@
>>  #include <netdb.h>
>>  #include <glib.h>
>>  #include <ctype.h>
>> -#include <net/if.h>
>> +#include <linux/if.h>
>>
>>  #include "nm-system.h"
>>  #include "nm-device.h"
>> diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c
>> index e863aab..9d8b79e 100644
>> --- a/src/ppp-manager/nm-ppp-manager.c
>> +++ b/src/ppp-manager/nm-ppp-manager.c
>> @@ -32,7 +32,7 @@
>>  #include <sys/socket.h>
>>  #include <sys/ioctl.h>
>>  #include <asm/types.h>
>> -#include <net/if.h>
>> +#include <linux/if.h>
>>  #include <sys/stat.h>
>>
>>  #include <linux/ppp_defs.h>
>> diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
>> index cdf5889..a33332a 100644
>> --- a/src/settings/plugins/ifcfg-rh/reader.c
>> +++ b/src/settings/plugins/ifcfg-rh/reader.c
>> @@ -28,7 +28,7 @@
>>  #include <ctype.h>
>>  #include <sys/inotify.h>
>>  #include <errno.h>
>> -#include <net/if.h>
>> +#include <linux/if.h>
>>  #include <sys/ioctl.h>
>>  #include <unistd.h>
>>  #include <netinet/ether.h>
>> diff --git a/src/wimax/iwmxsdk.c b/src/wimax/iwmxsdk.c
>> index dd78d5a..f9dc714 100644
>> --- a/src/wimax/iwmxsdk.c
>> +++ b/src/wimax/iwmxsdk.c
>> @@ -27,7 +27,7 @@
>>  #include <stdlib.h>
>>  #include <errno.h>
>>  #include <string.h>
>> -#include <net/if.h>
>> +#include <linux/if.h>
>>
>>  #include <glib.h>
>>
>> diff --git a/src/wimax/nm-device-wimax.c b/src/wimax/nm-device-wimax.c
>> index d41491a..ec23520 100644
>> --- a/src/wimax/nm-device-wimax.c
>> +++ b/src/wimax/nm-device-wimax.c
>> @@ -23,7 +23,7 @@
>>  #include <unistd.h>
>>  #include <sys/ioctl.h>
>>  #include <net/ethernet.h>
>> -#include <net/if.h>
>> +#include <linux/if.h>
>>
>>  #include <WiMaxAPI.h>
>>  #include <WiMaxAPIEx.h>
>
>
> _______________________________________________
> networkmanager-list mailing list
> networkmanager-list gnome org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list
>


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