[PATCH nft 3/3] mnl: use either name or handle to refer to objects

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

 



We can only specify either name or handle to refer to objects.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 src/mnl.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/mnl.c b/src/mnl.c
index d3129fda2b89..2be8ca14e50d 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -660,7 +660,7 @@ int mnl_nft_table_del(struct netlink_ctx *ctx, const struct cmd *cmd)
 	nftnl_table_set_u32(nlt, NFTNL_TABLE_FAMILY, cmd->handle.family);
 	if (cmd->handle.table.name)
 		nftnl_table_set(nlt, NFTNL_TABLE_NAME, cmd->handle.table.name);
-	if (cmd->handle.handle.id)
+	else if (cmd->handle.handle.id)
 		nftnl_table_set_u64(nlt, NFTNL_TABLE_HANDLE,
 				    cmd->handle.handle.id);
 
@@ -830,7 +830,7 @@ int mnl_nft_set_del(struct netlink_ctx *ctx, const struct cmd *cmd)
 	nftnl_set_set_str(nls, NFTNL_SET_TABLE, h->table.name);
 	if (h->set.name)
 		nftnl_set_set_str(nls, NFTNL_SET_NAME, h->set.name);
-	if (h->handle.id)
+	else if (h->handle.id)
 		nftnl_set_set_u64(nls, NFTNL_SET_HANDLE, h->handle.id);
 
 	nlh = nftnl_nlmsg_build_hdr(nftnl_batch_buffer(ctx->batch),
@@ -1189,8 +1189,9 @@ int mnl_nft_setelem_del(struct netlink_ctx *ctx, const struct cmd *cmd)
 
 	nftnl_set_set_u32(nls, NFTNL_SET_FAMILY, h->family);
 	nftnl_set_set_str(nls, NFTNL_SET_TABLE, h->table.name);
-	nftnl_set_set_str(nls, NFTNL_SET_NAME, h->set.name);
-	if (h->handle.id)
+	if (h->set.name)
+		nftnl_set_set_str(nls, NFTNL_SET_NAME, h->set.name);
+	else if (h->handle.id)
 		nftnl_set_set_u64(nls, NFTNL_SET_HANDLE, h->handle.id);
 
 	if (cmd->expr)
-- 
2.11.0




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux