Initial commit

This commit is contained in:
Your Name
2026-04-23 17:07:55 +08:00
commit b7e39e063b
16725 changed files with 1625565 additions and 0 deletions
@@ -0,0 +1,47 @@
From 698ed332e2c592235d2b737c545ac25ad0970e15 Mon Sep 17 00:00:00 2001
From: "Maxin B. John" <maxin.john@intel.com>
Date: Tue, 21 Feb 2017 11:16:31 +0200
Subject: [PATCH 1/4] configure: Add option to enable/disable libnfnetlink
This changes the configure behaviour from autodetecting
for libnfnetlink to having an option to disable it explicitly
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Maxin B. John <maxin.john@intel.com>
---
configure.ac | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index bc2ed47b..e27745e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,6 +63,9 @@ AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH],
AC_ARG_ENABLE([nftables],
AS_HELP_STRING([--disable-nftables], [Do not build nftables compat]),
[enable_nftables="$enableval"], [enable_nftables="yes"])
+AC_ARG_ENABLE([libnfnetlink],
+ AS_HELP_STRING([--disable-libnfnetlink], [Do not use netfilter netlink library]),
+ [enable_libnfnetlink="$enableval"], [enable_libnfnetlink="yes"])
AC_ARG_ENABLE([connlabel],
AS_HELP_STRING([--disable-connlabel],
[Do not build libnetfilter_conntrack]),
@@ -117,9 +120,10 @@ if test "x$enable_bpfc" = "xyes" || test "x$enable_nfsynproxy" = "xyes"; then
AC_CHECK_LIB(pcap, pcap_compile,, AC_MSG_ERROR(missing libpcap library required by bpf compiler or nfsynproxy tool))
fi
-PKG_CHECK_MODULES([libnfnetlink], [libnfnetlink >= 1.0],
- [nfnetlink=1], [nfnetlink=0])
-AM_CONDITIONAL([HAVE_LIBNFNETLINK], [test "$nfnetlink" = 1])
+AS_IF([test "x$enable_libnfnetlink" = "xyes"], [
+ PKG_CHECK_MODULES([libnfnetlink], [libnfnetlink >= 1.0])
+ ])
+AM_CONDITIONAL([HAVE_LIBNFNETLINK], [test "x$enable_libnfnetlink" = "xyes"])
if test "x$enable_nftables" = "xyes"; then
PKG_CHECK_MODULES([libmnl], [libmnl >= 1.0], [mnl=1], [mnl=0])
--
2.30.2
@@ -0,0 +1,33 @@
From d4699d2169fe2d91d0f1f4369d40d2e5f42b8877 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex@linutronix.de>
Date: Tue, 17 May 2022 10:56:59 +0200
Subject: [PATCH 2/4] iptables/xshared.h: add missing sys.types.h include
This resolves the build error under musl:
| ../../../../../../../workspace/sources/iptables/iptables/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
Upstream-Status: Submitted [via email to phil@nwl.cc]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
iptables/xshared.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/iptables/xshared.h b/iptables/xshared.h
index 0ed9f3c2..b1413834 100644
--- a/iptables/xshared.h
+++ b/iptables/xshared.h
@@ -6,6 +6,7 @@
#include <stdint.h>
#include <netinet/in.h>
#include <net/if.h>
+#include <sys/types.h>
#include <linux/netfilter_arp/arp_tables.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv6/ip6_tables.h>
--
2.30.2
@@ -0,0 +1,41 @@
From 28291b41bc3717f51e8d9d465f0100f1ca99dc26 Mon Sep 17 00:00:00 2001
From: Trevor Gamblin <trevor.gamblin@windriver.com>
Date: Wed, 9 Mar 2022 12:50:39 -0500
Subject: [PATCH 3/4] Makefile.am: do not install /etc/ethertypes
The /etc/ethertypes is provided by netbase since 6.0[1].
Do not instal the file in ebtables, otherwise there would be a conflict:
Error: Transaction test error:
file /etc/ethertypes conflicts between attempted installs of
netbase-1:6.2-r0.corei7_64 and iptables-1.8.7-r0.corei7_64
[1]
https://salsa.debian.org/md/netbase/-/commit/316680c6a2c3641b6abc76b3eebf88781f609d35)
This patch is based off of the same change made for the ebtables recipe:
http://cgit.openembedded.org/meta-openembedded/tree/meta-networking/recipes-filter/ebtables/ebtables-2.0.11/0001-Makefile.am-do-not-install-etc-ethertypes.patch?h=master
Upstream-Status: Inappropriate [embedded specific]
Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com>
---
Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 451c3cb2..5125238c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,7 +20,7 @@ EXTRA_DIST = autogen.sh iptables-test.py xlate-test.py
if ENABLE_NFTABLES
confdir = $(sysconfdir)
-dist_conf_DATA = etc/ethertypes etc/xtables.conf
+dist_conf_DATA = etc/xtables.conf
endif
.PHONY: tarball
--
2.30.2
@@ -0,0 +1,51 @@
From e7aa1dd2831f9bb5d0603c5e5027387ad7721b00 Mon Sep 17 00:00:00 2001
From: "Maxin B. John" <maxin.john@intel.com>
Date: Tue, 21 Feb 2017 11:49:07 +0200
Subject: [PATCH 4/4] configure.ac:
only-check-conntrack-when-libnfnetlink-enabled.patch
Package libnetfilter-conntrack depends on package libnfnetlink. iptables
checks package libnetfilter-conntrack whatever its package config
libnfnetlink is enabled or not. When libnfnetlink is disabled but
package libnetfilter-conntrack exists, it fails randomly with:
In file included from
.../iptables/1.4.21-r0/iptables-1.4.21/extensions/libxt_connlabel.c:8:0:
.../tmp/sysroots/qemumips/usr/include/libnetfilter_conntrack/libnetfilter_conntrack.h:14:42:
fatal error: libnfnetlink/linux_nfnetlink.h: No such file or directory
compilation terminated.
GNUmakefile:96: recipe for target 'libxt_connlabel.oo' failed
Only check libnetfilter-conntrack when libnfnetlink is enabled to fix it.
Upstream-Status: Pending
Signed-off-by: Kai Kang <kai.kang@windriver.com>
Signed-off-by: Maxin B. John <maxin.john@intel.com>
---
configure.ac | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index e27745e5..528f1bb5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,10 +158,12 @@ if test "$nftables" != 1; then
fi
if test "x$enable_connlabel" = "xyes"; then
- PKG_CHECK_MODULES([libnetfilter_conntrack],
+ nfconntrack=0
+ AS_IF([test "x$enable_libnfnetlink" = "xyes"], [
+ PKG_CHECK_MODULES([libnetfilter_conntrack],
[libnetfilter_conntrack >= 1.0.6],
[nfconntrack=1], [nfconntrack=0])
-
+ ])
if test "$nfconntrack" -ne 1; then
blacklist_modules="$blacklist_modules connlabel";
echo "WARNING: libnetfilter_conntrack not found, connlabel match will not be built";
--
2.30.2
@@ -0,0 +1,31 @@
From ed4082a7405a5838c205a34c1559e289949200cc Mon Sep 17 00:00:00 2001
From: Phil Sutter <phil@nwl.cc>
Date: Thu, 12 Jan 2023 14:38:44 +0100
Subject: extensions: NAT: Fix for -Werror=format-security
Have to pass either a string literal or format string to xt_xlate_add().
Fixes: f30c5edce0413 ("extensions: Merge SNAT, DNAT, REDIRECT and MASQUERADE")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Upstream-Status: Backport [https://git.netfilter.org/iptables/commit/?id=ed4082a7405a5838c205a34c1559e289949200cc]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
extensions/libxt_NAT.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/extensions/libxt_NAT.c b/extensions/libxt_NAT.c
index da9f2201..2a634398 100644
--- a/extensions/libxt_NAT.c
+++ b/extensions/libxt_NAT.c
@@ -424,7 +424,7 @@ __NAT_xlate(struct xt_xlate *xl, const struct nf_nat_range2 *r,
if (r->flags & NF_NAT_RANGE_PROTO_OFFSET)
return 0;
- xt_xlate_add(xl, tgt);
+ xt_xlate_add(xl, "%s", tgt);
if (strlen(range_str))
xt_xlate_add(xl, " to %s", range_str);
if (r->flags & NF_NAT_RANGE_PROTO_RANDOM) {
--
cgit v1.2.3
@@ -0,0 +1,13 @@
[Unit]
Description=IPv6 Packet Filtering Framework
Before=network-pre.target
Wants=network-pre.target
[Service]
Type=oneshot
ExecStart=@SBINDIR@/ip6tables-restore -w -- @RULESDIR@/ip6tables.rules
ExecReload=@SBINDIR@/ip6tables-restore -w -- @RULESDIR@/ip6tables.rules
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,13 @@
[Unit]
Description=IPv4 Packet Filtering Framework
Before=network-pre.target
Wants=network-pre.target
[Service]
Type=oneshot
ExecStart=@SBINDIR@/iptables-restore -w -- @RULESDIR@/iptables.rules
ExecReload=@SBINDIR@/iptables-restore -w -- @RULESDIR@/iptables.rules
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,125 @@
SUMMARY = "Tools for managing kernel packet filtering capabilities"
DESCRIPTION = "iptables is the userspace command line program used to configure and control network packet \
filtering code in Linux."
HOMEPAGE = "http://www.netfilter.org/"
BUGTRACKER = "http://bugzilla.netfilter.org/"
LICENSE = "GPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
file://iptables/iptables.c;beginline=13;endline=25;md5=c5cffd09974558cf27d0f763df2a12dc \
"
SRC_URI = "http://netfilter.org/projects/iptables/files/iptables-${PV}.tar.xz \
file://iptables.service \
file://iptables.rules \
file://ip6tables.service \
file://ip6tables.rules \
file://0001-configure-Add-option-to-enable-disable-libnfnetlink.patch \
file://0002-iptables-xshared.h-add-missing-sys.types.h-include.patch \
file://0003-Makefile.am-do-not-install-etc-ethertypes.patch \
file://0004-configure.ac-only-check-conntrack-when-libnfnetlink-.patch \
file://format-security.patch \
"
SRC_URI[sha256sum] = "ef6639a43be8325a4f8ea68123ffac236cb696e8c78501b64e8106afb008c87f"
SYSTEMD_SERVICE:${PN} = "\
iptables.service \
${@bb.utils.contains('PACKAGECONFIG', 'ipv6', 'ip6tables.service', '', d)} \
"
inherit autotools pkgconfig systemd
EXTRA_OECONF = "--with-kernel=${STAGING_INCDIR}"
CFLAGS:append:libc-musl = " -D__UAPI_DEF_ETHHDR=0"
PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}"
PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
# libnfnetlink recipe is in meta-networking layer
PACKAGECONFIG[libnfnetlink] = "--enable-libnfnetlink,--disable-libnfnetlink,libnfnetlink libnetfilter-conntrack"
# libnftnl recipe is in meta-networking layer(previously known as libnftables)
PACKAGECONFIG[libnftnl] = "--enable-nftables,--disable-nftables,libnftnl"
do_configure:prepend() {
# Remove some libtool m4 files
# Keep ax_check_linker_flags.m4 which belongs to autoconf-archive.
rm -f libtool.m4 lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4
# Copy a header to fix out of tree builds
cp -f ${S}/libiptc/linux_list.h ${S}/include/libiptc/
}
IPTABLES_RULES_DIR ?= "${sysconfdir}/${BPN}"
do_install:append() {
install -d ${D}${IPTABLES_RULES_DIR}
install -m 0644 ${WORKDIR}/iptables.rules ${D}${IPTABLES_RULES_DIR}
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/iptables.service ${D}${systemd_system_unitdir}
sed -i \
-e 's,@SBINDIR@,${sbindir},g' \
-e 's,@RULESDIR@,${IPTABLES_RULES_DIR},g' \
${D}${systemd_system_unitdir}/iptables.service
if ${@bb.utils.contains('PACKAGECONFIG', 'ipv6', 'true', 'false', d)} ; then
install -m 0644 ${WORKDIR}/ip6tables.rules ${D}${IPTABLES_RULES_DIR}
install -m 0644 ${WORKDIR}/ip6tables.service ${D}${systemd_system_unitdir}
sed -i \
-e 's,@SBINDIR@,${sbindir},g' \
-e 's,@RULESDIR@,${IPTABLES_RULES_DIR},g' \
${D}${systemd_system_unitdir}/ip6tables.service
fi
# if libnftnl is included, make the iptables symlink point to the nft-based binary by default
if ${@bb.utils.contains('PACKAGECONFIG', 'libnftnl', 'true', 'false', d)} ; then
ln -sf ${sbindir}/xtables-nft-multi ${D}${sbindir}/iptables
fi
}
PACKAGES =+ "${PN}-modules ${PN}-apply"
PACKAGES_DYNAMIC += "^${PN}-module-.*"
python populate_packages:prepend() {
modules = do_split_packages(d, '${libdir}/xtables', r'lib(.*)\.so$', '${PN}-module-%s', '${PN} module %s', extra_depends='')
if modules:
metapkg = d.getVar('PN') + '-modules'
d.appendVar('RDEPENDS:' + metapkg, ' ' + ' '.join(modules))
}
RDEPENDS:${PN} = "${PN}-module-xt-standard"
RRECOMMENDS:${PN} = " \
${PN}-modules \
kernel-module-x-tables \
kernel-module-ip-tables \
kernel-module-iptable-filter \
kernel-module-iptable-nat \
kernel-module-nf-defrag-ipv4 \
kernel-module-nf-conntrack \
kernel-module-nf-conntrack-ipv4 \
kernel-module-nf-nat \
kernel-module-ipt-masquerade \
${@bb.utils.contains('PACKAGECONFIG', 'ipv6', '\
kernel-module-ip6table-filter \
kernel-module-ip6-tables \
', '', d)} \
"
FILES:${PN} += "${datadir}/xtables"
FILES:${PN}-apply = "${sbindir}/ip*-apply"
RDEPENDS:${PN}-apply = "${PN} bash"
# Include the symlinks as well in respective packages
FILES:${PN}-module-xt-conntrack += "${libdir}/xtables/libxt_state.so"
FILES:${PN}-module-xt-ct += "${libdir}/xtables/libxt_NOTRACK.so ${libdir}/xtables/libxt_REDIRECT.so"
FILES:${PN}-module-xt-nat += "${libdir}/xtables/libxt_SNAT.so ${libdir}/xtables/libxt_DNAT.so ${libdir}/xtables/libxt_MASQUERADE.so"
ALLOW_EMPTY:${PN}-modules = "1"
INSANE_SKIP:${PN}-module-xt-conntrack = "dev-so"
INSANE_SKIP:${PN}-module-xt-ct = "dev-so"
INSANE_SKIP:${PN}-module-xt-nat = "dev-so"