aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
Diffstat (limited to 'package')
-rw-r--r--package/network/utils/iptables/Makefile7
-rw-r--r--package/network/utils/iptables/patches/001-xtables-Call-init_extensions6-for-static-builds.patch68
-rw-r--r--package/network/utils/iptables/patches/002-xtables-Call-init_extensions_a_b.patch107
-rw-r--r--package/network/utils/iptables/patches/020-treewide-use-uint-instead-of-u_int.patch144
-rw-r--r--package/network/utils/iptables/patches/030-revert-fix-build-for-missing-ETH_ALEN-definition.patch60
-rw-r--r--package/network/utils/iptables/patches/040-xshared-Fix-build-for-Werror-format-security.patch23
-rw-r--r--package/network/utils/iptables/patches/050-build-fix-error-during-out-of-tree-build.patch28
-rw-r--r--package/network/utils/iptables/patches/060-libxtables-unexport-init_extensions-declarations.patch82
-rw-r--r--package/network/utils/iptables/patches/101-remove-check-already.patch4
-rw-r--r--package/network/utils/iptables/patches/102-iptables-disable-modprobe.patch13
-rw-r--r--package/network/utils/iptables/patches/200-configurable_builtin.patch2
-rw-r--r--package/network/utils/iptables/patches/600-shared-libext.patch2
-rw-r--r--package/network/utils/iptables/patches/700-disable-legacy-revisions.patch14
13 files changed, 362 insertions, 192 deletions
diff --git a/package/network/utils/iptables/Makefile b/package/network/utils/iptables/Makefile
index 6546067553..fdb1aa916b 100644
--- a/package/network/utils/iptables/Makefile
+++ b/package/network/utils/iptables/Makefile
@@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=iptables
-PKG_VERSION:=1.8.7
-PKG_RELEASE:=7
+PKG_VERSION:=1.8.8
+PKG_RELEASE:=1
PKG_SOURCE_URL:=https://netfilter.org/projects/iptables/files
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
-PKG_HASH:=c109c96bb04998cd44156622d36f8e04b140701ec60531a10668cfdff5e8d8f0
+PKG_HASH:=71c75889dc710676631553eb1511da0177bbaaf1b551265b912d236c3f51859f
PKG_FIXUP:=autoreconf
PKG_FLAGS:=nonshared
@@ -650,7 +650,6 @@ define Build/InstallDev
$(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
$(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/include/ip6tables.h $(1)/usr/include/
- $(CP) $(PKG_BUILD_DIR)/include/libipulog $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
diff --git a/package/network/utils/iptables/patches/001-xtables-Call-init_extensions6-for-static-builds.patch b/package/network/utils/iptables/patches/001-xtables-Call-init_extensions6-for-static-builds.patch
deleted file mode 100644
index 22ccfa533a..0000000000
--- a/package/network/utils/iptables/patches/001-xtables-Call-init_extensions6-for-static-builds.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-From e727ccad036e2cdba3339536c65c7ceef43c0740 Mon Sep 17 00:00:00 2001
-From: Erik Wilson <erik.e.wilson@gmail.com>
-Date: Tue, 13 Jul 2021 16:48:23 -0700
-Subject: [PATCH] xtables: Call init_extensions6() for static builds
-
-Initialize extensions from libext6 for cases where xtables is built statically.
-
-Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1550
-Signed-off-by: Erik Wilson <Erik.E.Wilson@gmail.com>
-Signed-off-by: Florian Westphal <fw@strlen.de>
----
- iptables/xtables-monitor.c | 1 +
- iptables/xtables-restore.c | 1 +
- iptables/xtables-save.c | 1 +
- iptables/xtables-standalone.c | 1 +
- iptables/xtables-translate.c | 1 +
- 5 files changed, 5 insertions(+)
-
---- a/iptables/xtables-monitor.c
-+++ b/iptables/xtables-monitor.c
-@@ -628,6 +628,7 @@ int xtables_monitor_main(int argc, char
- #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
- init_extensions();
- init_extensions4();
-+ init_extensions6();
- #endif
-
- if (nft_init(&h, AF_INET, xtables_ipv4)) {
---- a/iptables/xtables-restore.c
-+++ b/iptables/xtables-restore.c
-@@ -364,6 +364,7 @@ xtables_restore_main(int family, const c
- #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
- init_extensions();
- init_extensions4();
-+ init_extensions6();
- #endif
- break;
- case NFPROTO_ARP:
---- a/iptables/xtables-save.c
-+++ b/iptables/xtables-save.c
-@@ -202,6 +202,7 @@ xtables_save_main(int family, int argc,
- #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
- init_extensions();
- init_extensions4();
-+ init_extensions6();
- #endif
- tables = xtables_ipv4;
- d.commit = true;
---- a/iptables/xtables-standalone.c
-+++ b/iptables/xtables-standalone.c
-@@ -57,6 +57,7 @@ xtables_main(int family, const char *pro
- #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
- init_extensions();
- init_extensions4();
-+ init_extensions6();
- #endif
-
- if (nft_init(&h, family, xtables_ipv4) < 0) {
---- a/iptables/xtables-translate.c
-+++ b/iptables/xtables-translate.c
-@@ -469,6 +469,7 @@ static int xtables_xlate_main_common(str
- #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
- init_extensions();
- init_extensions4();
-+ init_extensions6();
- #endif
- tables = xtables_ipv4;
- break;
diff --git a/package/network/utils/iptables/patches/002-xtables-Call-init_extensions_a_b.patch b/package/network/utils/iptables/patches/002-xtables-Call-init_extensions_a_b.patch
deleted file mode 100644
index 0d7226ccd5..0000000000
--- a/package/network/utils/iptables/patches/002-xtables-Call-init_extensions_a_b.patch
+++ /dev/null
@@ -1,107 +0,0 @@
-A modified version of this patch was commited upstream
-as part of a fixup series
-https://bugzilla.netfilter.org/show_bug.cgi?id=1593
-https://git.netfilter.org/iptables/commit/?id=0836524f093c0fd9c39604a46a949e43d9b47ef2
-
---- a/iptables/xtables-monitor.c
-+++ b/iptables/xtables-monitor.c
-@@ -629,6 +629,8 @@ int xtables_monitor_main(int argc, char
- init_extensions();
- init_extensions4();
- init_extensions6();
-+ init_extensionsa();
-+ init_extensionsb();
- #endif
-
- if (nft_init(&h, AF_INET, xtables_ipv4)) {
---- a/iptables/xtables-restore.c
-+++ b/iptables/xtables-restore.c
-@@ -368,9 +368,17 @@ xtables_restore_main(int family, const c
- #endif
- break;
- case NFPROTO_ARP:
-+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
-+ init_extensions();
-+ init_extensionsa();
-+#endif
- tables = xtables_arp;
- break;
- case NFPROTO_BRIDGE:
-+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
-+ init_extensions();
-+ init_extensionsb();
-+#endif
- tables = xtables_bridge;
- break;
- default:
---- a/iptables/xtables-save.c
-+++ b/iptables/xtables-save.c
-@@ -208,9 +208,17 @@ xtables_save_main(int family, int argc,
- d.commit = true;
- break;
- case NFPROTO_ARP:
-+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
-+ init_extensions();
-+ init_extensionsa();
-+#endif
- tables = xtables_arp;
- break;
- case NFPROTO_BRIDGE: {
-+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
-+ init_extensions();
-+ init_extensionsb();
-+#endif
- const char *ctr = getenv("EBTABLES_SAVE_COUNTER");
-
- if (!(d.format & FMT_NOCOUNTS)) {
---- a/iptables/xtables-standalone.c
-+++ b/iptables/xtables-standalone.c
-@@ -58,6 +58,8 @@ xtables_main(int family, const char *pro
- init_extensions();
- init_extensions4();
- init_extensions6();
-+ init_extensionsa();
-+ init_extensionsb();
- #endif
-
- if (nft_init(&h, family, xtables_ipv4) < 0) {
---- a/iptables/xtables-translate.c
-+++ b/iptables/xtables-translate.c
-@@ -474,9 +474,17 @@ static int xtables_xlate_main_common(str
- tables = xtables_ipv4;
- break;
- case NFPROTO_ARP:
-+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
-+ init_extensions();
-+ init_extensionsa();
-+#endif
- tables = xtables_arp;
- break;
- case NFPROTO_BRIDGE:
-+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
-+ init_extensions();
-+ init_extensionsb();
-+#endif
- tables = xtables_bridge;
- break;
- default:
---- a/iptables/xtables-arp.c
-+++ b/iptables/xtables-arp.c
-@@ -438,6 +438,7 @@ int nft_init_arp(struct nft_handle *h, c
- }
-
- #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
-+ init_extensions();
- init_extensionsa();
- #endif
-
---- a/iptables/xtables-eb.c
-+++ b/iptables/xtables-eb.c
-@@ -685,6 +685,7 @@ int nft_init_eb(struct nft_handle *h, co
- }
-
- #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
-+ init_extensions();
- init_extensionsb();
- #endif
-
diff --git a/package/network/utils/iptables/patches/020-treewide-use-uint-instead-of-u_int.patch b/package/network/utils/iptables/patches/020-treewide-use-uint-instead-of-u_int.patch
new file mode 100644
index 0000000000..e4b0cd92de
--- /dev/null
+++ b/package/network/utils/iptables/patches/020-treewide-use-uint-instead-of-u_int.patch
@@ -0,0 +1,144 @@
+From f319389525b066b7dc6d389c88f16a0df3b8f189 Mon Sep 17 00:00:00 2001
+From: Nick Hainke <vincent@systemli.org>
+Date: Mon, 16 May 2022 18:16:41 +0200
+Subject: treewide: use uint* instead of u_int*
+
+Gcc complains about missing types. Some commits introduced u_int* instead
+of uint*. Use uint treewide.
+
+Fixes errors in the form of:
+In file included from xtables-legacy-multi.c:5:
+xshared.h:83:56: error: unknown type name 'u_int16_t'; did you mean 'uint16_t'?
+ 83 | set_option(unsigned int *options, unsigned int option, u_int16_t *invflg,
+ | ^~~~~~~~~
+ | uint16_t
+make[6]: *** [Makefile:712: xtables_legacy_multi-xtables-legacy-multi.o] Error 1
+
+Avoid libipq API breakage by adjusting libipq.h include accordingly. For
+arpt_mangle.h kernel uAPI header, apply same change as in kernel commit
+e91ded8db5747 ("uapi: netfilter_arp: use __u8 instead of u_int8_t").
+
+Signed-off-by: Nick Hainke <vincent@systemli.org>
+Signed-off-by: Phil Sutter <phil@nwl.cc>
+---
+ extensions/libxt_conntrack.c | 2 +-
+ include/libipq/libipq.h | 8 ++++----
+ include/libiptc/libxtc.h | 2 +-
+ include/linux/netfilter_arp/arpt_mangle.h | 2 +-
+ iptables/xshared.c | 2 +-
+ iptables/xshared.h | 2 +-
+ libipq/ipq_create_handle.3 | 2 +-
+ libipq/ipq_set_mode.3 | 2 +-
+ 8 files changed, 11 insertions(+), 11 deletions(-)
+
+--- a/extensions/libxt_conntrack.c
++++ b/extensions/libxt_conntrack.c
+@@ -778,7 +778,7 @@ matchinfo_print(const void *ip, const st
+
+ static void
+ conntrack_dump_ports(const char *prefix, const char *opt,
+- u_int16_t port_low, u_int16_t port_high)
++ uint16_t port_low, uint16_t port_high)
+ {
+ if (port_high == 0 || port_low == port_high)
+ printf(" %s%s %u", prefix, opt, port_low);
+--- a/include/libipq/libipq.h
++++ b/include/libipq/libipq.h
+@@ -24,7 +24,7 @@
+ #include <errno.h>
+ #include <unistd.h>
+ #include <fcntl.h>
+-#include <sys/types.h>
++#include <stdint.h>
+ #include <sys/socket.h>
+ #include <sys/uio.h>
+ #include <asm/types.h>
+@@ -48,19 +48,19 @@ typedef unsigned long ipq_id_t;
+ struct ipq_handle
+ {
+ int fd;
+- u_int8_t blocking;
++ uint8_t blocking;
+ struct sockaddr_nl local;
+ struct sockaddr_nl peer;
+ };
+
+-struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol);
++struct ipq_handle *ipq_create_handle(uint32_t flags, uint32_t protocol);
+
+ int ipq_destroy_handle(struct ipq_handle *h);
+
+ ssize_t ipq_read(const struct ipq_handle *h,
+ unsigned char *buf, size_t len, int timeout);
+
+-int ipq_set_mode(const struct ipq_handle *h, u_int8_t mode, size_t len);
++int ipq_set_mode(const struct ipq_handle *h, uint8_t mode, size_t len);
+
+ ipq_packet_msg_t *ipq_get_packet(const unsigned char *buf);
+
+--- a/include/libiptc/libxtc.h
++++ b/include/libiptc/libxtc.h
+@@ -10,7 +10,7 @@ extern "C" {
+ #endif
+
+ #ifndef XT_MIN_ALIGN
+-/* xt_entry has pointers and u_int64_t's in it, so if you align to
++/* xt_entry has pointers and uint64_t's in it, so if you align to
+ it, you'll also align to any crazy matches and targets someone
+ might write */
+ #define XT_MIN_ALIGN (__alignof__(struct xt_entry))
+--- a/include/linux/netfilter_arp/arpt_mangle.h
++++ b/include/linux/netfilter_arp/arpt_mangle.h
+@@ -13,7 +13,7 @@ struct arpt_mangle
+ union {
+ struct in_addr tgt_ip;
+ } u_t;
+- u_int8_t flags;
++ __u8 flags;
+ int target;
+ };
+
+--- a/iptables/xshared.c
++++ b/iptables/xshared.c
+@@ -1025,7 +1025,7 @@ static const int inverse_for_options[NUM
+ };
+
+ void
+-set_option(unsigned int *options, unsigned int option, u_int16_t *invflg,
++set_option(unsigned int *options, unsigned int option, uint16_t *invflg,
+ bool invert)
+ {
+ if (*options & option)
+--- a/iptables/xshared.h
++++ b/iptables/xshared.h
+@@ -80,7 +80,7 @@ struct xtables_target;
+ #define IPT_INV_ARPHRD 0x0800
+
+ void
+-set_option(unsigned int *options, unsigned int option, u_int16_t *invflg,
++set_option(unsigned int *options, unsigned int option, uint16_t *invflg,
+ bool invert);
+
+ /**
+--- a/libipq/ipq_create_handle.3
++++ b/libipq/ipq_create_handle.3
+@@ -24,7 +24,7 @@ ipq_create_handle, ipq_destroy_handle \(
+ .br
+ .B #include <libipq.h>
+ .sp
+-.BI "struct ipq_handle *ipq_create_handle(u_int32_t " flags ", u_int32_t " protocol ");"
++.BI "struct ipq_handle *ipq_create_handle(uint32_t " flags ", uint32_t " protocol ");"
+ .br
+ .BI "int ipq_destroy_handle(struct ipq_handle *" h );
+ .SH DESCRIPTION
+--- a/libipq/ipq_set_mode.3
++++ b/libipq/ipq_set_mode.3
+@@ -24,7 +24,7 @@ ipq_set_mode \(em set the ip_queue queui
+ .br
+ .B #include <libipq.h>
+ .sp
+-.BI "int ipq_set_mode(const struct ipq_handle *" h ", u_int8_t " mode ", size_t " range );
++.BI "int ipq_set_mode(const struct ipq_handle *" h ", uint8_t " mode ", size_t " range );
+ .SH DESCRIPTION
+ The
+ .B ipq_set_mode
diff --git a/package/network/utils/iptables/patches/030-revert-fix-build-for-missing-ETH_ALEN-definition.patch b/package/network/utils/iptables/patches/030-revert-fix-build-for-missing-ETH_ALEN-definition.patch
new file mode 100644
index 0000000000..6c8e3deb5c
--- /dev/null
+++ b/package/network/utils/iptables/patches/030-revert-fix-build-for-missing-ETH_ALEN-definition.patch
@@ -0,0 +1,60 @@
+From 0e7cf0ad306cdf95dc3c28d15a254532206a888e Mon Sep 17 00:00:00 2001
+From: Phil Sutter <phil@nwl.cc>
+Date: Wed, 18 May 2022 16:04:09 +0200
+Subject: Revert "fix build for missing ETH_ALEN definition"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This reverts commit c5d9a723b5159a28f547b577711787295a14fd84 as it broke
+compiling against musl libc. Might be a bug in the latter, but for the
+time being try to please both by avoiding the include and instead
+defining ETH_ALEN if unset.
+
+While being at it, move netinet/ether.h include up.
+
+Fixes: 1bdb5535f561a ("libxtables: Extend MAC address printing/parsing support")
+Signed-off-by: Phil Sutter <phil@nwl.cc>
+Reviewed-by: Maciej Żenczykowski <maze@google.com>
+---
+ libxtables/xtables.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+--- a/libxtables/xtables.c
++++ b/libxtables/xtables.c
+@@ -28,6 +28,7 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
++#include <netinet/ether.h>
+ #include <sys/socket.h>
+ #include <sys/stat.h>
+ #include <sys/statfs.h>
+@@ -45,7 +46,6 @@
+
+ #include <xtables.h>
+ #include <limits.h> /* INT_MAX in ip_tables.h/ip6_tables.h */
+-#include <linux/if_ether.h> /* ETH_ALEN */
+ #include <linux/netfilter_ipv4/ip_tables.h>
+ #include <linux/netfilter_ipv6/ip6_tables.h>
+ #include <libiptc/libxtc.h>
+@@ -72,6 +72,10 @@
+ #define PROC_SYS_MODPROBE "/proc/sys/kernel/modprobe"
+ #endif
+
++#ifndef ETH_ALEN
++#define ETH_ALEN 6
++#endif
++
+ /* we need this for ip6?tables-restore. ip6?tables-restore.c sets line to the
+ * current line of the input file, in order to give a more precise error
+ * message. ip6?tables itself doesn't need this, so it is initialized to the
+@@ -2245,8 +2249,6 @@ void xtables_print_num(uint64_t number,
+ printf(FMT("%4lluT ","%lluT "), (unsigned long long)number);
+ }
+
+-#include <netinet/ether.h>
+-
+ static const unsigned char mac_type_unicast[ETH_ALEN] = {};
+ static const unsigned char msk_type_unicast[ETH_ALEN] = {1};
+ static const unsigned char mac_type_multicast[ETH_ALEN] = {1};
diff --git a/package/network/utils/iptables/patches/040-xshared-Fix-build-for-Werror-format-security.patch b/package/network/utils/iptables/patches/040-xshared-Fix-build-for-Werror-format-security.patch
new file mode 100644
index 0000000000..f7e5e34c73
--- /dev/null
+++ b/package/network/utils/iptables/patches/040-xshared-Fix-build-for-Werror-format-security.patch
@@ -0,0 +1,23 @@
+From b72eb12ea5a61df0655ad99d5048994e916be83a Mon Sep 17 00:00:00 2001
+From: Phil Sutter <phil@nwl.cc>
+Date: Fri, 13 May 2022 16:51:58 +0200
+Subject: [PATCH] xshared: Fix build for -Werror=format-security
+
+Gcc complains about the omitted format string.
+
+Signed-off-by: Phil Sutter <phil@nwl.cc>
+---
+ iptables/xshared.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/iptables/xshared.c
++++ b/iptables/xshared.c
+@@ -1307,7 +1307,7 @@ static void check_empty_interface(struct
+ return;
+
+ if (args->family != NFPROTO_ARP)
+- xtables_error(PARAMETER_PROBLEM, msg);
++ xtables_error(PARAMETER_PROBLEM, "%s", msg);
+
+ fprintf(stderr, "%s", msg);
+ }
diff --git a/package/network/utils/iptables/patches/050-build-fix-error-during-out-of-tree-build.patch b/package/network/utils/iptables/patches/050-build-fix-error-during-out-of-tree-build.patch
new file mode 100644
index 0000000000..acfca96e0f
--- /dev/null
+++ b/package/network/utils/iptables/patches/050-build-fix-error-during-out-of-tree-build.patch
@@ -0,0 +1,28 @@
+From 0ebf52fc951b2a4d98a166afb34af4f364bbeece Mon Sep 17 00:00:00 2001
+From: Ben Brown <ben@demerara.io>
+Date: Wed, 25 May 2022 16:26:13 +0100
+Subject: build: Fix error during out of tree build
+
+Fixes the following error:
+
+ ../../libxtables/xtables.c:52:10: fatal error: libiptc/linux_list.h: No such file or directory
+ 52 | #include <libiptc/linux_list.h>
+
+Fixes: f58b0d7406451 ("libxtables: Implement notargets hash table")
+Signed-off-by: Ben Brown <ben@demerara.io>
+Signed-off-by: Phil Sutter <phil@nwl.cc>
+---
+ libxtables/Makefile.am | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/libxtables/Makefile.am
++++ b/libxtables/Makefile.am
+@@ -1,7 +1,7 @@
+ # -*- Makefile -*-
+
+ AM_CFLAGS = ${regular_CFLAGS}
+-AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_builddir}/include -I${top_srcdir}/include -I${top_srcdir}/iptables ${kinclude_CPPFLAGS}
++AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_builddir}/include -I${top_srcdir}/include -I${top_srcdir}/iptables -I${top_srcdir} ${kinclude_CPPFLAGS}
+
+ lib_LTLIBRARIES = libxtables.la
+ libxtables_la_SOURCES = xtables.c xtoptions.c getethertype.c
diff --git a/package/network/utils/iptables/patches/060-libxtables-unexport-init_extensions-declarations.patch b/package/network/utils/iptables/patches/060-libxtables-unexport-init_extensions-declarations.patch
new file mode 100644
index 0000000000..559b93eea4
--- /dev/null
+++ b/package/network/utils/iptables/patches/060-libxtables-unexport-init_extensions-declarations.patch
@@ -0,0 +1,82 @@
+From ef108943f69a6e20533d58823740d3f0534ea8ec Mon Sep 17 00:00:00 2001
+From: Phil Sutter <phil@nwl.cc>
+Date: Wed, 1 Jun 2022 19:15:06 +0200
+Subject: libxtables: Unexport init_extensions*() declarations
+
+The functions are used for static builds to initialize extensions after
+libxtables init. Regular library users should not need them, but the
+empty declarations introduced in #else case (and therefore present in
+user's env) may clash with existing symbol names.
+
+Avoid problems and guard the whole block declaring the function
+prototypes and mangling extensions' _init functions by XTABLES_INTERNAL.
+
+Reported-by: Nick Hainke <vincent@systemli.org>
+Fixes: 6c689b639cf8e ("Simplify static build extension loading")
+Signed-off-by: Phil Sutter <phil@nwl.cc>
+---
+ include/xtables.h | 44 ++++++++++++++++++++++----------------------
+ 1 file changed, 22 insertions(+), 22 deletions(-)
+
+--- a/include/xtables.h
++++ b/include/xtables.h
+@@ -585,27 +585,6 @@ static inline void xtables_print_mark_ma
+ xtables_print_val_mask(mark, mask, NULL);
+ }
+
+-#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
+-# ifdef _INIT
+-# undef _init
+-# define _init _INIT
+-# endif
+- extern void init_extensions(void);
+- extern void init_extensions4(void);
+- extern void init_extensions6(void);
+- extern void init_extensionsa(void);
+- extern void init_extensionsb(void);
+-#else
+-# define _init __attribute__((constructor)) _INIT
+-# define EMPTY_FUNC_DEF(x) static inline void x(void) {}
+- EMPTY_FUNC_DEF(init_extensions)
+- EMPTY_FUNC_DEF(init_extensions4)
+- EMPTY_FUNC_DEF(init_extensions6)
+- EMPTY_FUNC_DEF(init_extensionsa)
+- EMPTY_FUNC_DEF(init_extensionsb)
+-# undef EMPTY_FUNC_DEF
+-#endif
+-
+ extern const struct xtables_pprot xtables_chain_protos[];
+ extern uint16_t xtables_parse_protocol(const char *s);
+
+@@ -663,9 +642,30 @@ void xtables_announce_chain(const char *
+ # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
+ # endif
+
++#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
++# ifdef _INIT
++# undef _init
++# define _init _INIT
++# endif
++ extern void init_extensions(void);
++ extern void init_extensions4(void);
++ extern void init_extensions6(void);
++ extern void init_extensionsa(void);
++ extern void init_extensionsb(void);
++#else
++# define _init __attribute__((constructor)) _INIT
++# define EMPTY_FUNC_DEF(x) static inline void x(void) {}
++ EMPTY_FUNC_DEF(init_extensions)
++ EMPTY_FUNC_DEF(init_extensions4)
++ EMPTY_FUNC_DEF(init_extensions6)
++ EMPTY_FUNC_DEF(init_extensionsa)
++ EMPTY_FUNC_DEF(init_extensionsb)
++# undef EMPTY_FUNC_DEF
++#endif
++
+ extern void _init(void);
+
+-#endif
++#endif /* XTABLES_INTERNAL */
+
+ #ifdef __cplusplus
+ } /* extern "C" */
diff --git a/package/network/utils/iptables/patches/101-remove-check-already.patch b/package/network/utils/iptables/patches/101-remove-check-already.patch
index 16afafec2d..bd49224c70 100644
--- a/package/network/utils/iptables/patches/101-remove-check-already.patch
+++ b/package/network/utils/iptables/patches/101-remove-check-already.patch
@@ -1,6 +1,6 @@
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
-@@ -968,12 +968,6 @@ void xtables_register_match(struct xtabl
+@@ -1093,12 +1093,6 @@ void xtables_register_match(struct xtabl
struct xtables_match **pos;
bool seen_myself = false;
@@ -13,7 +13,7 @@
if (me->version == NULL) {
fprintf(stderr, "%s: match %s<%u> is missing a version\n",
xt_params->program_name, me->name, me->revision);
-@@ -1152,12 +1146,6 @@ void xtables_register_target(struct xtab
+@@ -1277,12 +1271,6 @@ void xtables_register_target(struct xtab
struct xtables_target **pos;
bool seen_myself = false;
diff --git a/package/network/utils/iptables/patches/102-iptables-disable-modprobe.patch b/package/network/utils/iptables/patches/102-iptables-disable-modprobe.patch
index b8e19c781a..710f481cac 100644
--- a/package/network/utils/iptables/patches/102-iptables-disable-modprobe.patch
+++ b/package/network/utils/iptables/patches/102-iptables-disable-modprobe.patch
@@ -1,6 +1,15 @@
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
-@@ -403,6 +403,7 @@ static char *get_modprobe(void)
+@@ -476,7 +476,7 @@ char *xtables_strdup(const char *s)
+ return dup;
+ }
+
+-static char *get_modprobe(void)
++__attribute__((unused)) static char *get_modprobe(void)
+ {
+ int procfile;
+ char *ret;
+@@ -511,6 +511,7 @@ static char *get_modprobe(void)
int xtables_insmod(const char *modname, const char *modprobe, bool quiet)
{
@@ -8,7 +17,7 @@
char *buf = NULL;
char *argv[4];
int status;
-@@ -437,6 +438,7 @@ int xtables_insmod(const char *modname,
+@@ -545,6 +546,7 @@ int xtables_insmod(const char *modname,
free(buf);
if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
return 0;
diff --git a/package/network/utils/iptables/patches/200-configurable_builtin.patch b/package/network/utils/iptables/patches/200-configurable_builtin.patch
index 6d7b5b5822..75c29e1e9c 100644
--- a/package/network/utils/iptables/patches/200-configurable_builtin.patch
+++ b/package/network/utils/iptables/patches/200-configurable_builtin.patch
@@ -60,7 +60,7 @@
.SECONDARY:
-@@ -161,11 +181,11 @@ libext4.a: initext4.o ${libext4_objs}
+@@ -163,11 +183,11 @@ libext4.a: initext4.o ${libext4_objs}
libext6.a: initext6.o ${libext6_objs}
${AM_VERBOSE_AR} ${AR} crs $@ $^;
diff --git a/package/network/utils/iptables/patches/600-shared-libext.patch b/package/network/utils/iptables/patches/600-shared-libext.patch
index 819f628f9e..838b1ffa66 100644
--- a/package/network/utils/iptables/patches/600-shared-libext.patch
+++ b/package/network/utils/iptables/patches/600-shared-libext.patch
@@ -18,7 +18,7 @@
-include .*.d
-@@ -164,22 +164,22 @@ xt_connlabel_LIBADD = @libnetfilter_conn
+@@ -166,22 +166,22 @@ xt_connlabel_LIBADD = @libnetfilter_conn
# handling code in the Makefiles.
#
lib%.o: ${srcdir}/lib%.c
diff --git a/package/network/utils/iptables/patches/700-disable-legacy-revisions.patch b/package/network/utils/iptables/patches/700-disable-legacy-revisions.patch
index cc451ef959..09db390006 100644
--- a/package/network/utils/iptables/patches/700-disable-legacy-revisions.patch
+++ b/package/network/utils/iptables/patches/700-disable-legacy-revisions.patch
@@ -1,6 +1,6 @@
--- a/extensions/libxt_conntrack.c
+++ b/extensions/libxt_conntrack.c
-@@ -1395,6 +1395,7 @@ static int conntrack3_mt6_xlate(struct x
+@@ -1399,6 +1399,7 @@ static int conntrack3_mt6_xlate(struct x
}
static struct xtables_match conntrack_mt_reg[] = {
@@ -8,7 +8,7 @@
{
.version = XTABLES_VERSION,
.name = "conntrack",
-@@ -1470,6 +1471,7 @@ static struct xtables_match conntrack_mt
+@@ -1474,6 +1475,7 @@ static struct xtables_match conntrack_mt
.alias = conntrack_print_name_alias,
.x6_options = conntrack2_mt_opts,
},
@@ -16,7 +16,7 @@
{
.version = XTABLES_VERSION,
.name = "conntrack",
-@@ -1502,6 +1504,7 @@ static struct xtables_match conntrack_mt
+@@ -1506,6 +1508,7 @@ static struct xtables_match conntrack_mt
.x6_options = conntrack3_mt_opts,
.xlate = conntrack3_mt6_xlate,
},
@@ -24,7 +24,7 @@
{
.family = NFPROTO_UNSPEC,
.name = "state",
-@@ -1532,6 +1535,8 @@ static struct xtables_match conntrack_mt
+@@ -1536,6 +1539,8 @@ static struct xtables_match conntrack_mt
.x6_parse = state_ct23_parse,
.x6_options = state_opts,
},
@@ -33,7 +33,7 @@
{
.family = NFPROTO_UNSPEC,
.name = "state",
-@@ -1561,6 +1566,7 @@ static struct xtables_match conntrack_mt
+@@ -1565,6 +1570,7 @@ static struct xtables_match conntrack_mt
.x6_parse = state_parse,
.x6_options = state_opts,
},
@@ -77,7 +77,7 @@
void _init(void)
--- a/extensions/libxt_multiport.c
+++ b/extensions/libxt_multiport.c
-@@ -571,6 +571,7 @@ static int multiport_xlate6_v1(struct xt
+@@ -591,6 +591,7 @@ static int multiport_xlate6_v1(struct xt
}
static struct xtables_match multiport_mt_reg[] = {
@@ -85,7 +85,7 @@
{
.family = NFPROTO_IPV4,
.name = "multiport",
-@@ -601,6 +602,7 @@ static struct xtables_match multiport_mt
+@@ -621,6 +622,7 @@ static struct xtables_match multiport_mt
.x6_options = multiport_opts,
.xlate = multiport_xlate6,
},