[PATCH nft 02/18] src: unbreak deletion by table handle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
 src/evaluate.c                                |  3 +++
 src/mnl.c                                     |  2 +-
 .../testcases/cache/0008_delete_by_handle_0   | 20 +++++++++++++++++++
 3 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100755 tests/shell/testcases/cache/0008_delete_by_handle_0

diff --git a/src/evaluate.c b/src/evaluate.c
index a6bb1792c58a..c52309f46f59 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -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;
diff --git a/src/mnl.c b/src/mnl.c
index d5ea87d8d609..1a8e8105707b 100644
--- 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
index 000000000000..24b2607b236f
--- /dev/null
+++ b/tests/shell/testcases/cache/0008_delete_by_handle_0
@@ -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
-- 
2.20.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux