netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [regresssion 4.15] Userspace compilation broken by uapi/linux/if_ether.h update
@ 2018-01-25 14:58 Guillaume Nault
  2018-01-25 22:21 ` Hauke Mehrtens
  0 siblings, 1 reply; 6+ messages in thread
From: Guillaume Nault @ 2018-01-25 14:58 UTC (permalink / raw)
  To: netdev; +Cc: Hauke Mehrtens

Hi,

Commit 6926e041a892 ("uapi/if_ether.h: prevent redefinition of struct ethhdr"),
can break compilation of userspace programs (in my case, accel-ppp
(https://accel-ppp.org)).

This happens for userspace programs that end up including
linux/if_ether.h, netinet/in.h and linux/in.h in this order:

# cat test_ifether.c
#include <linux/if_ether.h>
#include <netinet/in.h>
#include <linux/in.h>

int main(void)
{
	return 0;
}

# gcc test_ifether.c
In file included from test_ifether.c:2:0:
/usr/include/linux/in.h:29:3: error: redeclaration of enumerator ‘IPPROTO_IP’
   IPPROTO_IP = 0,  /* Dummy protocol for TCP  */
   ^
/usr/include/netinet/in.h:42:5: note: previous definition of ‘IPPROTO_IP’ was here
     IPPROTO_IP = 0,    /* Dummy protocol for TCP.  */
     ^~~~~~~~~~


Now that linux/libc-compat.h is included in linux/if_ether.h, it is
processed before netinet/in.h. Therefore, it sets the relevant
__UAPI_DEF_* guards to 1 (as _NETINET_IN_H isn't yet defined).
Then netinet/in.h is included, followed by linux/in.h. The later
doesn't realise that what it defines has already been included by
netinet/in.h because the __UAPI_DEF_* guards were set too early.

Of course the situation is a bit more complicated on real projects, as
these files aren't included directly. For example, in accel-ppp, the
PPPoE module (accel-ppp/accel-pppd/ctrl/pppoe/pppoe.c) uses
#include <net/ethernet.h>   /* includes linux/if_ether.h */
#include <arpa/inet.h>      /* includes netinet/in.h */
#include <linux/if_pppox.h> /* (through pppoe.h), includes linux/in.h */


I don't have a satisfying solution for now, but I'd really like it if
we could avoid shipping a kernel which forces userspace to play with
include files ordering to keep compiling.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-02-06 15:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-25 14:58 [regresssion 4.15] Userspace compilation broken by uapi/linux/if_ether.h update Guillaume Nault
2018-01-25 22:21 ` Hauke Mehrtens
2018-01-26 10:51   ` Guillaume Nault
     [not found]     ` <20180126105138.GU1422-pHk1y4uTXVDytLWWfqlThQ@public.gmane.org>
2018-01-26 17:17       ` Guillaume Nault
     [not found]         ` <20180126171723.GV1422-pHk1y4uTXVDytLWWfqlThQ@public.gmane.org>
2018-01-26 19:21           ` David Miller
2018-02-06 15:08       ` Guillaume Nault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).