diff mbox series

xtables: fix compilation with musl

Message ID 20220516162448.24800-1-vincent@systemli.org
State Accepted
Delegated to: Pablo Neira
Headers show
Series xtables: fix compilation with musl | expand

Commit Message

Nick May 16, 2022, 4:24 p.m. UTC
From: Nick Hainke <vincent@systemli.org>

Only include <linux/if_ether.h> if bionic is used.

Fixes errors in the form of:
In file included from /home/nick/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-11.2.0_musl/include/netinet/ether.h:8,
                 from xtables.c:2238:
/home/nick/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-11.2.0_musl/include/netinet/if_ether.h:115:8: error: redefinition of 'struct ethhdr'
  115 | struct ethhdr {
      |        ^~~~~~
In file included from xtables.c:48:
/home/nick/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.15.38/user_headers/include/linux/if_ether.h:168:8: note: originally defined here
  168 | struct ethhdr {
      |        ^~~~~~
make[5]: *** [Makefile:471: libxtables_la-xtables.lo] Error 1

Signed-off-by: Nick Hainke <vincent@systemli.org>
---
 libxtables/xtables.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index 96fd783a..7dd7729d 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -45,7 +45,9 @@ 
 
 #include <xtables.h>
 #include <limits.h> /* INT_MAX in ip_tables.h/ip6_tables.h */
+#ifdef __BIONIC__
 #include <linux/if_ether.h> /* ETH_ALEN */
+#endif
 #include <linux/netfilter_ipv4/ip_tables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <libiptc/libxtc.h>