diff options
Diffstat (limited to 'meta/recipes-extended/iptables')
8 files changed, 176 insertions, 136 deletions
diff --git a/meta/recipes-extended/iptables/iptables/0001-configure-Add-option-to-enable-disable-libnfnetlink.patch b/meta/recipes-extended/iptables/iptables/0001-configure-Add-option-to-enable-disable-libnfnetlink.patch index 03c36ccbc2..0fe2261511 100644 --- a/meta/recipes-extended/iptables/iptables/0001-configure-Add-option-to-enable-disable-libnfnetlink.patch +++ b/meta/recipes-extended/iptables/iptables/0001-configure-Add-option-to-enable-disable-libnfnetlink.patch @@ -1,21 +1,24 @@ -From c46db7c2e1f63ec525835553587e70c635565310 Mon Sep 17 00:00:00 2001 +From 653db8b938166db7833135f615b90c38a3f27a30 Mon Sep 17 00:00:00 2001 From: "Maxin B. John" <maxin.john@intel.com> -Date: Tue, 21 Feb 2017 11:16:31 +0200 +Date: Thu, 25 Apr 2024 10:51:02 +0200 Subject: [PATCH] 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 +Default behavior (autodetecting) does not change, but specifying +either option would explicitly disable or enable libnfnetlink support, +and if the library is not found in the latter case, ./configure will error +out. +Upstream-Status: Backport [https://git.netfilter.org/iptables/commit/?id=653db8b938166db7833135f615b90c38a3f27a30] Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Maxin B. John <maxin.john@intel.com> +Signed-off-by: Alexander Kanavin <alex@linutronix.de> +Signed-off-by: Phil Sutter <phil@nwl.cc> --- - configure.ac | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) + configure.ac | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac -index eda7871..03ddc50 100644 +index d99fa3b9..2293702b 100644 --- a/configure.ac +++ b/configure.ac @@ -63,6 +63,9 @@ AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH], @@ -24,24 +27,27 @@ index eda7871..03ddc50 100644 [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"]) ++ [enable_libnfnetlink="$enableval"], [enable_libnfnetlink="auto"]) AC_ARG_ENABLE([connlabel], AS_HELP_STRING([--disable-connlabel], [Do not build libnetfilter_conntrack]), -@@ -115,9 +118,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 +@@ -113,8 +116,14 @@ AM_CONDITIONAL([ENABLE_SYNCONF], [test "$enable_nfsynproxy" = "yes"]) + AM_CONDITIONAL([ENABLE_NFTABLES], [test "$enable_nftables" = "yes"]) + AM_CONDITIONAL([ENABLE_CONNLABEL], [test "$enable_connlabel" = "yes"]) -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 specified explicitly on the command line, error out when library was not found ++# Otherwise, disable and continue ++AS_IF([test "x$enable_libnfnetlink" = "xyes"], ++ [PKG_CHECK_MODULES([libnfnetlink], [libnfnetlink >= 1.0], ++ [nfnetlink=1])], ++ [test "x$enable_libnfnetlink" = "xauto"], ++ [PKG_CHECK_MODULES([libnfnetlink], [libnfnetlink >= 1.0], ++ [nfnetlink=1], [nfnetlink=0])]) + AM_CONDITIONAL([HAVE_LIBNFNETLINK], [test "$nfnetlink" = 1]) - if test "x$enable_nftables" = "xyes"; then - PKG_CHECK_MODULES([libmnl], [libmnl >= 1.0], [mnl=1], [mnl=0]) + if test "x$enable_bpfc" = "xyes" || test "x$enable_nfsynproxy" = "xyes"; then -- -2.4.0 +2.39.2 diff --git a/meta/recipes-extended/iptables/iptables/0002-configure.ac-only-check-conntrack-when-libnfnetlink-enabled.patch b/meta/recipes-extended/iptables/iptables/0002-configure.ac-only-check-conntrack-when-libnfnetlink-enabled.patch deleted file mode 100644 index 7842c6408a..0000000000 --- a/meta/recipes-extended/iptables/iptables/0002-configure.ac-only-check-conntrack-when-libnfnetlink-enabled.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 26090b3dbcdf6a11e60535da949b726a6e86426d 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] 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 03ddc50..523caea 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -172,10 +172,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.4.0 - diff --git a/meta/recipes-extended/iptables/iptables/ip6tables.rules b/meta/recipes-extended/iptables/iptables/ip6tables.rules new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/meta/recipes-extended/iptables/iptables/ip6tables.rules diff --git a/meta/recipes-extended/iptables/iptables/ip6tables.service b/meta/recipes-extended/iptables/iptables/ip6tables.service new file mode 100644 index 0000000000..6c059fca49 --- /dev/null +++ b/meta/recipes-extended/iptables/iptables/ip6tables.service @@ -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 diff --git a/meta/recipes-extended/iptables/iptables/iptables.rules b/meta/recipes-extended/iptables/iptables/iptables.rules new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/meta/recipes-extended/iptables/iptables/iptables.rules diff --git a/meta/recipes-extended/iptables/iptables/iptables.service b/meta/recipes-extended/iptables/iptables/iptables.service new file mode 100644 index 0000000000..0eb3c343de --- /dev/null +++ b/meta/recipes-extended/iptables/iptables/iptables.service @@ -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 diff --git a/meta/recipes-extended/iptables/iptables_1.6.2.bb b/meta/recipes-extended/iptables/iptables_1.6.2.bb deleted file mode 100644 index e00824f763..0000000000 --- a/meta/recipes-extended/iptables/iptables_1.6.2.bb +++ /dev/null @@ -1,64 +0,0 @@ -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 = "GPLv2+" -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.bz2 \ - file://0001-configure-Add-option-to-enable-disable-libnfnetlink.patch \ - file://0002-configure.ac-only-check-conntrack-when-libnfnetlink-enabled.patch \ -" - -SRC_URI[md5sum] = "7d2b7847e4aa8832a18437b8a4c1873d" -SRC_URI[sha256sum] = "55d02dfa46263343a401f297d44190f2a3e5113c8933946f094ed40237053733" - -inherit autotools pkgconfig - -EXTRA_OECONF = "--with-kernel=${STAGING_INCDIR}" - -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 -} - -PACKAGES += "${PN}-modules" -PACKAGES_DYNAMIC += "^${PN}-module-.*" - -python populate_packages_prepend() { - modules = do_split_packages(d, '${libdir}/xtables', 'lib(.*)\.so$', '${PN}-module-%s', '${PN} module %s', extra_depends='') - if modules: - metapkg = d.getVar('PN') + '-modules' - d.appendVar('RDEPENDS_' + metapkg, ' ' + ' '.join(modules)) -} - -FILES_${PN} += "${datadir}/xtables" - -ALLOW_EMPTY_${PN}-modules = "1" - -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 \ -" diff --git a/meta/recipes-extended/iptables/iptables_1.8.10.bb b/meta/recipes-extended/iptables/iptables_1.8.10.bb new file mode 100644 index 0000000000..86f1335ac8 --- /dev/null +++ b/meta/recipes-extended/iptables/iptables_1.8.10.bb @@ -0,0 +1,123 @@ +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 \ + " +SRC_URI[sha256sum] = "5cc255c189356e317d070755ce9371eb63a1b783c34498fb8c30264f3cc59c9c" + +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 --enable-connlabel,--disable-libnfnetlink --disable-connlabel,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 ${UNPACKDIR}/iptables.rules ${D}${IPTABLES_RULES_DIR} + + install -d ${D}${systemd_system_unitdir} + install -m 0644 ${UNPACKDIR}/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 ${UNPACKDIR}/ip6tables.rules ${D}${IPTABLES_RULES_DIR} + install -m 0644 ${UNPACKDIR}/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 + ln -sf ${sbindir}/xtables-nft-multi ${D}${sbindir}/iptables-save + ln -sf ${sbindir}/xtables-nft-multi ${D}${sbindir}/iptables-restore + 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" |