Commit 11616545 authored by Hauke Mehrtens's avatar Hauke Mehrtens Committed by Stefan Bader

uapi/if_ether.h: move __UAPI_DEF_ETHHDR libc define

BugLink: https://bugs.launchpad.net/bugs/1818813

commit da360299 upstream.

This fixes a compile problem of some user space applications by not
including linux/libc-compat.h in uapi/if_ether.h.

linux/libc-compat.h checks which "features" the header files, included
from the libc, provide to make the Linux kernel uapi header files only
provide no conflicting structures and enums. If a user application mixes
kernel headers and libc headers it could happen that linux/libc-compat.h
gets included too early where not all other libc headers are included
yet. Then the linux/libc-compat.h would not prevent all the
redefinitions and we run into compile problems.
This patch removes the include of linux/libc-compat.h from
uapi/if_ether.h to fix the recently introduced case, but not all as this
is more or less impossible.

It is no problem to do the check directly in the if_ether.h file and not
in libc-compat.h as this does not need any fancy glibc header detection
as glibc never provided struct ethhdr and should define
__UAPI_DEF_ETHHDR by them self when they will provide this.

The following test program did not compile correctly any more:

#include <linux/if_ether.h>
#include <netinet/in.h>
#include <linux/in.h>

int main(void)
{
	return 0;
}

Fixes: 6926e041 ("uapi/if_ether.h: prevent redefinition of struct ethhdr")
Reported-by: default avatarGuillaume Nault <g.nault@alphalink.fr>
Cc: <stable@vger.kernel.org> # 4.15
Signed-off-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 86351931
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#define _UAPI_LINUX_IF_ETHER_H #define _UAPI_LINUX_IF_ETHER_H
#include <linux/types.h> #include <linux/types.h>
#include <linux/libc-compat.h>
/* /*
* IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
...@@ -137,6 +136,11 @@ ...@@ -137,6 +136,11 @@
* This is an Ethernet frame header. * This is an Ethernet frame header.
*/ */
/* allow libcs like musl to deactivate this, glibc does not implement this. */
#ifndef __UAPI_DEF_ETHHDR
#define __UAPI_DEF_ETHHDR 1
#endif
#if __UAPI_DEF_ETHHDR #if __UAPI_DEF_ETHHDR
struct ethhdr { struct ethhdr {
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
......
...@@ -184,10 +184,4 @@ ...@@ -184,10 +184,4 @@
#endif /* __GLIBC__ */ #endif /* __GLIBC__ */
/* Definitions for if_ether.h */
/* allow libcs like musl to deactivate this, glibc does not implement this. */
#ifndef __UAPI_DEF_ETHHDR
#define __UAPI_DEF_ETHHDR 1
#endif
#endif /* _UAPI_LIBC_COMPAT_H */ #endif /* _UAPI_LIBC_COMPAT_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment