Skip to contentSkip to conversation

tests: shell: Test for false-positive rule check

PATCH In review Phil Sutter 1 participant 2 messages Apr 5, 2023 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 tests: shell: Test for false-positive rule check

Rule comparison in legacy ip6tables was broken by commit eb2546a846776 ("xshared: Share make_delete_mask() between ip{,6}tables"): A part of the rules' data was masked out for comparison by accident.

---
 .../shell/testcases/ip6tables/0005-rule-check_0 | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100755 iptables/tests/shell/testcases/ip6tables/0005-rule-check_0
iptables/tests/shell/testcases/ip6tables/0005-rule-check_0 new file +17 -0
new file mode 100755
index 0000000000000..cc8215bf43495
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# Test the fix in commit 78850e7dba64a ("ip6tables: Fix checking existence of
+# rule"). Happens with legacy ip6tables only, but testing ip6tables-nft doesn't
+# hurt.
+#
+# Code taken from https://bugzilla.netfilter.org/show_bug.cgi?id=1667
+# Thanks to Jonathan Caicedo <[email protected]> for providing it.
+
+RULE='-p tcp --dport 81 -j DNAT --to-destination [::1]:81'
+
+$XT_MULTI ip6tables -t nat -N testchain || exit 1
+$XT_MULTI ip6tables -t nat -A testchain $RULE || exit 1
+$XT_MULTI ip6tables -t nat -C testchain $RULE || exit 1
+
+$XT_MULTI ip6tables -t nat -C testchain ${RULE//81/82} 2>/dev/null && exit 1
+exit 0
Signature · 1 line
2.38.0
author reviewer
#1 lore raw
Quoted 5 lines · Phil Sutter

Rule comparison in legacy ip6tables was broken by commit eb2546a846776 ("xshared: Share make_delete_mask() between ip{,6}tables"): A part of the rules' data was masked out for comparison by accident.

Patch applied.