summaryrefslogtreecommitdiffstats
path: root/iptables/nft.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2023-02-28 18:09:25 +0100
committerPhil Sutter <phil@nwl.cc>2023-03-01 20:15:45 +0100
commit5fd85822bd12a02f1a921243f605fc6238d705b4 (patch)
tree1eae37af351b26ba4f2ea53113368be7a5f8808a /iptables/nft.c
parent8030e5444681e16ac2f481ddad73e33fab376147 (diff)
nft-restore: Fix for deletion of new, referenced rule
Combining multiple corner-cases here: * Insert a rule before another new one which is not the first. Triggers NFTNL_RULE_ID assignment of the latter. * Delete the referenced new rule in the same batch again. Causes overwriting of the previously assigned RULE_ID. Consequently, iptables-nft-restore fails during *insert*, because the reference is dangling. Reported-by: Eric Garver <eric@garver.life> Fixes: 760b35b46e4cc ("nft: Fix for add and delete of same rule in single batch") Signed-off-by: Phil Sutter <phil@nwl.cc> Tested-by: Eric Garver <eric@garver.life>
Diffstat (limited to 'iptables/nft.c')
-rw-r--r--iptables/nft.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/iptables/nft.c b/iptables/nft.c
index 63468cf3..5896fd41 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -2343,7 +2343,8 @@ static int __nft_rule_del(struct nft_handle *h, struct nftnl_rule *r)
nftnl_rule_list_del(r);
- if (!nftnl_rule_get_u64(r, NFTNL_RULE_HANDLE))
+ if (!nftnl_rule_get_u64(r, NFTNL_RULE_HANDLE) &&
+ !nftnl_rule_get_u32(r, NFTNL_RULE_ID))
nftnl_rule_set_u32(r, NFTNL_RULE_ID, ++h->rule_id);
obj = batch_rule_add(h, NFT_COMPAT_RULE_DELETE, r);