42e29326b986def095b8f22551b63ae903a4a45b
[openwrt/staging/zorun.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/linux/if_ether.h
18 +++ b/include/linux/if_ether.h
19 @@ -22,6 +22,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 @@ -142,11 +143,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/linux/libc-compat.h
42 +++ b/include/linux/libc-compat.h
43 @@ -89,6 +89,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 @@ -184,6 +192,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
68 --- a/ip/iplink_bridge.c
69 +++ b/ip/iplink_bridge.c
70 @@ -14,8 +14,8 @@
71 #include <string.h>
72 #include <netinet/in.h>
73 #include <linux/if_link.h>
74 -#include <linux/if_bridge.h>
75 #include <netinet/ether.h>
76 +#include <linux/if_bridge.h>
77 #include <net/if.h>
78
79 #include "rt_names.h"