Skip to contentSkip to conversation

tests: shell: Test delinearization of native nftables expressions

PATCH In review Phil Sutter 2 participants 2 messages Sep 22, 2022 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 tests: shell: Test delinearization of native nftables expressions

Even if iptables-nft doesn't generate them anymore, it should continue to correctly parse them. Make sure this is tested for.

---
 .../nft-only/0010-native-delinearize_0        | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100755 iptables/tests/shell/testcases/nft-only/0010-native-delinearize_0
iptables/tests/shell/testcases/nft-only/0010-native-delinearize_0 new file +26 -0
new file mode 100755
index 0000000000000..cca36fd88d6c7
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+[[ $XT_MULTI == *xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
+nft -v >/dev/null || exit 0
+
+set -e
+
+nft -f - <<EOF
+table ip filter {
+	chain FORWARD {
+		type filter hook forward priority filter;
+		limit rate 10/day counter
+		udp dport 42 counter
+	}
+}
+EOF
+
+EXPECT="*filter
+:INPUT ACCEPT [0:0]
+:FORWARD ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+-A FORWARD -m limit --limit 10/day
+-A FORWARD -p udp -m udp --dport 42
+COMMIT"
+
+diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI iptables-save | grep -v '^#')
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 2 lines · Phil Sutter

Even if iptables-nft doesn't generate them anymore, it should continue to correctly parse them. Make sure this is tested for.

I've added this and will merge what I have with this script.