]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: unbreak deletion by table handle
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 29 Apr 2021 22:30:05 +0000 (00:30 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 2 May 2021 21:30:35 +0000 (23:30 +0200)
Use NFTA_TABLE_HANDLE instead of NFTA_TABLE_NAME to refer to the
table 64-bit unique handle.

Fixes: 7840b9224d5b ("evaluate: remove table from cache on delete table")
Fixes: f8aec603aa7e ("src: initial extended netlink error reporting")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c
src/mnl.c
tests/shell/testcases/cache/0008_delete_by_handle_0 [new file with mode: 0755]

index a6bb1792c58a10d69513fed923a81973ad8d885b..c52309f46f59ea7ba9c0689331684ce2e045ff34 100644 (file)
@@ -4335,6 +4335,9 @@ static void table_del_cache(struct eval_ctx *ctx, struct cmd *cmd)
 {
        struct table *table;
 
+       if (!cmd->handle.table.name)
+               return;
+
        table = table_lookup(&cmd->handle, &ctx->nft->cache);
        if (!table)
                return;
index d5ea87d8d6092e21273f54fc78a171e0dbccde6d..1a8e8105707bdc8aff090eac74bd46fba7a3da84 100644 (file)
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -960,7 +960,7 @@ int mnl_nft_table_del(struct netlink_ctx *ctx, struct cmd *cmd)
                mnl_attr_put_strz(nlh, NFTA_TABLE_NAME, cmd->handle.table.name);
        } else if (cmd->handle.handle.id) {
                cmd_add_loc(cmd, nlh->nlmsg_len, &cmd->handle.handle.location);
-               mnl_attr_put_u64(nlh, NFTA_TABLE_NAME,
+               mnl_attr_put_u64(nlh, NFTA_TABLE_HANDLE,
                                 htobe64(cmd->handle.handle.id));
        }
        nftnl_table_nlmsg_build_payload(nlh, nlt);
diff --git a/tests/shell/testcases/cache/0008_delete_by_handle_0 b/tests/shell/testcases/cache/0008_delete_by_handle_0
new file mode 100755 (executable)
index 0000000..24b2607
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+set -e
+
+$NFT add table t
+$NFT delete table handle 1
+
+$NFT add table t
+
+$NFT add chain t c
+$NFT delete chain t handle 1
+
+$NFT add set t s { type ipv4_addr\; }
+$NFT delete set t handle 2
+
+$NFT add flowtable t f { hook ingress priority 0\; }
+$NFT delete flowtable t handle 4
+
+$NFT add counter t x
+$NFT delete counter t handle 5