public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Qi.Chen@windriver.com
To: openembedded-core@lists.openembedded.org
Subject: [OE-core][PATCH 1/2] musl: avoid redefinition error on ethhdr
Date: Tue, 14 Oct 2025 20:15:12 +0800	[thread overview]
Message-ID: <20251014121513.2606389-1-Qi.Chen@windriver.com> (raw)

From: Chen Qi <Qi.Chen@windriver.com>

This __UAPI_DEF_ETHHDR macro should be defined right after
the definition of 'struct ethhdr', otherwise, we'll get
re-definition error in some case. This is because the
lines under 'struct ethhdr' definition are header file inclusion
lines and those header files might also check __UAPI_DEF_ETHHDR
and define ethhdr, resulting in redefinition error.

Another problem is that if_ether.h in musl should also consider
the possibility that other header files included before it also
defines struct ethhdr and __UAPI_DEF_ETHHDR.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 ...if_ether.h-define-__UAPI_DEF_ETHHDR-.patch | 39 +++++++++++++++++++
 ...if_ether.h-guard-ethhdr-definition-t.patch | 39 +++++++++++++++++++
 meta/recipes-core/musl/musl_git.bb            |  2 +
 3 files changed, 80 insertions(+)
 create mode 100644 meta/recipes-core/musl/musl/0001-include-netinet-if_ether.h-define-__UAPI_DEF_ETHHDR-.patch
 create mode 100644 meta/recipes-core/musl/musl/0001-include-netinet-if_ether.h-guard-ethhdr-definition-t.patch

diff --git a/meta/recipes-core/musl/musl/0001-include-netinet-if_ether.h-define-__UAPI_DEF_ETHHDR-.patch b/meta/recipes-core/musl/musl/0001-include-netinet-if_ether.h-define-__UAPI_DEF_ETHHDR-.patch
new file mode 100644
index 0000000000..800273612d
--- /dev/null
+++ b/meta/recipes-core/musl/musl/0001-include-netinet-if_ether.h-define-__UAPI_DEF_ETHHDR-.patch
@@ -0,0 +1,39 @@
+From 5ab64f7e08ea0325d83d446dd4015f82b4c179dd Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Mon, 29 Sep 2025 21:39:01 +0800
+Subject: [PATCH] include/netinet/if_ether.h: define __UAPI_DEF_ETHHDR early
+
+After 'struct ethhdr' is defined, we should immediately define
+__UAPI_DEF_ETHHDR. Because the following lines are header inclusion
+lines which might introduce header files checking __UAPI_DEF_ETHHDR.
+If we don't define this macro early, we will get redefinition error.
+
+Upstream-Status: Submitted [https://www.openwall.com/lists/musl/2025/09/30/1]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ include/netinet/if_ether.h | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/include/netinet/if_ether.h b/include/netinet/if_ether.h
+index 3479f511..b1646f6f 100644
+--- a/include/netinet/if_ether.h
++++ b/include/netinet/if_ether.h
+@@ -117,6 +117,7 @@ struct ethhdr {
+ 	uint8_t h_source[ETH_ALEN];
+ 	uint16_t h_proto;
+ };
++#define __UAPI_DEF_ETHHDR       0
+ 
+ #include <net/ethernet.h>
+ #include <net/if_arp.h>
+@@ -144,6 +145,4 @@ do { \
+ 	(enaddr)[5] = ((uint8_t *)ipaddr)[3]; \
+ } while(0)
+ 
+-#define __UAPI_DEF_ETHHDR       0
+-
+ #endif
+-- 
+2.34.1
+
diff --git a/meta/recipes-core/musl/musl/0001-include-netinet-if_ether.h-guard-ethhdr-definition-t.patch b/meta/recipes-core/musl/musl/0001-include-netinet-if_ether.h-guard-ethhdr-definition-t.patch
new file mode 100644
index 0000000000..343b0976ed
--- /dev/null
+++ b/meta/recipes-core/musl/musl/0001-include-netinet-if_ether.h-guard-ethhdr-definition-t.patch
@@ -0,0 +1,39 @@
+From 67976391887c3c65138a3b6fc306f2f5b490aeb4 Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Tue, 30 Sep 2025 10:42:51 +0800
+Subject: [PATCH] include/netinet/if_ether.h: guard ethhdr definition to better
+ work with other header files
+
+The unconditional definition of 'struct ethhdr' has the implicit
+requirement on this header file, that is, it needs to be included
+before other header files defining ethhdr.
+
+Upstream-Status: Submitted [https://www.openwall.com/lists/musl/2025/09/30/2]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ include/netinet/if_ether.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/include/netinet/if_ether.h b/include/netinet/if_ether.h
+index b1646f6f..e5a1ebd0 100644
+--- a/include/netinet/if_ether.h
++++ b/include/netinet/if_ether.h
+@@ -112,12 +112,14 @@
+ #define ETH_P_XDSA	0x00F8
+ #define ETH_P_MAP	0x00F9
+ 
++#ifndef __UAPI_DEF_ETHHDR
+ struct ethhdr {
+ 	uint8_t h_dest[ETH_ALEN];
+ 	uint8_t h_source[ETH_ALEN];
+ 	uint16_t h_proto;
+ };
+ #define __UAPI_DEF_ETHHDR       0
++#endif
+ 
+ #include <net/ethernet.h>
+ #include <net/if_arp.h>
+-- 
+2.34.1
+
diff --git a/meta/recipes-core/musl/musl_git.bb b/meta/recipes-core/musl/musl_git.bb
index 3f5fa37fba..ab4655b378 100644
--- a/meta/recipes-core/musl/musl_git.bb
+++ b/meta/recipes-core/musl/musl_git.bb
@@ -14,6 +14,8 @@ SRC_URI = "git://git.musl-libc.org/musl;branch=master \
            file://0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch \
            file://0002-ldso-Use-syslibdir-and-libdir-as-default-pathes-to-l.patch \
            file://0001-Update-syscalls-for-r32-rv64-from-kernel-6.4-through.patch \
+           file://0001-include-netinet-if_ether.h-define-__UAPI_DEF_ETHHDR-.patch \
+           file://0001-include-netinet-if_ether.h-guard-ethhdr-definition-t.patch \
           "
 
 PROVIDES += "virtual/libc virtual/libiconv virtual/libintl virtual/crypt"
-- 
2.34.1



             reply	other threads:[~2025-10-14 12:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 12:15 Qi.Chen [this message]
2025-10-14 12:15 ` [OE-core][PATCH 2/2] systemd: upgrade from 257.8 to 258 Qi.Chen
2025-10-15  8:44   ` Mathieu Dubois-Briand
2025-10-15  8:50     ` ChenQi
2025-10-15  3:33 ` [OE-core][PATCH 1/2] musl: avoid redefinition error on ethhdr ChenQi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251014121513.2606389-1-Qi.Chen@windriver.com \
    --to=qi.chen@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox