xref: /OK3568_Linux_fs/buildroot/package/arptables/0001-Fix-musl-build-issue.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From cbf84a0bc377c6a368d30571f37ebfab27784697 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
3Date: Wed, 2 Dec 2015 04:57:33 +0100
4Subject: [PATCH 4/4] Fix musl build issue
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Due to clashes in the namespace between the Linux Kernel headers and the
10netinet headers building arptables with the musl C library fails.
11
12Best advice from the musl developers is to not include both headers in a
13userspace tool (see the thread on the musl mailing list [1], especially [2]).
14
15Since arptables only requires a few definitions from the Linux Kernel headers
16we opt-out the clashing header files and define the needed definitions.
17
18[1] http://www.openwall.com/lists/musl/2012/10/09/1
19[2] http://www.openwall.com/lists/musl/2012/10/11/1
20
21Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
22---
23 extensions/arpt_CLASSIFY.c    |  7 +++++++
24 include/linux/netfilter_arp.h | 11 +++++++++++
25 2 files changed, 18 insertions(+)
26
27diff --git a/extensions/arpt_CLASSIFY.c b/extensions/arpt_CLASSIFY.c
28index cb5770b..c58129f 100644
29--- a/extensions/arpt_CLASSIFY.c
30+++ b/extensions/arpt_CLASSIFY.c
31@@ -21,7 +21,14 @@
32 #include <stdio.h>
33 #include <getopt.h>
34 #include <arptables.h>
35+
36+#ifdef __KERNEL__
37 #include <linux/netfilter/xt_CLASSIFY.h>
38+#else
39+struct xt_classify_target_info {
40+	uint32_t priority;
41+};
42+#endif
43
44 #define TC_H_MAJ_MASK (0xFFFF0000U)
45 #define TC_H_MIN_MASK (0x0000FFFFU)
46diff --git a/include/linux/netfilter_arp.h b/include/linux/netfilter_arp.h
47index 92bc6dd..2a63e82 100644
48--- a/include/linux/netfilter_arp.h
49+++ b/include/linux/netfilter_arp.h
50@@ -5,7 +5,18 @@
51  * (C)2002 Rusty Russell IBM -- This code is GPL.
52  */
53
54+#ifdef __KERNEL__
55 #include <linux/netfilter.h>
56+#else
57+/* Responses from hook functions. */
58+#define NF_DROP 0
59+#define NF_ACCEPT 1
60+#define NF_STOLEN 2
61+#define NF_QUEUE 3
62+#define NF_REPEAT 4
63+#define NF_STOP 5
64+#define NF_MAX_VERDICT NF_STOP
65+#endif
66
67 /* There is no PF_ARP. */
68 #define NF_ARP		0
69--
702.6.2
71
72