aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--target/linux/generic/patches-3.18/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch146
-rw-r--r--target/linux/generic/patches-3.18/270-bridge_header_fix.patch10
-rw-r--r--target/linux/generic/patches-3.18/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch34
-rw-r--r--target/linux/generic/patches-3.18/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch81
-rw-r--r--target/linux/generic/patches-3.18/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch67
-rw-r--r--target/linux/generic/patches-4.0/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch146
-rw-r--r--target/linux/generic/patches-4.0/270-bridge_header_fix.patch10
-rw-r--r--target/linux/generic/patches-4.0/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch34
-rw-r--r--target/linux/generic/patches-4.0/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch81
-rw-r--r--target/linux/generic/patches-4.0/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch67
-rw-r--r--target/linux/generic/patches-4.1/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch146
-rw-r--r--target/linux/generic/patches-4.1/270-bridge_header_fix.patch10
-rw-r--r--target/linux/generic/patches-4.1/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch34
-rw-r--r--target/linux/generic/patches-4.1/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch81
-rw-r--r--target/linux/generic/patches-4.1/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch67
15 files changed, 984 insertions, 30 deletions
diff --git a/target/linux/generic/patches-3.18/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch b/target/linux/generic/patches-3.18/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch
new file mode 100644
index 0000000000..4c5cd596f7
--- /dev/null
+++ b/target/linux/generic/patches-3.18/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch
@@ -0,0 +1,146 @@
+From 279c6c7fa64f5763e6b9f05e7ab3840092e702e7 Mon Sep 17 00:00:00 2001
+From: Stephen Hemminger <stephen@networkplumber.org>
+Date: Mon, 29 Jun 2015 14:57:48 -1000
+Subject: [PATCH] api: fix compatibility of linux/in.h with netinet/in.h
+
+u
+This fixes breakage to iproute2 build with recent kernel headers
+caused by:
+ commit a263653ed798216c0069922d7b5237ca49436007
+ Author: Pablo Neira Ayuso <pablo@netfilter.org>
+ Date: Wed Jun 17 10:28:27 2015 -0500
+
+ netfilter: don't pull include/linux/netfilter.h from netns headers
+
+The issue is that definitions in linux/in.h overlap with those
+in netinet/in.h. This patch solves this by introducing the same
+mechanism as was used to solve the same problem with linux/in6.h
+
+Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ include/uapi/linux/in.h | 16 +++++++++++++---
+ include/uapi/linux/libc-compat.h | 22 ++++++++++++++++++++++
+ 2 files changed, 35 insertions(+), 3 deletions(-)
+
+--- a/include/uapi/linux/in.h
++++ b/include/uapi/linux/in.h
+@@ -19,8 +19,10 @@
+ #define _UAPI_LINUX_IN_H
+
+ #include <linux/types.h>
++#include <linux/libc-compat.h>
+ #include <linux/socket.h>
+
++#if __UAPI_DEF_IN_IPPROTO
+ /* Standard well-defined IP protocols. */
+ enum {
+ IPPROTO_IP = 0, /* Dummy protocol for TCP */
+@@ -73,12 +75,14 @@ enum {
+ #define IPPROTO_RAW IPPROTO_RAW
+ IPPROTO_MAX
+ };
++#endif
+
+-
++#if __UAPI_DEF_IN_ADDR
+ /* Internet address. */
+ struct in_addr {
+ __be32 s_addr;
+ };
++#endif
+
+ #define IP_TOS 1
+ #define IP_TTL 2
+@@ -154,6 +158,7 @@ struct in_addr {
+
+ /* Request struct for multicast socket ops */
+
++#if __UAPI_DEF_IP_MREQ
+ struct ip_mreq {
+ struct in_addr imr_multiaddr; /* IP multicast address of group */
+ struct in_addr imr_interface; /* local IP address of interface */
+@@ -205,14 +210,18 @@ struct group_filter {
+ #define GROUP_FILTER_SIZE(numsrc) \
+ (sizeof(struct group_filter) - sizeof(struct __kernel_sockaddr_storage) \
+ + (numsrc) * sizeof(struct __kernel_sockaddr_storage))
++#endif
+
++#if __UAPI_DEF_IN_PKTINFO
+ struct in_pktinfo {
+ int ipi_ifindex;
+ struct in_addr ipi_spec_dst;
+ struct in_addr ipi_addr;
+ };
++#endif
+
+ /* Structure describing an Internet (IP) socket address. */
++#if __UAPI_DEF_SOCKADDR_IN
+ #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
+ struct sockaddr_in {
+ __kernel_sa_family_t sin_family; /* Address family */
+@@ -224,8 +233,9 @@ struct sockaddr_in {
+ sizeof(unsigned short int) - sizeof(struct in_addr)];
+ };
+ #define sin_zero __pad /* for BSD UNIX comp. -FvK */
++#endif
+
+-
++#if __UAPI_DEF_IN_CLASS
+ /*
+ * Definitions of the bits in an Internet address integer.
+ * On subnets, host and network parts are found according
+@@ -276,7 +286,7 @@ struct sockaddr_in {
+ #define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
+ #define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
+ #define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */
+-
++#endif
+
+ /* <asm/byteorder.h> contains the htonl type stuff.. */
+ #include <asm/byteorder.h>
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -56,6 +56,13 @@
+
+ /* GLIBC headers included first so don't define anything
+ * that would already be defined. */
++#define __UAPI_DEF_IN_ADDR 0
++#define __UAPI_DEF_IN_IPPROTO 0
++#define __UAPI_DEF_IN_PKTINFO 0
++#define __UAPI_DEF_IP_MREQ 0
++#define __UAPI_DEF_SOCKADDR_IN 0
++#define __UAPI_DEF_IN_CLASS 0
++
+ #define __UAPI_DEF_IN6_ADDR 0
+ /* The exception is the in6_addr macros which must be defined
+ * if the glibc code didn't define them. This guard matches
+@@ -76,6 +83,13 @@
+ /* Linux headers included first, and we must define everything
+ * we need. The expectation is that glibc will check the
+ * __UAPI_DEF_* defines and adjust appropriately. */
++#define __UAPI_DEF_IN_ADDR 1
++#define __UAPI_DEF_IN_IPPROTO 1
++#define __UAPI_DEF_IN_PKTINFO 1
++#define __UAPI_DEF_IP_MREQ 1
++#define __UAPI_DEF_SOCKADDR_IN 1
++#define __UAPI_DEF_IN_CLASS 1
++
+ #define __UAPI_DEF_IN6_ADDR 1
+ /* We unconditionally define the in6_addr macros and glibc must
+ * coordinate. */
+@@ -99,6 +113,14 @@
+ * that we need. */
+ #else /* !defined(__GLIBC__) */
+
++/* Definitions for in.h */
++#define __UAPI_DEF_IN_ADDR 1
++#define __UAPI_DEF_IN_IPPROTO 1
++#define __UAPI_DEF_IN_PKTINFO 1
++#define __UAPI_DEF_IP_MREQ 1
++#define __UAPI_DEF_SOCKADDR_IN 1
++#define __UAPI_DEF_IN_CLASS 1
++
+ /* Definitions for in6.h */
+ #define __UAPI_DEF_IN6_ADDR 1
+ #define __UAPI_DEF_IN6_ADDR_ALT 1
diff --git a/target/linux/generic/patches-3.18/270-bridge_header_fix.patch b/target/linux/generic/patches-3.18/270-bridge_header_fix.patch
deleted file mode 100644
index 8b25db400a..0000000000
--- a/target/linux/generic/patches-3.18/270-bridge_header_fix.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/include/uapi/linux/if_bridge.h
-+++ b/include/uapi/linux/if_bridge.h
-@@ -15,7 +15,6 @@
-
- #include <linux/types.h>
- #include <linux/if_ether.h>
--#include <linux/in6.h>
-
- #define SYSFS_BRIDGE_ATTR "bridge"
- #define SYSFS_BRIDGE_FDB "brforward"
diff --git a/target/linux/generic/patches-3.18/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch b/target/linux/generic/patches-3.18/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch
new file mode 100644
index 0000000000..762f4989b6
--- /dev/null
+++ b/target/linux/generic/patches-3.18/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch
@@ -0,0 +1,34 @@
+From 8b05e325824d3b38e52a7748b3b5dc34dc1c0f6d Mon Sep 17 00:00:00 2001
+From: David Heidelberger <david.heidelberger@ixit.cz>
+Date: Mon, 29 Jun 2015 14:37:54 +0200
+Subject: [PATCH 1/3] uapi/kernel.h: glibc specific inclusion of sysinfo.h
+
+including sysinfo.h from kernel.h makes no sense whatsoever,
+but removing it breaks glibc's userspace header,
+which includes kernel.h instead of sysinfo.h from their sys/sysinfo.h.
+this seems to be a historical mistake.
+on musl, including any header that uses kernel.h directly or indirectly
+plus sys/sysinfo.h will produce a compile error due to redefinition of
+struct sysinfo from sys/sysinfo.h.
+so for now, only include it on glibc or when including from kernel
+in order not to break their headers.
+
+Signed-off-by: John Spencer <maillist-linux@barfooze.de>
+Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ include/uapi/linux/kernel.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/include/uapi/linux/kernel.h
++++ b/include/uapi/linux/kernel.h
+@@ -1,7 +1,9 @@
+ #ifndef _UAPI_LINUX_KERNEL_H
+ #define _UAPI_LINUX_KERNEL_H
+
++#if defined(__KERNEL__) || defined( __GLIBC__)
+ #include <linux/sysinfo.h>
++#endif
+
+ /*
+ * 'kernel.h' contains some often-used function prototypes etc
diff --git a/target/linux/generic/patches-3.18/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch b/target/linux/generic/patches-3.18/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch
new file mode 100644
index 0000000000..891299ead1
--- /dev/null
+++ b/target/linux/generic/patches-3.18/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch
@@ -0,0 +1,81 @@
+From f972afc2509eebcb00d370256c55b112a3b5ffca Mon Sep 17 00:00:00 2001
+From: David Heidelberger <david.heidelberger@ixit.cz>
+Date: Mon, 29 Jun 2015 16:50:40 +0200
+Subject: [PATCH 2/3] uapi/libc-compat.h: do not rely on __GLIBC__
+
+Musl provides the same structs as glibc, but does not provide a define to
+allow its detection. Since the absence of __GLIBC__ also can mean that it
+is included from the kernel, change the __GLIBC__ detection to
+!__KERNEL__, which should always be true when included from userspace.
+
+Signed-off-by: John Spencer <maillist-linux@barfooze.de>
+Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ include/uapi/linux/libc-compat.h | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -48,13 +48,13 @@
+ #ifndef _UAPI_LIBC_COMPAT_H
+ #define _UAPI_LIBC_COMPAT_H
+
+-/* We have included glibc headers... */
+-#if defined(__GLIBC__)
++/* We have included libc headers... */
++#if !defined(__KERNEL__)
+
+-/* Coordinate with glibc netinet/in.h header. */
++/* Coordinate with libc netinet/in.h header. */
+ #if defined(_NETINET_IN_H)
+
+-/* GLIBC headers included first so don't define anything
++/* LIBC headers included first so don't define anything
+ * that would already be defined. */
+ #define __UAPI_DEF_IN_ADDR 0
+ #define __UAPI_DEF_IN_IPPROTO 0
+@@ -68,7 +68,7 @@
+ * if the glibc code didn't define them. This guard matches
+ * the guard in glibc/inet/netinet/in.h which defines the
+ * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
+-#if defined(__USE_MISC) || defined (__USE_GNU)
++#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
+ #define __UAPI_DEF_IN6_ADDR_ALT 0
+ #else
+ #define __UAPI_DEF_IN6_ADDR_ALT 1
+@@ -81,7 +81,7 @@
+ #else
+
+ /* Linux headers included first, and we must define everything
+- * we need. The expectation is that glibc will check the
++ * we need. The expectation is that the libc will check the
+ * __UAPI_DEF_* defines and adjust appropriately. */
+ #define __UAPI_DEF_IN_ADDR 1
+ #define __UAPI_DEF_IN_IPPROTO 1
+@@ -91,7 +91,7 @@
+ #define __UAPI_DEF_IN_CLASS 1
+
+ #define __UAPI_DEF_IN6_ADDR 1
+-/* We unconditionally define the in6_addr macros and glibc must
++/* We unconditionally define the in6_addr macros and the libc must
+ * coordinate. */
+ #define __UAPI_DEF_IN6_ADDR_ALT 1
+ #define __UAPI_DEF_SOCKADDR_IN6 1
+@@ -111,7 +111,7 @@
+ /* If we did not see any headers from any supported C libraries,
+ * or we are being included in the kernel, then define everything
+ * that we need. */
+-#else /* !defined(__GLIBC__) */
++#else /* defined(__KERNEL__) */
+
+ /* Definitions for in.h */
+ #define __UAPI_DEF_IN_ADDR 1
+@@ -132,6 +132,6 @@
+ /* Definitions for xattr.h */
+ #define __UAPI_DEF_XATTR 1
+
+-#endif /* __GLIBC__ */
++#endif /* __KERNEL__ */
+
+ #endif /* _UAPI_LIBC_COMPAT_H */
diff --git a/target/linux/generic/patches-3.18/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch b/target/linux/generic/patches-3.18/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch
new file mode 100644
index 0000000000..feea4c31c6
--- /dev/null
+++ b/target/linux/generic/patches-3.18/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch
@@ -0,0 +1,67 @@
+From fcbb6fed85ea9ff4feb4f1ebd4f0f235fdaf06b6 Mon Sep 17 00:00:00 2001
+From: David Heidelberger <david.heidelberger@ixit.cz>
+Date: Mon, 29 Jun 2015 16:53:03 +0200
+Subject: [PATCH 3/3] uapi/if_ether.h: prevent redefinition of struct ethhdr
+
+Musl provides its own ethhdr struct definition. Add a guard to prevent
+its definition of the appropriate musl header has already been included.
+
+Signed-off-by: John Spencer <maillist-linux@barfooze.de>
+Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ include/uapi/linux/if_ether.h | 3 +++
+ include/uapi/linux/libc-compat.h | 11 +++++++++++
+ 2 files changed, 14 insertions(+)
+
+--- a/include/uapi/linux/if_ether.h
++++ b/include/uapi/linux/if_ether.h
+@@ -22,6 +22,7 @@
+ #define _UAPI_LINUX_IF_ETHER_H
+
+ #include <linux/types.h>
++#include <linux/libc-compat.h>
+
+ /*
+ * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
+@@ -134,11 +135,13 @@
+ * This is an Ethernet frame header.
+ */
+
++#if __UAPI_DEF_ETHHDR
+ struct ethhdr {
+ unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
+ unsigned char h_source[ETH_ALEN]; /* source ether addr */
+ __be16 h_proto; /* packet type ID field */
+ } __attribute__((packed));
++#endif
+
+
+ #endif /* _UAPI_LINUX_IF_ETHER_H */
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -51,6 +51,14 @@
+ /* We have included libc headers... */
+ #if !defined(__KERNEL__)
+
++/* musl defines the ethhdr struct itself in its netinet/if_ether.h.
++ * Glibc just includes the kernel header and uses a different guard. */
++#if defined(_NETINET_IF_ETHER_H)
++#define __UAPI_DEF_ETHHDR 0
++#else
++#define __UAPI_DEF_ETHHDR 1
++#endif
++
+ /* Coordinate with libc netinet/in.h header. */
+ #if defined(_NETINET_IN_H)
+
+@@ -113,6 +121,9 @@
+ * that we need. */
+ #else /* defined(__KERNEL__) */
+
++/* Definitions for if_ether.h */
++#define __UAPI_DEF_ETHHDR 1
++
+ /* Definitions for in.h */
+ #define __UAPI_DEF_IN_ADDR 1
+ #define __UAPI_DEF_IN_IPPROTO 1
diff --git a/target/linux/generic/patches-4.0/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch b/target/linux/generic/patches-4.0/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch
new file mode 100644
index 0000000000..d0bea944ac
--- /dev/null
+++ b/target/linux/generic/patches-4.0/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch
@@ -0,0 +1,146 @@
+From 279c6c7fa64f5763e6b9f05e7ab3840092e702e7 Mon Sep 17 00:00:00 2001
+From: Stephen Hemminger <stephen@networkplumber.org>
+Date: Mon, 29 Jun 2015 14:57:48 -1000
+Subject: [PATCH] api: fix compatibility of linux/in.h with netinet/in.h
+
+u
+This fixes breakage to iproute2 build with recent kernel headers
+caused by:
+ commit a263653ed798216c0069922d7b5237ca49436007
+ Author: Pablo Neira Ayuso <pablo@netfilter.org>
+ Date: Wed Jun 17 10:28:27 2015 -0500
+
+ netfilter: don't pull include/linux/netfilter.h from netns headers
+
+The issue is that definitions in linux/in.h overlap with those
+in netinet/in.h. This patch solves this by introducing the same
+mechanism as was used to solve the same problem with linux/in6.h
+
+Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ include/uapi/linux/in.h | 16 +++++++++++++---
+ include/uapi/linux/libc-compat.h | 22 ++++++++++++++++++++++
+ 2 files changed, 35 insertions(+), 3 deletions(-)
+
+--- a/include/uapi/linux/in.h
++++ b/include/uapi/linux/in.h
+@@ -19,8 +19,10 @@
+ #define _UAPI_LINUX_IN_H
+
+ #include <linux/types.h>
++#include <linux/libc-compat.h>
+ #include <linux/socket.h>
+
++#if __UAPI_DEF_IN_IPPROTO
+ /* Standard well-defined IP protocols. */
+ enum {
+ IPPROTO_IP = 0, /* Dummy protocol for TCP */
+@@ -73,12 +75,14 @@ enum {
+ #define IPPROTO_RAW IPPROTO_RAW
+ IPPROTO_MAX
+ };
++#endif
+
+-
++#if __UAPI_DEF_IN_ADDR
+ /* Internet address. */
+ struct in_addr {
+ __be32 s_addr;
+ };
++#endif
+
+ #define IP_TOS 1
+ #define IP_TTL 2
+@@ -155,6 +159,7 @@ struct in_addr {
+
+ /* Request struct for multicast socket ops */
+
++#if __UAPI_DEF_IP_MREQ
+ struct ip_mreq {
+ struct in_addr imr_multiaddr; /* IP multicast address of group */
+ struct in_addr imr_interface; /* local IP address of interface */
+@@ -206,14 +211,18 @@ struct group_filter {
+ #define GROUP_FILTER_SIZE(numsrc) \
+ (sizeof(struct group_filter) - sizeof(struct __kernel_sockaddr_storage) \
+ + (numsrc) * sizeof(struct __kernel_sockaddr_storage))
++#endif
+
++#if __UAPI_DEF_IN_PKTINFO
+ struct in_pktinfo {
+ int ipi_ifindex;
+ struct in_addr ipi_spec_dst;
+ struct in_addr ipi_addr;
+ };
++#endif
+
+ /* Structure describing an Internet (IP) socket address. */
++#if __UAPI_DEF_SOCKADDR_IN
+ #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
+ struct sockaddr_in {
+ __kernel_sa_family_t sin_family; /* Address family */
+@@ -225,8 +234,9 @@ struct sockaddr_in {
+ sizeof(unsigned short int) - sizeof(struct in_addr)];
+ };
+ #define sin_zero __pad /* for BSD UNIX comp. -FvK */
++#endif
+
+-
++#if __UAPI_DEF_IN_CLASS
+ /*
+ * Definitions of the bits in an Internet address integer.
+ * On subnets, host and network parts are found according
+@@ -277,7 +287,7 @@ struct sockaddr_in {
+ #define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
+ #define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
+ #define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */
+-
++#endif
+
+ /* <asm/byteorder.h> contains the htonl type stuff.. */
+ #include <asm/byteorder.h>
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -56,6 +56,13 @@
+
+ /* GLIBC headers included first so don't define anything
+ * that would already be defined. */
++#define __UAPI_DEF_IN_ADDR 0
++#define __UAPI_DEF_IN_IPPROTO 0
++#define __UAPI_DEF_IN_PKTINFO 0
++#define __UAPI_DEF_IP_MREQ 0
++#define __UAPI_DEF_SOCKADDR_IN 0
++#define __UAPI_DEF_IN_CLASS 0
++
+ #define __UAPI_DEF_IN6_ADDR 0
+ /* The exception is the in6_addr macros which must be defined
+ * if the glibc code didn't define them. This guard matches
+@@ -78,6 +85,13 @@
+ /* Linux headers included first, and we must define everything
+ * we need. The expectation is that glibc will check the
+ * __UAPI_DEF_* defines and adjust appropriately. */
++#define __UAPI_DEF_IN_ADDR 1
++#define __UAPI_DEF_IN_IPPROTO 1
++#define __UAPI_DEF_IN_PKTINFO 1
++#define __UAPI_DEF_IP_MREQ 1
++#define __UAPI_DEF_SOCKADDR_IN 1
++#define __UAPI_DEF_IN_CLASS 1
++
+ #define __UAPI_DEF_IN6_ADDR 1
+ /* We unconditionally define the in6_addr macros and glibc must
+ * coordinate. */
+@@ -103,6 +117,14 @@
+ * that we need. */
+ #else /* !defined(__GLIBC__) */
+
++/* Definitions for in.h */
++#define __UAPI_DEF_IN_ADDR 1
++#define __UAPI_DEF_IN_IPPROTO 1
++#define __UAPI_DEF_IN_PKTINFO 1
++#define __UAPI_DEF_IP_MREQ 1
++#define __UAPI_DEF_SOCKADDR_IN 1
++#define __UAPI_DEF_IN_CLASS 1
++
+ /* Definitions for in6.h */
+ #define __UAPI_DEF_IN6_ADDR 1
+ #define __UAPI_DEF_IN6_ADDR_ALT 1
diff --git a/target/linux/generic/patches-4.0/270-bridge_header_fix.patch b/target/linux/generic/patches-4.0/270-bridge_header_fix.patch
deleted file mode 100644
index 8b25db400a..0000000000
--- a/target/linux/generic/patches-4.0/270-bridge_header_fix.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/include/uapi/linux/if_bridge.h
-+++ b/include/uapi/linux/if_bridge.h
-@@ -15,7 +15,6 @@
-
- #include <linux/types.h>
- #include <linux/if_ether.h>
--#include <linux/in6.h>
-
- #define SYSFS_BRIDGE_ATTR "bridge"
- #define SYSFS_BRIDGE_FDB "brforward"
diff --git a/target/linux/generic/patches-4.0/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch b/target/linux/generic/patches-4.0/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch
new file mode 100644
index 0000000000..762f4989b6
--- /dev/null
+++ b/target/linux/generic/patches-4.0/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch
@@ -0,0 +1,34 @@
+From 8b05e325824d3b38e52a7748b3b5dc34dc1c0f6d Mon Sep 17 00:00:00 2001
+From: David Heidelberger <david.heidelberger@ixit.cz>
+Date: Mon, 29 Jun 2015 14:37:54 +0200
+Subject: [PATCH 1/3] uapi/kernel.h: glibc specific inclusion of sysinfo.h
+
+including sysinfo.h from kernel.h makes no sense whatsoever,
+but removing it breaks glibc's userspace header,
+which includes kernel.h instead of sysinfo.h from their sys/sysinfo.h.
+this seems to be a historical mistake.
+on musl, including any header that uses kernel.h directly or indirectly
+plus sys/sysinfo.h will produce a compile error due to redefinition of
+struct sysinfo from sys/sysinfo.h.
+so for now, only include it on glibc or when including from kernel
+in order not to break their headers.
+
+Signed-off-by: John Spencer <maillist-linux@barfooze.de>
+Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ include/uapi/linux/kernel.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/include/uapi/linux/kernel.h
++++ b/include/uapi/linux/kernel.h
+@@ -1,7 +1,9 @@
+ #ifndef _UAPI_LINUX_KERNEL_H
+ #define _UAPI_LINUX_KERNEL_H
+
++#if defined(__KERNEL__) || defined( __GLIBC__)
+ #include <linux/sysinfo.h>
++#endif
+
+ /*
+ * 'kernel.h' contains some often-used function prototypes etc
diff --git a/target/linux/generic/patches-4.0/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch b/target/linux/generic/patches-4.0/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch
new file mode 100644
index 0000000000..61d3873c01
--- /dev/null
+++ b/target/linux/generic/patches-4.0/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch
@@ -0,0 +1,81 @@
+From f972afc2509eebcb00d370256c55b112a3b5ffca Mon Sep 17 00:00:00 2001
+From: David Heidelberger <david.heidelberger@ixit.cz>
+Date: Mon, 29 Jun 2015 16:50:40 +0200
+Subject: [PATCH 2/3] uapi/libc-compat.h: do not rely on __GLIBC__
+
+Musl provides the same structs as glibc, but does not provide a define to
+allow its detection. Since the absence of __GLIBC__ also can mean that it
+is included from the kernel, change the __GLIBC__ detection to
+!__KERNEL__, which should always be true when included from userspace.
+
+Signed-off-by: John Spencer <maillist-linux@barfooze.de>
+Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ include/uapi/linux/libc-compat.h | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -48,13 +48,13 @@
+ #ifndef _UAPI_LIBC_COMPAT_H
+ #define _UAPI_LIBC_COMPAT_H
+
+-/* We have included glibc headers... */
+-#if defined(__GLIBC__)
++/* We have included libc headers... */
++#if !defined(__KERNEL__)
+
+-/* Coordinate with glibc netinet/in.h header. */
++/* Coordinate with libc netinet/in.h header. */
+ #if defined(_NETINET_IN_H)
+
+-/* GLIBC headers included first so don't define anything
++/* LIBC headers included first so don't define anything
+ * that would already be defined. */
+ #define __UAPI_DEF_IN_ADDR 0
+ #define __UAPI_DEF_IN_IPPROTO 0
+@@ -68,7 +68,7 @@
+ * if the glibc code didn't define them. This guard matches
+ * the guard in glibc/inet/netinet/in.h which defines the
+ * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
+-#if defined(__USE_MISC) || defined (__USE_GNU)
++#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
+ #define __UAPI_DEF_IN6_ADDR_ALT 0
+ #else
+ #define __UAPI_DEF_IN6_ADDR_ALT 1
+@@ -83,7 +83,7 @@
+ #else
+
+ /* Linux headers included first, and we must define everything
+- * we need. The expectation is that glibc will check the
++ * we need. The expectation is that the libc will check the
+ * __UAPI_DEF_* defines and adjust appropriately. */
+ #define __UAPI_DEF_IN_ADDR 1
+ #define __UAPI_DEF_IN_IPPROTO 1
+@@ -93,7 +93,7 @@
+ #define __UAPI_DEF_IN_CLASS 1
+
+ #define __UAPI_DEF_IN6_ADDR 1
+-/* We unconditionally define the in6_addr macros and glibc must
++/* We unconditionally define the in6_addr macros and the libc must
+ * coordinate. */
+ #define __UAPI_DEF_IN6_ADDR_ALT 1
+ #define __UAPI_DEF_SOCKADDR_IN6 1
+@@ -115,7 +115,7 @@
+ /* If we did not see any headers from any supported C libraries,
+ * or we are being included in the kernel, then define everything
+ * that we need. */
+-#else /* !defined(__GLIBC__) */
++#else /* defined(__KERNEL__) */
+
+ /* Definitions for in.h */
+ #define __UAPI_DEF_IN_ADDR 1
+@@ -138,6 +138,6 @@
+ /* Definitions for xattr.h */
+ #define __UAPI_DEF_XATTR 1
+
+-#endif /* __GLIBC__ */
++#endif /* __KERNEL__ */
+
+ #endif /* _UAPI_LIBC_COMPAT_H */
diff --git a/target/linux/generic/patches-4.0/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch b/target/linux/generic/patches-4.0/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch
new file mode 100644
index 0000000000..257c9d7e99
--- /dev/null
+++ b/target/linux/generic/patches-4.0/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch
@@ -0,0 +1,67 @@
+From fcbb6fed85ea9ff4feb4f1ebd4f0f235fdaf06b6 Mon Sep 17 00:00:00 2001
+From: David Heidelberger <david.heidelberger@ixit.cz>
+Date: Mon, 29 Jun 2015 16:53:03 +0200
+Subject: [PATCH 3/3] uapi/if_ether.h: prevent redefinition of struct ethhdr
+
+Musl provides its own ethhdr struct definition. Add a guard to prevent
+its definition of the appropriate musl header has already been included.
+
+Signed-off-by: John Spencer <maillist-linux@barfooze.de>
+Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ include/uapi/linux/if_ether.h | 3 +++
+ include/uapi/linux/libc-compat.h | 11 +++++++++++
+ 2 files changed, 14 insertions(+)
+
+--- a/include/uapi/linux/if_ether.h
++++ b/include/uapi/linux/if_ether.h
+@@ -22,6 +22,7 @@
+ #define _UAPI_LINUX_IF_ETHER_H
+
+ #include <linux/types.h>
++#include <linux/libc-compat.h>
+
+ /*
+ * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
+@@ -134,11 +135,13 @@
+ * This is an Ethernet frame header.
+ */
+
++#if __UAPI_DEF_ETHHDR
+ struct ethhdr {
+ unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
+ unsigned char h_source[ETH_ALEN]; /* source ether addr */
+ __be16 h_proto; /* packet type ID field */
+ } __attribute__((packed));
++#endif
+
+
+ #endif /* _UAPI_LINUX_IF_ETHER_H */
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -51,6 +51,14 @@
+ /* We have included libc headers... */
+ #if !defined(__KERNEL__)
+
++/* musl defines the ethhdr struct itself in its netinet/if_ether.h.
++ * Glibc just includes the kernel header and uses a different guard. */
++#if defined(_NETINET_IF_ETHER_H)
++#define __UAPI_DEF_ETHHDR 0
++#else
++#define __UAPI_DEF_ETHHDR 1
++#endif
++
+ /* Coordinate with libc netinet/in.h header. */
+ #if defined(_NETINET_IN_H)
+
+@@ -117,6 +125,9 @@
+ * that we need. */
+ #else /* defined(__KERNEL__) */
+
++/* Definitions for if_ether.h */
++#define __UAPI_DEF_ETHHDR 1
++
+ /* Definitions for in.h */
+ #define __UAPI_DEF_IN_ADDR 1
+ #define __UAPI_DEF_IN_IPPROTO 1
diff --git a/target/linux/generic/patches-4.1/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch b/target/linux/generic/patches-4.1/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch
new file mode 100644
index 0000000000..d0bea944ac
--- /dev/null
+++ b/target/linux/generic/patches-4.1/095-api-fix-compatibility-of-linux-in.h-with-netinet-in..patch
@@ -0,0 +1,146 @@
+From 279c6c7fa64f5763e6b9f05e7ab3840092e702e7 Mon Sep 17 00:00:00 2001
+From: Stephen Hemminger <stephen@networkplumber.org>
+Date: Mon, 29 Jun 2015 14:57:48 -1000
+Subject: [PATCH] api: fix compatibility of linux/in.h with netinet/in.h
+
+u
+This fixes breakage to iproute2 build with recent kernel headers
+caused by:
+ commit a263653ed798216c0069922d7b5237ca49436007
+ Author: Pablo Neira Ayuso <pablo@netfilter.org>
+ Date: Wed Jun 17 10:28:27 2015 -0500
+
+ netfilter: don't pull include/linux/netfilter.h from netns headers
+
+The issue is that definitions in linux/in.h overlap with those
+in netinet/in.h. This patch solves this by introducing the same
+mechanism as was used to solve the same problem with linux/in6.h
+
+Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ include/uapi/linux/in.h | 16 +++++++++++++---
+ include/uapi/linux/libc-compat.h | 22 ++++++++++++++++++++++
+ 2 files changed, 35 insertions(+), 3 deletions(-)
+
+--- a/include/uapi/linux/in.h
++++ b/include/uapi/linux/in.h
+@@ -19,8 +19,10 @@
+ #define _UAPI_LINUX_IN_H
+
+ #include <linux/types.h>
++#include <linux/libc-compat.h>
+ #include <linux/socket.h>
+
++#if __UAPI_DEF_IN_IPPROTO
+ /* Standard well-defined IP protocols. */
+ enum {
+ IPPROTO_IP = 0, /* Dummy protocol for TCP */
+@@ -73,12 +75,14 @@ enum {
+ #define IPPROTO_RAW IPPROTO_RAW
+ IPPROTO_MAX
+ };
++#endif
+
+-
++#if __UAPI_DEF_IN_ADDR
+ /* Internet address. */
+ struct in_addr {
+ __be32 s_addr;
+ };
++#endif
+
+ #define IP_TOS 1
+ #define IP_TTL 2
+@@ -155,6 +159,7 @@ struct in_addr {
+
+ /* Request struct for multicast socket ops */
+
++#if __UAPI_DEF_IP_MREQ
+ struct ip_mreq {
+ struct in_addr imr_multiaddr; /* IP multicast address of group */
+ struct in_addr imr_interface; /* local IP address of interface */
+@@ -206,14 +211,18 @@ struct group_filter {
+ #define GROUP_FILTER_SIZE(numsrc) \
+ (sizeof(struct group_filter) - sizeof(struct __kernel_sockaddr_storage) \
+ + (numsrc) * sizeof(struct __kernel_sockaddr_storage))
++#endif
+
++#if __UAPI_DEF_IN_PKTINFO
+ struct in_pktinfo {
+ int ipi_ifindex;
+ struct in_addr ipi_spec_dst;
+ struct in_addr ipi_addr;
+ };
++#endif
+
+ /* Structure describing an Internet (IP) socket address. */
++#if __UAPI_DEF_SOCKADDR_IN
+ #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
+ struct sockaddr_in {
+ __kernel_sa_family_t sin_family; /* Address family */
+@@ -225,8 +234,9 @@ struct sockaddr_in {
+ sizeof(unsigned short int) - sizeof(struct in_addr)];
+ };
+ #define sin_zero __pad /* for BSD UNIX comp. -FvK */
++#endif
+
+-
++#if __UAPI_DEF_IN_CLASS
+ /*
+ * Definitions of the bits in an Internet address integer.
+ * On subnets, host and network parts are found according
+@@ -277,7 +287,7 @@ struct sockaddr_in {
+ #define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
+ #define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
+ #define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */
+-
++#endif
+
+ /* <asm/byteorder.h> contains the htonl type stuff.. */
+ #include <asm/byteorder.h>
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -56,6 +56,13 @@
+
+ /* GLIBC headers included first so don't define anything
+ * that would already be defined. */
++#define __UAPI_DEF_IN_ADDR 0
++#define __UAPI_DEF_IN_IPPROTO 0
++#define __UAPI_DEF_IN_PKTINFO 0
++#define __UAPI_DEF_IP_MREQ 0
++#define __UAPI_DEF_SOCKADDR_IN 0
++#define __UAPI_DEF_IN_CLASS 0
++
+ #define __UAPI_DEF_IN6_ADDR 0
+ /* The exception is the in6_addr macros which must be defined
+ * if the glibc code didn't define them. This guard matches
+@@ -78,6 +85,13 @@
+ /* Linux headers included first, and we must define everything
+ * we need. The expectation is that glibc will check the
+ * __UAPI_DEF_* defines and adjust appropriately. */
++#define __UAPI_DEF_IN_ADDR 1
++#define __UAPI_DEF_IN_IPPROTO 1
++#define __UAPI_DEF_IN_PKTINFO 1
++#define __UAPI_DEF_IP_MREQ 1
++#define __UAPI_DEF_SOCKADDR_IN 1
++#define __UAPI_DEF_IN_CLASS 1
++
+ #define __UAPI_DEF_IN6_ADDR 1
+ /* We unconditionally define the in6_addr macros and glibc must
+ * coordinate. */
+@@ -103,6 +117,14 @@
+ * that we need. */
+ #else /* !defined(__GLIBC__) */
+
++/* Definitions for in.h */
++#define __UAPI_DEF_IN_ADDR 1
++#define __UAPI_DEF_IN_IPPROTO 1
++#define __UAPI_DEF_IN_PKTINFO 1
++#define __UAPI_DEF_IP_MREQ 1
++#define __UAPI_DEF_SOCKADDR_IN 1
++#define __UAPI_DEF_IN_CLASS 1
++
+ /* Definitions for in6.h */
+ #define __UAPI_DEF_IN6_ADDR 1
+ #define __UAPI_DEF_IN6_ADDR_ALT 1
diff --git a/target/linux/generic/patches-4.1/270-bridge_header_fix.patch b/target/linux/generic/patches-4.1/270-bridge_header_fix.patch
deleted file mode 100644
index 8b25db400a..0000000000
--- a/target/linux/generic/patches-4.1/270-bridge_header_fix.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/include/uapi/linux/if_bridge.h
-+++ b/include/uapi/linux/if_bridge.h
-@@ -15,7 +15,6 @@
-
- #include <linux/types.h>
- #include <linux/if_ether.h>
--#include <linux/in6.h>
-
- #define SYSFS_BRIDGE_ATTR "bridge"
- #define SYSFS_BRIDGE_FDB "brforward"
diff --git a/target/linux/generic/patches-4.1/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch b/target/linux/generic/patches-4.1/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch
new file mode 100644
index 0000000000..762f4989b6
--- /dev/null
+++ b/target/linux/generic/patches-4.1/270-uapi-kernel.h-glibc-specific-inclusion-of-sysinfo.h.patch
@@ -0,0 +1,34 @@
+From 8b05e325824d3b38e52a7748b3b5dc34dc1c0f6d Mon Sep 17 00:00:00 2001
+From: David Heidelberger <david.heidelberger@ixit.cz>
+Date: Mon, 29 Jun 2015 14:37:54 +0200
+Subject: [PATCH 1/3] uapi/kernel.h: glibc specific inclusion of sysinfo.h
+
+including sysinfo.h from kernel.h makes no sense whatsoever,
+but removing it breaks glibc's userspace header,
+which includes kernel.h instead of sysinfo.h from their sys/sysinfo.h.
+this seems to be a historical mistake.
+on musl, including any header that uses kernel.h directly or indirectly
+plus sys/sysinfo.h will produce a compile error due to redefinition of
+struct sysinfo from sys/sysinfo.h.
+so for now, only include it on glibc or when including from kernel
+in order not to break their headers.
+
+Signed-off-by: John Spencer <maillist-linux@barfooze.de>
+Signed-off-by: David Heidelberger <david.heidelberger@ixit.cz>
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ include/uapi/linux/kernel.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/include/uapi/linux/kernel.h
++++ b/include/uapi/linux/kernel.h
+@@ -1,7 +1,9 @@
+ #ifndef _UAPI_LINUX_KERNEL_H
+ #define _UAPI_LINUX_KERNEL_H
+
++#if defined(__KERNEL__) || defined( __GLIBC__)
+ #include <linux/sysinfo.h>
++#endif
+
+ /*
+ * 'kernel.h' contains some often-used function prototypes etc
diff --git a/target/linux/generic/patches-4.1/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch b/target/linux/generic/patches-4.1/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch
new file mode 100644
index 0000000000..61d3873c01
--- /dev/null
+++ b/target/linux/generic/patches-4.1/271-uapi-libc-compat.h-do-not-rely-on-__GLIBC__.patch
@@ -0,0 +1,81 @@
+From f972afc2509eebcb00d370256c55b112a3b5ffca Mon Sep 17 00:00:00 2001
+From: David Heidelberger <david.heidelberger@ixit.cz>
+Date: Mon, 29 Jun 2015 16:50:40 +0200
+Subject: [PATCH 2/3] uapi/libc-compat.h: do not rely on __GLIBC__
+
+Musl provides the same structs as glibc, but does not provide a define to
+allow its detection. Since the absence of __GLIBC__ also can mean that it
+is included from the kernel, change the __GLIBC__ detection to
+!__KERNEL__, which should always be true when included from userspace.
+
+Signed-off-by: John Spencer <maillist-linux@barfooze.de>
+Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ include/uapi/linux/libc-compat.h | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -48,13 +48,13 @@
+ #ifndef _UAPI_LIBC_COMPAT_H
+ #define _UAPI_LIBC_COMPAT_H
+
+-/* We have included glibc headers... */
+-#if defined(__GLIBC__)
++/* We have included libc headers... */
++#if !defined(__KERNEL__)
+
+-/* Coordinate with glibc netinet/in.h header. */
++/* Coordinate with libc netinet/in.h header. */
+ #if defined(_NETINET_IN_H)
+
+-/* GLIBC headers included first so don't define anything
++/* LIBC headers included first so don't define anything
+ * that would already be defined. */
+ #define __UAPI_DEF_IN_ADDR 0
+ #define __UAPI_DEF_IN_IPPROTO 0
+@@ -68,7 +68,7 @@
+ * if the glibc code didn't define them. This guard matches
+ * the guard in glibc/inet/netinet/in.h which defines the
+ * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
+-#if defined(__USE_MISC) || defined (__USE_GNU)
++#if !defined(__GLIBC__) || defined(__USE_MISC) || defined (__USE_GNU)
+ #define __UAPI_DEF_IN6_ADDR_ALT 0
+ #else
+ #define __UAPI_DEF_IN6_ADDR_ALT 1
+@@ -83,7 +83,7 @@
+ #else
+
+ /* Linux headers included first, and we must define everything
+- * we need. The expectation is that glibc will check the
++ * we need. The expectation is that the libc will check the
+ * __UAPI_DEF_* defines and adjust appropriately. */
+ #define __UAPI_DEF_IN_ADDR 1
+ #define __UAPI_DEF_IN_IPPROTO 1
+@@ -93,7 +93,7 @@
+ #define __UAPI_DEF_IN_CLASS 1
+
+ #define __UAPI_DEF_IN6_ADDR 1
+-/* We unconditionally define the in6_addr macros and glibc must
++/* We unconditionally define the in6_addr macros and the libc must
+ * coordinate. */
+ #define __UAPI_DEF_IN6_ADDR_ALT 1
+ #define __UAPI_DEF_SOCKADDR_IN6 1
+@@ -115,7 +115,7 @@
+ /* If we did not see any headers from any supported C libraries,
+ * or we are being included in the kernel, then define everything
+ * that we need. */
+-#else /* !defined(__GLIBC__) */
++#else /* defined(__KERNEL__) */
+
+ /* Definitions for in.h */
+ #define __UAPI_DEF_IN_ADDR 1
+@@ -138,6 +138,6 @@
+ /* Definitions for xattr.h */
+ #define __UAPI_DEF_XATTR 1
+
+-#endif /* __GLIBC__ */
++#endif /* __KERNEL__ */
+
+ #endif /* _UAPI_LIBC_COMPAT_H */
diff --git a/target/linux/generic/patches-4.1/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch b/target/linux/generic/patches-4.1/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch
new file mode 100644
index 0000000000..257c9d7e99
--- /dev/null
+++ b/target/linux/generic/patches-4.1/272-uapi-if_ether.h-prevent-redefinition-of-struct-ethhd.patch
@@ -0,0 +1,67 @@
+From fcbb6fed85ea9ff4feb4f1ebd4f0f235fdaf06b6 Mon Sep 17 00:00:00 2001
+From: David Heidelberger <david.heidelberger@ixit.cz>
+Date: Mon, 29 Jun 2015 16:53:03 +0200
+Subject: [PATCH 3/3] uapi/if_ether.h: prevent redefinition of struct ethhdr
+
+Musl provides its own ethhdr struct definition. Add a guard to prevent
+its definition of the appropriate musl header has already been included.
+
+Signed-off-by: John Spencer <maillist-linux@barfooze.de>
+Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
+Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+---
+ include/uapi/linux/if_ether.h | 3 +++
+ include/uapi/linux/libc-compat.h | 11 +++++++++++
+ 2 files changed, 14 insertions(+)
+
+--- a/include/uapi/linux/if_ether.h
++++ b/include/uapi/linux/if_ether.h
+@@ -22,6 +22,7 @@
+ #define _UAPI_LINUX_IF_ETHER_H
+
+ #include <linux/types.h>
++#include <linux/libc-compat.h>
+
+ /*
+ * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
+@@ -134,11 +135,13 @@
+ * This is an Ethernet frame header.
+ */
+
++#if __UAPI_DEF_ETHHDR
+ struct ethhdr {
+ unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
+ unsigned char h_source[ETH_ALEN]; /* source ether addr */
+ __be16 h_proto; /* packet type ID field */
+ } __attribute__((packed));
++#endif
+
+
+ #endif /* _UAPI_LINUX_IF_ETHER_H */
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -51,6 +51,14 @@
+ /* We have included libc headers... */
+ #if !defined(__KERNEL__)
+
++/* musl defines the ethhdr struct itself in its netinet/if_ether.h.
++ * Glibc just includes the kernel header and uses a different guard. */
++#if defined(_NETINET_IF_ETHER_H)
++#define __UAPI_DEF_ETHHDR 0
++#else
++#define __UAPI_DEF_ETHHDR 1
++#endif
++
+ /* Coordinate with libc netinet/in.h header. */
+ #if defined(_NETINET_IN_H)
+
+@@ -117,6 +125,9 @@
+ * that we need. */
+ #else /* defined(__KERNEL__) */
+
++/* Definitions for if_ether.h */
++#define __UAPI_DEF_ETHHDR 1
++
+ /* Definitions for in.h */
+ #define __UAPI_DEF_IN_ADDR 1
+ #define __UAPI_DEF_IN_IPPROTO 1