abd1f7eaca9724cb5df17d4e38d553b1ffc0b589
[openwrt/staging/hauke.git] /
1 From fcbb6fed85ea9ff4feb4f1ebd4f0f235fdaf06b6 Mon Sep 17 00:00:00 2001
2 From: David Heidelberger <david.heidelberger@ixit.cz>
3 Date: Mon, 29 Jun 2015 16:53:03 +0200
4 Subject: [PATCH 3/3] uapi/if_ether.h: prevent redefinition of struct ethhdr
5
6 Musl provides its own ethhdr struct definition. Add a guard to prevent
7 its definition of the appropriate musl header has already been included.
8
9 Signed-off-by: John Spencer <maillist-linux@barfooze.de>
10 Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
11 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
12 ---
13 include/uapi/linux/if_ether.h | 3 +++
14 include/uapi/linux/libc-compat.h | 11 +++++++++++
15 2 files changed, 14 insertions(+)
16
17 --- a/include/uapi/linux/if_ether.h
18 +++ b/include/uapi/linux/if_ether.h
19 @@ -23,6 +23,7 @@
20 #define _LINUX_IF_ETHER_H
21
22 #include <linux/types.h>
23 +#include <linux/libc-compat.h>
24
25 /*
26 * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
27 @@ -149,11 +150,13 @@
28 * This is an Ethernet frame header.
29 */
30
31 +#if __UAPI_DEF_ETHHDR
32 struct ethhdr {
33 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
34 unsigned char h_source[ETH_ALEN]; /* source ether addr */
35 __be16 h_proto; /* packet type ID field */
36 } __attribute__((packed));
37 +#endif
38
39
40 #endif /* _LINUX_IF_ETHER_H */
41 --- a/include/uapi/linux/libc-compat.h
42 +++ b/include/uapi/linux/libc-compat.h
43 @@ -90,6 +90,14 @@
44
45 #endif /* _NET_IF_H */
46
47 +/* musl defines the ethhdr struct itself in its netinet/if_ether.h.
48 + * Glibc just includes the kernel header and uses a different guard. */
49 +#if defined(_NETINET_IF_ETHER_H)
50 +#define __UAPI_DEF_ETHHDR 0
51 +#else
52 +#define __UAPI_DEF_ETHHDR 1
53 +#endif
54 +
55 /* Coordinate with libc netinet/in.h header. */
56 #if defined(_NETINET_IN_H)
57
58 @@ -185,6 +193,9 @@
59 /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
60 #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
61
62 +/* Definitions for if_ether.h */
63 +#define __UAPI_DEF_ETHHDR 1
64 +
65 /* Definitions for in.h */
66 #define __UAPI_DEF_IN_ADDR 1
67 #define __UAPI_DEF_IN_IPPROTO 1