diff --git a/package/iptables/iptables.mk b/package/iptables/iptables.mk index a9d912f6cc9..bb01c07a432 100644 --- a/package/iptables/iptables.mk +++ b/package/iptables/iptables.mk @@ -49,11 +49,33 @@ else IPTABLES_CONF_OPTS += --disable-bpf-compiler --disable-nfsynproxy endif +# Enable kernel support for iptables-nft even if nftables compat is not +# enabled by default. +ifeq ($(BR2_PACKAGE_IPTABLES_NFTABLES),y) +define IPTABLES_LINUX_CONFIG_FIXUPS_IPTABLES_NFT + $(call KCONFIG_ENABLE_OPT,CONFIG_NF_TABLES) + $(call KCONFIG_ENABLE_OPT,CONFIG_NF_TABLES_INET) + $(call KCONFIG_ENABLE_OPT,CONFIG_NFT_SOCKET) +endef +endif + +# Enable kernel support for iptables-legacy only if nftables compat is not +# enabled by default. +ifeq ($(BR2_PACKAGE_IPTABLES_NFTABLES_DEFAULT),) +define IPTABLES_LINUX_CONFIG_FIXUPS_IPTABLES_LEGACY + # [for Linux kernel versions 6.17 and later] + $(call KCONFIG_ENABLE_OPT,CONFIG_IP_NF_IPTABLES_LEGACY) + $(call KCONFIG_ENABLE_OPT,CONFIG_NETFILTER_XTABLES_LEGACY) +endef +endif + define IPTABLES_LINUX_CONFIG_FIXUPS $(call KCONFIG_ENABLE_OPT,CONFIG_IP_NF_IPTABLES) $(call KCONFIG_ENABLE_OPT,CONFIG_IP_NF_FILTER) $(call KCONFIG_ENABLE_OPT,CONFIG_NETFILTER) $(call KCONFIG_ENABLE_OPT,CONFIG_NETFILTER_XTABLES) + $(IPTABLES_LINUX_CONFIG_FIXUPS_IPTABLES_LEGACY) + $(IPTABLES_LINUX_CONFIG_FIXUPS_IPTABLES_NFT) endef define IPTABLES_INSTALL_INIT_SYSV diff --git a/support/testing/tests/package/test_iptables.py b/support/testing/tests/package/test_iptables.py index 72f2dd71a4f..918fa4fb297 100644 --- a/support/testing/tests/package/test_iptables.py +++ b/support/testing/tests/package/test_iptables.py @@ -15,7 +15,7 @@ class TestIptables(infra.basetest.BRTest): BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y - BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.82" + BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.18.36" BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config" BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y @@ -38,7 +38,10 @@ def test_run(self): self.emulator.login() # We check the program can execute. - self.assertRunOk("iptables --version") + cmd = "iptables --version" + output, exit_code = self.emulator.run(cmd) + self.assertEqual(exit_code, 0) + self.assertTrue(output[0].endswith("(legacy)")) # We delete all rules in all chains. We also set default # policies to ACCEPT for INPUT and OUTPUT chains. This should