1From 6766ab322a9eb8c73f8276be9cdea356eb124de0 Mon Sep 17 00:00:00 2001 2From: Baruch Siach <baruch@tkos.co.il> 3Date: Thu, 11 Nov 2021 07:58:10 +0200 4Subject: [PATCH] Fix build with musl libc 5MIME-Version: 1.0 6Content-Type: text/plain; charset=UTF-8 7Content-Transfer-Encoding: 8bit 8 9musl libc defines its own struct ethhdr that conflicts with the kernel 10define one. The kernel headers provide a way to suppress its struct 11ethhdr. For that to work the libc headers must precede the kernel. Move 12the kernel linux/if_tun.h include below libc net/ethernet.h. That fixes 13the following build failure: 14 15In file included from .../arm-buildroot-linux-musleabihf/sysroot/usr/include/net/ethernet.h:10, 16 from ../include/headers.h:117, 17 from Thread.c:72: 18.../arm-buildroot-linux-musleabihf/sysroot/usr/include/netinet/if_ether.h:116:8: error: redefinition of ‘struct ethhdr’ 19 116 | struct ethhdr { 20 | ^~~~~~ 21In file included from .../arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/if_tun.h:20, 22 from ../include/headers.h:110, 23 from Thread.c:72: 24.../arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/if_ether.h:148:8: note: originally defined here 25 148 | struct ethhdr { 26 | ^~~~~~ 27 28Fixes bug #157. 29 30Signed-off-by: Baruch Siach <baruch@tkos.co.il> 31--- 32Upstream status: sent to Robert McMahon <rjmcmahon@rjmcmahon.com> 33 34 include/headers.h | 10 +++++----- 35 1 file changed, 5 insertions(+), 5 deletions(-) 36 37diff --git a/include/headers.h b/include/headers.h 38index 00e0ea0dba42..887490475381 100644 39--- a/include/headers.h 40+++ b/include/headers.h 41@@ -106,11 +106,6 @@ typedef bool _Bool; 42 #include <net/if.h> 43 #endif 44 45-#if ((HAVE_TUNTAP_TAP) || (HAVE_TUNTAP_TUN)) 46-#include <linux/if_tun.h> 47-#include <sys/ioctl.h> 48-#endif 49- 50 51 // AF_PACKET HEADERS 52 #if defined(HAVE_LINUX_FILTER_H) && defined(HAVE_AF_PACKET) 53@@ -146,6 +141,11 @@ typedef bool _Bool; 54 #define IPV6HDRLEN 40 55 #endif // HAVE_AF_PACKET 56 57+#if ((HAVE_TUNTAP_TAP) || (HAVE_TUNTAP_TUN)) 58+#include <linux/if_tun.h> 59+#include <sys/ioctl.h> 60+#endif 61+ 62 #ifdef WIN32 63 64 /* Windows config file */ 65-- 662.33.0 67 68