1 --- a/include/linux-private/linux/if_ether.h
2 +++ b/include/linux-private/linux/if_ether.h
4 #define _LINUX_IF_ETHER_H
6 #include <linux/types.h>
7 +#include <linux/libc-compat.h>
10 * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
12 * This is an Ethernet frame header.
15 +#if __UAPI_DEF_ETHHDR
17 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
18 unsigned char h_source[ETH_ALEN]; /* source ether addr */
19 __be16 h_proto; /* packet type ID field */
20 } __attribute__((packed));
23 #endif /* _LINUX_IF_ETHER_H */
24 --- a/include/linux-private/linux/libc-compat.h
25 +++ b/include/linux-private/linux/libc-compat.h
27 #ifndef _LIBC_COMPAT_H
28 #define _LIBC_COMPAT_H
30 -/* We have included glibc headers... */
31 -#if defined(__GLIBC__)
32 +/* We're used from userspace... */
33 +#if !defined(__KERNEL__)
35 -/* Coordinate with glibc netinet/in.h header. */
36 +/* Coordinate with libc netinet/if_ether.h */
37 +#ifdef _NETINET_IF_ETHER_H /* musl */
38 +#define __UAPI_DEF_ETHHDR 0
40 +/* glibc uses __NETINET_IF_ETHER_H, and uses the uapi header. */
41 +#define __UAPI_DEF_ETHHDR 1
44 +/* Coordinate with libc netinet/in.h header. */
45 #if defined(_NETINET_IN_H)
47 /* GLIBC headers included first so don't define anything
49 #define __UAPI_DEF_IN_CLASS 0
51 #define __UAPI_DEF_IN6_ADDR 0
52 -/* The exception is the in6_addr macros which must be defined
53 - * if the glibc code didn't define them. This guard matches
54 - * the guard in glibc/inet/netinet/in.h which defines the
55 - * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
56 -#if defined(__USE_MISC) || defined (__USE_GNU)
57 #define __UAPI_DEF_IN6_ADDR_ALT 0
59 -#define __UAPI_DEF_IN6_ADDR_ALT 1
61 #define __UAPI_DEF_SOCKADDR_IN6 0
62 #define __UAPI_DEF_IPV6_MREQ 0
63 #define __UAPI_DEF_IPPROTO_V6 0
67 /* Linux headers included first, and we must define everything
68 - * we need. The expectation is that glibc will check the
69 + * we need. The expectation is that libc will check the
70 * __UAPI_DEF_* defines and adjust appropriately. */
71 #define __UAPI_DEF_IN_ADDR 1
72 #define __UAPI_DEF_IN_IPPROTO 1
74 #define __UAPI_DEF_IN_CLASS 1
76 #define __UAPI_DEF_IN6_ADDR 1
77 -/* We unconditionally define the in6_addr macros and glibc must
78 +/* We unconditionally define the in6_addr macros and libc must
80 #define __UAPI_DEF_IN6_ADDR_ALT 1
81 #define __UAPI_DEF_SOCKADDR_IN6 1
83 /* If we did not see any headers from any supported C libraries,
84 * or we are being included in the kernel, then define everything
86 -#else /* !defined(__GLIBC__) */
87 +#else /* defined(__KERNEL__) */
89 +/* Definitions for if/ether.h */
90 +#define __UAPI_DEF_ETHHDR 1
92 /* Definitions for in.h */
93 #define __UAPI_DEF_IN_ADDR 1
95 /* Definitions for xattr.h */
96 #define __UAPI_DEF_XATTR 1
98 -#endif /* __GLIBC__ */
99 +#endif /* defined(__KERNEL__) */
101 #endif /* _LIBC_COMPAT_H */