diff mbox

[OpenWrt-Devel] linux-3.18: prevent redefinition of struct ethhdr

Message ID 1434902002-18745-1-git-send-email-amery@geeks.cl
State Accepted
Delegated to: Jonas Gorski
Headers show

Commit Message

Alejandro Mery June 21, 2015, 3:53 p.m. UTC
when using musl packages include netinet/ether.h break because
struct ethhdr gets redefined.

this patch comes includes a patch originally from sabotage linux
and it has been submitted upstream https://lkml.org/lkml/2014/3/14/266

Signed-off-by: Alejandro Mery <amery@geeks.cl>
---
 ...206-prevent-redefinition-of-struct-ethhdr.patch | 53 ++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 target/linux/generic/patches-3.18/206-prevent-redefinition-of-struct-ethhdr.patch

Comments

Karl Palsson June 22, 2015, 10:32 a.m. UTC | #1
Alejandro Mery <amery@geeks.cl> wrote:
> when using musl packages include netinet/ether.h break because
> struct ethhdr gets redefined.
> 
> this patch comes includes a patch originally from sabotage linux
> and it has been submitted upstream https://lkml.org/lkml/2014/3/14/266
> 

If this gets merged, could we then drop the large and growing pile of
musl ether.h patches in each of the packages?  Is this going to get
_merged_ upstream, or was it just posted to LKML?  I didn't see any discussion of it there.

Cheers,
Karl P
Alejandro Mery June 22, 2015, 8:08 p.m. UTC | #2
Hi,

On 22/06/15 11:32, Karl Palsson wrote:
>
> Alejandro Mery <amery@geeks.cl> wrote:
>> when using musl packages include netinet/ether.h break because
>> struct ethhdr gets redefined.
>>
>> this patch comes includes a patch originally from sabotage linux
>> and it has been submitted upstream https://lkml.org/lkml/2014/3/14/266
>>
>
> If this gets merged, could we then drop the large and growing pile of
> musl ether.h patches in each of the packages?  Is this going to get
> _merged_ upstream, or was it just posted to LKML?  I didn't see any discussion of it there.

not sure if *all* related patches can be removed because some packages 
do very nasty stuff, but this at least fixes those not doing 
define/include witchcraft. also, here I'm only patching 3.18 and will 
4.0 need similar love.

this patch is happily used by openembedded and sabotage linux, but it 
might take a while upstream decides to take it into consideration... 
it's not that they enjoy becoming part of libc wars.

but they did at least replace the #ifdef __GLIBC__ with a #ifndef 
__KERNEL__ in libc-compat.h, and that's something :)

cheers,
Alejandro Mery
Jonas Gorski July 4, 2015, 10:48 a.m. UTC | #3
Hi,

On Sun, Jun 21, 2015 at 5:53 PM, Alejandro Mery <amery@geeks.cl> wrote:
> when using musl packages include netinet/ether.h break because
> struct ethhdr gets redefined.
>
> this patch comes includes a patch originally from sabotage linux
> and it has been submitted upstream https://lkml.org/lkml/2014/3/14/266
>
> Signed-off-by: Alejandro Mery <amery@geeks.cl>

I committed the whole patchseries slightly reworked in r46161, which
should improve the situation a bit. I plan to resubmit them myself
when the merge window closes, in the hope to eventually have them
included upstream. The original submission seems to have missed the
right mailing lists and was whitespace broken, which probably caused
it to be ignored / overlooked.

Of course this still requires libc headers before kernel headers, but
at least that order should now work.


Jonas
diff mbox

Patch

diff --git a/target/linux/generic/patches-3.18/206-prevent-redefinition-of-struct-ethhdr.patch b/target/linux/generic/patches-3.18/206-prevent-redefinition-of-struct-ethhdr.patch
new file mode 100644
index 0000000..e888320
--- /dev/null
+++ b/target/linux/generic/patches-3.18/206-prevent-redefinition-of-struct-ethhdr.patch
@@ -0,0 +1,53 @@ 
+From 4ffbb51f2abfbefa73cbd418f55b20148d04959a Mon Sep 17 00:00:00 2001
+From: rofl0r <retnyg@gmx.net>
+Date: Wed, 22 Jan 2014 00:57:48 +0100
+Subject: [PATCH] libc-compat.h: prevent redefinition of struct ethhdr
+
+---
+ generic/include/linux/if_ether.h    | 4 +++-
+ generic/include/linux/libc-compat.h | 6 ++++++
+ 2 files changed, 9 insertions(+), 1 deletion(-)
+
+Index: linux-3.19/include/uapi/linux/if_ether.h
+===================================================================
+--- linux-3.19.orig/include/uapi/linux/if_ether.h
++++ linux-3.19/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,12 @@
+  *	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 */
+Index: linux-3.19/include/uapi/linux/libc-compat.h
+===================================================================
+--- linux-3.18.16.orig/include/uapi/linux/libc-compat.h
++++ linux-3.18.16/include/uapi/linux/libc-compat.h
+@@ -48,6 +48,12 @@
+ #ifndef _UAPI_LIBC_COMPAT_H
+ #define _UAPI_LIBC_COMPAT_H
+ 
++#ifdef _NETINET_IF_ETHER_H /* musl */
++#define __UAPI_DEF_ETHHDR 0
++#else /* glibc uses __NETINET_IF_ETHER_H, and includes the kernel header. */
++#define __UAPI_DEF_ETHHDR 1
++#endif
++
+ /* We have included glibc headers... */
+ #if defined(__GLIBC__)
+