0004-vlan-fix-musl-libc-conflict-with-Linux-kernel-header.patch 2.21 KB
From 71a517e922c91e2c6cad28d339a081b5f6de0932 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
Date: Tue, 8 Mar 2016 21:07:12 +0100
Subject: [PATCH] vlan: fix musl libc conflict with Linux kernel headers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Due to both <netinet/in.h> (in "utils/includes.h") and <linux/in6.h> (in
<linux/if_bridge.h>) being included, the in6_addr is being redefined: once from
the C library headers and once from the Linux kernel headers. This causes some
build failures with for example the musl C library:

In file included from /usr/include/linux/if_bridge.h:18,
                 from ../src/ap/vlan_init.c:17:
/usr/include/linux/in6.h:32: error: redefinition of 'struct in6_addr'
/usr/include/linux/in6.h:49: error: redefinition of 'struct sockaddr_in6'
/usr/include/linux/in6.h:59: error: redefinition of 'struct ipv6_mreq'

Mixing C library and Linux kernel headers is a bit problematic [1] and should be
avoided if possible [2]. In order to fix this, define just the macros needed
from <linux/if_bridge.h> as done in Busybox for the brctl applet [3].

Upstream status: Pending [4]

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=15850
[2] http://www.openwall.com/lists/musl/2015/10/06/1
[3] https://git.busybox.net/busybox/commit/?id=5fa6d1a632505789409a2ba6cf8e112529f9db18
[4] http://lists.infradead.org/pipermail/hostap/2016-March/035357.html

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
---
 src/ap/vlan_init.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/ap/vlan_init.c b/src/ap/vlan_init.c
index 1670c0d..f2e3da0 100644
--- a/src/ap/vlan_init.c
+++ b/src/ap/vlan_init.c
@@ -14,7 +14,16 @@
 #include <sys/ioctl.h>
 #include <linux/sockios.h>
 #include <linux/if_vlan.h>
-#include <linux/if_bridge.h>
+/* From <linux/if_bridge.h> */
+#define BRCTL_GET_VERSION 0
+#define BRCTL_GET_BRIDGES 1
+#define BRCTL_ADD_BRIDGE 2
+#define BRCTL_DEL_BRIDGE 3
+#define BRCTL_ADD_IF 4
+#define BRCTL_DEL_IF 5
+#define BRCTL_GET_BRIDGE_INFO 6
+#define BRCTL_GET_PORT_LIST 7
+#define BRCTL_SET_BRIDGE_FORWARD_DELAY 8
 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
 
 #include "utils/common.h"
-- 
2.7.2