Skip to contentSkip to conversation

2.6.28 headers break kbd and net-tools userspace builds

DISCUSSION Andrew Walrond 4 participants 15 messages Jan 22, 2009 – Feb 3, 2009 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Breaks kbd like this:

/usr/include/linux/serial.h:164: error: expected
specifier-qualifier-list before '__u32'

and net-tools like this:

In file included from /usr/include/linux/if_tunnel.h:5,

                  from iptunnel.c:39:

/usr/include/linux/ip.h:85: error: redefinition of 'struct iphdr'

Both build fine with 2.6.27.10 headers.

Hope that's useful.

Andrew Walrond

#1 lore raw
Quoted 4 lines · Andrew Walrond

Breaks kbd like this:

/usr/include/linux/serial.h:164: error: expected
specifier-qualifier-list before '__u32'

This is know and fixed. The fix is to include linux/types.h in serial.h.

Quoted 8 lines

and net-tools like this:

In file included from /usr/include/linux/if_tunnel.h:5,

                  from iptunnel.c:39:

/usr/include/linux/ip.h:85: error: redefinition of 'struct iphdr'

Both build fine with 2.6.27.10 headers.

Herbert added an include of ip.h in commit:

commit c19e654ddbe3831252f61e76a74d661e1a755530

Author: Herbert Xu <[email protected]>
Date:   Thu Oct 9 11:59:55 2008 -0700

gre: Add netlink interface

This patch adds a netlink interface that will eventually displace the existing ioctl interface. It utilises the elegant rtnl_link_ops mechanism.

This causes struct iphdr to be redefined.
But there is noting wrong in including ip.h in if_tunnel.h.

I checked the include guards and they are correct.

Could you please investige where it picks up the first definition of struct iphdr.

Quoted 1 line

Hope that's useful.

Anything that can improve the exported user headers are useful - thanks.

Sam

#2 lore raw
Quoted 7 lines · Sam Ravnborg

I checked the include guards and they are correct.

Could you please investige where it picks up the first definition of struct iphdr.

Here you go:

$ make iptunnel.o

cc -D_GNU_SOURCE -O2 -Wall -g -I. -idirafter ./include/ -Ilib -c -o
iptunnel.o iptunnel.c
In file included from /usr/include/linux/if_tunnel.h:5,

                from iptunnel.c:39:

/usr/include/linux/ip.h:85: error: redefinition of 'struct iphdr'

$ grep -r iphdr /usr/include/

/usr/include/netinet/ip.h:struct iphdr /usr/include/netinet/tcp.h: * This should be defined as MIN(512, IP_MSS
- sizeof (struct tcpiphdr)).
/usr/include/linux/if_tunnel.h: struct iphdr iph;
/usr/include/linux/ip.h:struct iphdr {

$ grep netinet/ip.h iptunnel.c

#include <netinet/ip.h>

So linux/ip.h is clashing with glibc(2.8)'s netinet/ip.h

Andrew Walrond

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

[restored lkml]

Quoted 26 lines · Andrew Walrond
Quoted 7 lines · Sam Ravnborg

I checked the include guards and they are correct.

Could you please investige where it picks up the first definition of struct iphdr.

Here you go:

$ make iptunnel.o

cc -D_GNU_SOURCE -O2 -Wall -g -I. -idirafter ./include/ -Ilib -c -o
iptunnel.o iptunnel.c
In file included from /usr/include/linux/if_tunnel.h:5,

                from iptunnel.c:39:

/usr/include/linux/ip.h:85: error: redefinition of 'struct iphdr'

$ grep -r iphdr /usr/include/

/usr/include/netinet/ip.h:struct iphdr /usr/include/netinet/tcp.h: * This should be defined as MIN(512, IP_MSS
- sizeof (struct tcpiphdr)).
/usr/include/linux/if_tunnel.h: struct iphdr iph;
/usr/include/linux/ip.h:struct iphdr {

Quoted 5 lines
$ grep netinet/ip.h iptunnel.c

#include <netinet/ip.h>

So linux/ip.h is clashing with glibc(2.8)'s netinet/ip.h

I took a look at my netinet/ip.h and this is obviously the same structure.
But I do not know what the right answer is here.

Added netdev..

This may be a general thing. Because iphdr is no a kernel thing, it is an IP thing. So one could argue that the kernel should not export it in the first place.

Sam

maintainer
#5 lore raw

From: Sam Ravnborg <[email protected]>
Date: Thu, 22 Jan 2009 20:12:39 +0100

Quoted 19 lines · Andrew Walrond
Quoted 8 lines
$ grep -r iphdr /usr/include/

/usr/include/netinet/ip.h:struct iphdr /usr/include/netinet/tcp.h: * This should be defined as MIN(512, IP_MSS
- sizeof (struct tcpiphdr)).
/usr/include/linux/if_tunnel.h: struct iphdr iph;
/usr/include/linux/ip.h:struct iphdr {

Quoted 5 lines
$ grep netinet/ip.h iptunnel.c

#include <netinet/ip.h>

So linux/ip.h is clashing with glibc(2.8)'s netinet/ip.h

I took a look at my netinet/ip.h and this is obviously the same structure.
But I do not know what the right answer is here.

Quoted 5 lines

Added netdev..

This may be a general thing. Because iphdr is no a kernel thing, it is an IP thing. So one could argue that the kernel should not export it in the first place.

The fly in the ointment is linux/if_tunnel.h

We export a structure there for a userland interface which uses "struct iphdr".

Because of that, we are faced with the difficult choice between defining the structure (as we do) in linux/ip.h or using some ugly __KERNEL__ ifdefs in linux/if_tunnel.h to conditionally include netinet/ip.h instead. :-/

Really, I have no idea what to do about this as the problem has existed for so long.

#6 lore raw
Quoted 28 lines · David Miller
Quoted 15 lines · Andrew Walrond
Quoted 8 lines
$ grep -r iphdr /usr/include/

/usr/include/netinet/ip.h:struct iphdr /usr/include/netinet/tcp.h: * This should be defined as MIN(512, IP_MSS
- sizeof (struct tcpiphdr)).
/usr/include/linux/if_tunnel.h: struct iphdr iph;
/usr/include/linux/ip.h:struct iphdr {

Quoted 5 lines
$ grep netinet/ip.h iptunnel.c

#include <netinet/ip.h>

So linux/ip.h is clashing with glibc(2.8)'s netinet/ip.h

Quoted 7 lines

I took a look at my netinet/ip.h and this is obviously the same structure.
But I do not know what the right answer is here.

This may be a general thing. Because iphdr is no a kernel thing, it is an IP thing. So one could argue that the kernel should not export it in the first place.

The fly in the ointment is linux/if_tunnel.h

We export a structure there for a userland interface which uses "struct iphdr".

Quoted 7 lines

Because of that, we are faced with the difficult choice between defining the structure (as we do) in linux/ip.h or using some ugly __KERNEL__ ifdefs in linux/if_tunnel.h to conditionally include netinet/ip.h instead. :-/

Really, I have no idea what to do about this as the problem has existed for so long.

I think in the long term, exported structs should probably have a "kernel_" prefix, much like userspace libraries use such prefixes to (try to) guard against simple name clashes.

maintainer
#7 lore raw

From: Jan Engelhardt <[email protected]>
Date: Tue, 27 Jan 2009 11:44:51 +0100 (CET)

Quoted 12 lines · David Miller
Quoted 10 lines

The fly in the ointment is linux/if_tunnel.h

We export a structure there for a userland interface which uses "struct iphdr".

Because of that, we are faced with the difficult choice between defining the structure (as we do) in linux/ip.h or using some ugly __KERNEL__ ifdefs in linux/if_tunnel.h to conditionally include netinet/ip.h instead. :-/

Quoted 6 lines
Quoted 2 lines

Really, I have no idea what to do about this as the problem has existed for so long.

I think in the long term, exported structs should probably have a "kernel_" prefix, much like userspace libraries use such prefixes to (try to) guard against simple name clashes.

This is a reasonable rule for future interfaces, but won't help us here on this one.

For one thing, users can be making use of the inner types to build the blobs they send via these interfaces. So it's not like we can rename "struct iphdr" to "struct kernel_iphdr" to fix this particular case.

Really, we page a huge price these days because the relationship between glibc's and the kernel's userland header exports in the past has been anti-social at best.

#8 lore raw
Quoted 18 lines · David Miller
Quoted 11 lines · David Miller
Quoted 10 lines

The fly in the ointment is linux/if_tunnel.h

We export a structure there for a userland interface which uses "struct iphdr".

Because of that, we are faced with the difficult choice between defining the structure (as we do) in linux/ip.h or using some ugly __KERNEL__ ifdefs in linux/if_tunnel.h to conditionally include netinet/ip.h instead. :-/

Quoted 6 lines
Quoted 2 lines

Really, I have no idea what to do about this as the problem has existed for so long.

I think in the long term, exported structs should probably have a "kernel_" prefix, much like userspace libraries use such prefixes to (try to) guard against simple name clashes.

Quoted 6 lines

This is a reasonable rule for future interfaces, but won't help us here on this one.[...]
Really, we page a huge price these days because the relationship between glibc's and the kernel's userland header exports in the past has been anti-social at best.

Yeah I just had to notice >:-(

IPPROTO_MH is only defined in linux/in6.h, but inclusion of it:

/usr/include/linux/in6.h:31: error: redefinition of ■struct in6_addr■ /usr/include/linux/in6.h:52: error: redefinition of ■struct sockaddr_in6■ /usr/include/linux/in6.h:60: error: redefinition of ■struct ipv6_mreq■

Ick. That's even worse than tunnels.

#9 lore raw

Hey guys. A gentle nudge...

My distro scripts build the

glibc
iproute2
iputils
kbd
lm_sensors
net-tools
strace

packages and others against every new release of linux and linux-stable, (hence my initial report). Right now I'm stalled at the 2.6.27.? headers so can't do any more testing until this is resolved.

Andrew Walrond

Quoted 39 lines · Jan Engelhardt
Quoted 19 lines · David Miller
Quoted 12 lines · David Miller
Quoted 11 lines

The fly in the ointment is linux/if_tunnel.h

We export a structure there for a userland interface which uses "struct iphdr".

Because of that, we are faced with the difficult choice between defining the structure (as we do) in linux/ip.h or using some ugly __KERNEL__ ifdefs in linux/if_tunnel.h to conditionally include netinet/ip.h instead. :-/

Quoted 7 lines
Quoted 3 lines

Really, I have no idea what to do about this as the problem has existed for so long.

I think in the long term, exported structs should probably have a "kernel_" prefix, much like userspace libraries use such prefixes to (try to) guard against simple name clashes.

Quoted 7 lines

This is a reasonable rule for future interfaces, but won't help us here on this one.[...]
Really, we page a huge price these days because the relationship between glibc's and the kernel's userland header exports in the past has been anti-social at best.

Yeah I just had to notice >:-(

IPPROTO_MH is only defined in linux/in6.h, but inclusion of it:

/usr/include/linux/in6.h:31: error: redefinition of ■struct in6_addr■ /usr/include/linux/in6.h:52: error: redefinition of ■struct sockaddr_in6■ /usr/include/linux/in6.h:60: error: redefinition of ■struct ipv6_mreq■

Ick. That's even worse than tunnels.

maintainer
#10 lore raw

From: Andrew Walrond <[email protected]>
Date: Mon, 02 Feb 2009 10:35:25 +0000

Quoted 12 lines

Hey guys. A gentle nudge...

My distro scripts build the

glibc
iproute2
iputils
kbd
lm_sensors
net-tools
strace

Quoted 2 lines

packages and others against every new release of linux and linux-stable, (hence my initial report). Right now I'm stalled at the 2.6.27.? headers so can't do any more testing until this is resolved.

There isn't anything we can really do about these cases.

No matter what we do, we break the userland build in one way or another.

#11 lore raw
Quoted 6 lines · David Miller

There isn't anything we can really do about these cases.

No matter what we do, we break the userland build in one way or another.

What exactly is the purpose of the kernel headers? Are there some definitions in the kernel headers that will never be available from glibc? Is it perhaps possible to work towards exporting kernel headers for the sole purpose of building glibc, and all other packages should be able to build against glibc's headers?

Andrew Walrond

maintainer
#12 lore raw

From: Andrew Walrond <[email protected]>
Date: Mon, 02 Feb 2009 21:13:11 +0000

Quoted 5 lines

What exactly is the purpose of the kernel headers? Are there some definitions in the kernel headers that will never be available from glibc? Is it perhaps possible to work towards exporting kernel headers for the sole purpose of building glibc, and all other packages should be able to build against glibc's headers?

To a certain extent they are supposed to be able to co-exist.

We weren't careful in the past in some cases, to the point where the conflicts often very difficult to resolve. That's the kind of situation we have here.

I guess I'll put in the following hack for now:

include/linux/if_tunnel.h +3 -0
index aeab2cb..82c4362 100644
@@ -2,7 +2,10 @@
 #define _IF_TUNNEL_H_
 
 #include <linux/types.h>
+
+#ifdef __KERNEL__
 #include <linux/ip.h>
+#endif
 
 #define SIOCGETTUNNEL   (SIOCDEVPRIVATE + 0)
 #define SIOCADDTUNNEL   (SIOCDEVPRIVATE + 1)
maintainer
#13 lore raw

From: David Miller <[email protected]>
Date: Mon, 02 Feb 2009 13:24:50 -0800 (PST)

include/linux/if_tunnel.h

Quoted 4 lines

I guess I'll put in the following hack for now:

include/linux/if_tunnel.h +0 -0
index aeab2cb..82c4362 100644

Need to also update linux/Kbuild, here is an updated patch:

include/linux/Kbuild +1 -1
index 12e9a29..6a9bb97 100644
@@ -89,7 +89,6 @@ header-y += if_ppp.h
 header-y += if_slip.h
 header-y += if_strip.h
 header-y += if_tun.h
-header-y += if_tunnel.h
 header-y += in_route.h
 header-y += ioctl.h
 header-y += ip6_tunnel.h
@@ -235,6 +234,7 @@ unifdef-y += if_phonet.h
 unifdef-y += if_pppol2tp.h
 unifdef-y += if_pppox.h
 unifdef-y += if_tr.h
+unifdef-y += if_tunnel.h
 unifdef-y += if_vlan.h
 unifdef-y += igmp.h
 unifdef-y += inet_diag.h
include/linux/if_tunnel.h +3 -0
index aeab2cb..82c4362 100644
@@ -2,7 +2,10 @@
 #define _IF_TUNNEL_H_
 
 #include <linux/types.h>
+
+#ifdef __KERNEL__
 #include <linux/ip.h>
+#endif
 
 #define SIOCGETTUNNEL   (SIOCDEVPRIVATE + 0)
 #define SIOCADDTUNNEL   (SIOCDEVPRIVATE + 1)
#14 lore raw
Quoted 9 lines · David Miller

From: David Miller <[email protected]>
Date: Mon, 02 Feb 2009 13:24:50 -0800 (PST)

include/linux/if_tunnel.h

Quoted 4 lines

I guess I'll put in the following hack for now:

include/linux/if_tunnel.h +0 -0
index aeab2cb..82c4362 100644

Need to also update linux/Kbuild, here is an updated patch:

All headers are unifdeffed - so the Kbuild patch
is not needed.

Sam

maintainer
#15 lore raw

From: Sam Ravnborg <[email protected]>
Date: Tue, 3 Feb 2009 05:58:33 +0100

Quoted 6 lines · David Miller
Quoted 5 lines

From: David Miller <[email protected]>
Date: Mon, 02 Feb 2009 13:24:50 -0800 (PST)

Quoted 2 lines

I guess I'll put in the following hack for now:

Quoted 7 lines
Quoted 4 lines

include/linux/if_tunnel.h

Quoted 2 lines
include/linux/if_tunnel.h +0 -0
index aeab2cb..82c4362 100644

Need to also update linux/Kbuild, here is an updated patch:

All headers are unifdeffed - so the Kbuild patch
is not needed.

Thanks for the info but that's how I commited and pushed out the fix already, and it doesn't hurt either :-)