45039ce1336075091cd5250c0411a1c4c52d86f5
[openwrt/openwrt.git] / target / linux / generic / backport-4.14 / 272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch
1 From 649affd04813c43e0a72886517fcfccd63230981 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Mon, 29 Jun 2015 16:53:03 +0200
4 Subject: 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 glibc does not implement this header, but when glibc will implement this
10 they can just define __UAPI_DEF_ETHHDR 0 to make it work with the
11 kernel.
12
13 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
14 ---
15 include/uapi/linux/if_ether.h | 3 +++
16 include/uapi/linux/libc-compat.h | 6 ++++++
17 2 files changed, 9 insertions(+)
18
19 --- a/include/uapi/linux/if_ether.h
20 +++ b/include/uapi/linux/if_ether.h
21 @@ -23,6 +23,7 @@
22 #define _UAPI_LINUX_IF_ETHER_H
23
24 #include <linux/types.h>
25 +#include <linux/libc-compat.h>
26
27 /*
28 * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
29 @@ -150,11 +151,13 @@
30 * This is an Ethernet frame header.
31 */
32
33 +#if __UAPI_DEF_ETHHDR
34 struct ethhdr {
35 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
36 unsigned char h_source[ETH_ALEN]; /* source ether addr */
37 __be16 h_proto; /* packet type ID field */
38 } __attribute__((packed));
39 +#endif
40
41
42 #endif /* _UAPI_LINUX_IF_ETHER_H */
43 --- a/include/uapi/linux/libc-compat.h
44 +++ b/include/uapi/linux/libc-compat.h
45 @@ -264,4 +264,10 @@
46
47 #endif /* __GLIBC__ */
48
49 +/* Definitions for if_ether.h */
50 +/* allow libcs like musl to deactivate this, glibc does not implement this. */
51 +#ifndef __UAPI_DEF_ETHHDR
52 +#define __UAPI_DEF_ETHHDR 1
53 +#endif
54 +
55 #endif /* _UAPI_LIBC_COMPAT_H */