2009-01-22 12:51:46

by Andrew Walrond

[permalink] [raw]
Subject: 2.6.28 headers break kbd and net-tools userspace builds

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


2009-01-22 17:57:30

by Sam Ravnborg

[permalink] [raw]
Subject: Re: 2.6.28 headers break kbd and net-tools userspace builds

On Thu, Jan 22, 2009 at 12:45:13PM +0000, Andrew Walrond wrote:
> 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.

>
> 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.

> Hope that's useful.

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

Sam

2009-01-22 19:04:53

by Andrew Walrond

[permalink] [raw]
Subject: Re: 2.6.28 headers break kbd and net-tools userspace builds

Sam Ravnborg wrote:
>
> 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

2009-01-22 19:11:19

by Sam Ravnborg

[permalink] [raw]
Subject: Re: 2.6.28 headers break kbd and net-tools userspace builds

[restored lkml]

On Thu, Jan 22, 2009 at 07:03:29PM +0000, Andrew Walrond wrote:
> Sam Ravnborg wrote:
> >
> >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

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

2009-01-27 05:08:50

by David Miller

[permalink] [raw]
Subject: Re: 2.6.28 headers break kbd and net-tools userspace builds

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

> On Thu, Jan 22, 2009 at 07:03:29PM +0000, Andrew Walrond wrote:
> > $ 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
>
> 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.

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.

2009-01-27 10:45:08

by Jan Engelhardt

[permalink] [raw]
Subject: Re: 2.6.28 headers break kbd and net-tools userspace builds


On Tuesday 2009-01-27 06:08, David Miller wrote:
>> On Thu, Jan 22, 2009 at 07:03:29PM +0000, Andrew Walrond wrote:
>> > $ 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
>>
>> 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".
>
>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.

2009-01-28 20:41:01

by David Miller

[permalink] [raw]
Subject: Re: 2.6.28 headers break kbd and net-tools userspace builds

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

>
> On Tuesday 2009-01-27 06:08, David Miller wrote:
> >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.
>
> 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.

2009-01-30 04:12:47

by Jan Engelhardt

[permalink] [raw]
Subject: Re: 2.6.28 headers break kbd and net-tools userspace builds


On Wednesday 2009-01-28 21:29, David Miller wrote:
>> On Tuesday 2009-01-27 06:08, David Miller wrote:
>> >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.
>>
>> 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.[...]
>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.