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
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.
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>
13 include/uapi/linux/if_ether.h | 3 +++
14 include/uapi/linux/libc-compat.h | 11 +++++++++++
15 2 files changed, 14 insertions(+)
17 --- a/include/linux/if_ether.h
18 +++ b/include/linux/if_ether.h
20 #define _LINUX_IF_ETHER_H
22 #include <linux/types.h>
23 +#include <linux/libc-compat.h>
26 * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
28 * This is an Ethernet frame header.
31 +#if __UAPI_DEF_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));
40 #endif /* _LINUX_IF_ETHER_H */
41 --- a/include/linux/libc-compat.h
42 +++ b/include/linux/libc-compat.h
45 #endif /* _NET_IF_H */
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
52 +#define __UAPI_DEF_ETHHDR 1
55 /* Coordinate with libc netinet/in.h header. */
56 #if defined(_NETINET_IN_H)
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
62 +/* Definitions for if_ether.h */
63 +#define __UAPI_DEF_ETHHDR 1
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
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>