diff options
author | Phil Sutter <phil@nwl.cc> | 2019-09-03 18:10:55 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2019-09-30 08:11:45 +0200 |
commit | 760b35b46e4cc3aabe9214027959266df23a0122 (patch) | |
tree | 9d3501f3c76aced056493a2373c397b9e43fa9cf /iptables/tests/shell/testcases | |
parent | f51cae64e9064ae503586ab5a4572ee3bea97de2 (diff) |
nft: Fix for add and delete of same rule in single batch
Another corner-case found when extending restore ordering test: If a
delete command in a dump referenced a rule added earlier within the same
dump, kernel would reject the resulting NFT_MSG_DELRULE command.
Catch this by assigning the rule to delete a RULE_ID value if it doesn't
have a handle yet. Since __nft_rule_del() does not duplicate the
nftnl_rule object when creating the NFT_COMPAT_RULE_DELETE command, this
RULE_ID value is added to both NEWRULE and DELRULE commands - exactly
what is needed to establish the reference.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/tests/shell/testcases')
-rwxr-xr-x | iptables/tests/shell/testcases/ipt-restore/0003-restore-ordering_0 | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/iptables/tests/shell/testcases/ipt-restore/0003-restore-ordering_0 b/iptables/tests/shell/testcases/ipt-restore/0003-restore-ordering_0 index 51f2422e..3f1d229e 100755 --- a/iptables/tests/shell/testcases/ipt-restore/0003-restore-ordering_0 +++ b/iptables/tests/shell/testcases/ipt-restore/0003-restore-ordering_0 @@ -14,7 +14,7 @@ ipt_show() { $XT_MULTI iptables-restore <<EOF *filter --A FORWARD -m comment --comment "appended rule" -j ACCEPT +-A FORWARD -m comment --comment "rule 4" -j ACCEPT -I FORWARD 1 -m comment --comment "rule 1" -j ACCEPT -I FORWARD 2 -m comment --comment "rule 2" -j ACCEPT -I FORWARD 3 -m comment --comment "rule 3" -j ACCEPT @@ -24,7 +24,7 @@ EOF EXPECT='-A FORWARD -m comment --comment "rule 1" -j ACCEPT -A FORWARD -m comment --comment "rule 2" -j ACCEPT -A FORWARD -m comment --comment "rule 3" -j ACCEPT --A FORWARD -m comment --comment "appended rule" -j ACCEPT' +-A FORWARD -m comment --comment "rule 4" -j ACCEPT' diff -u -Z <(echo -e "$EXPECT") <(ipt_show) @@ -32,11 +32,14 @@ diff -u -Z <(echo -e "$EXPECT") <(ipt_show) $XT_MULTI iptables-restore --noflush <<EOF *filter +-A FORWARD -m comment --comment "rule 5" -j ACCEPT -I FORWARD 1 -m comment --comment "rule 0.5" -j ACCEPT -I FORWARD 3 -m comment --comment "rule 1.5" -j ACCEPT -I FORWARD 5 -m comment --comment "rule 2.5" -j ACCEPT -I FORWARD 7 -m comment --comment "rule 3.5" -j ACCEPT --I FORWARD 9 -m comment --comment "appended rule 2" -j ACCEPT +-I FORWARD 9 -m comment --comment "rule 4.5" -j ACCEPT +-I FORWARD 11 -m comment --comment "rule 5.5" -j ACCEPT +-A FORWARD -m comment --comment "rule 6" -j ACCEPT COMMIT EOF @@ -47,8 +50,11 @@ EXPECT='-A FORWARD -m comment --comment "rule 0.5" -j ACCEPT -A FORWARD -m comment --comment "rule 2.5" -j ACCEPT -A FORWARD -m comment --comment "rule 3" -j ACCEPT -A FORWARD -m comment --comment "rule 3.5" -j ACCEPT --A FORWARD -m comment --comment "appended rule" -j ACCEPT --A FORWARD -m comment --comment "appended rule 2" -j ACCEPT' +-A FORWARD -m comment --comment "rule 4" -j ACCEPT +-A FORWARD -m comment --comment "rule 4.5" -j ACCEPT +-A FORWARD -m comment --comment "rule 5" -j ACCEPT +-A FORWARD -m comment --comment "rule 5.5" -j ACCEPT +-A FORWARD -m comment --comment "rule 6" -j ACCEPT' diff -u -Z <(echo -e "$EXPECT") <(ipt_show) @@ -78,6 +84,8 @@ diff -u -Z <(echo -e "$EXPECT") <(ipt_show) $XT_MULTI iptables-restore --noflush <<EOF *filter +-A FORWARD -m comment --comment "appended rule 4" -j ACCEPT +-D FORWARD 7 -D FORWARD -m comment --comment "appended rule 1" -j ACCEPT -D FORWARD 3 -I FORWARD 3 -m comment --comment "manually replaced rule 2" -j ACCEPT |