Re: [PATCH nft v4] src: add support to command "destroy"

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

 



Hi,

On 28/10/2022 20:26, Phil Sutter wrote:
Hi Fernando,

On Fri, Oct 28, 2022 at 12:06:48PM +0200, Fernando Fernandez Mancera wrote:
[...]
diff --git a/src/mnl.c b/src/mnl.c
index e87b0338..ab0e06c9 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -602,10 +602,16 @@ int mnl_nft_rule_del(struct netlink_ctx *ctx, struct cmd *cmd)
nftnl_rule_set_u32(nlr, NFTNL_RULE_FAMILY, h->family); - nlh = nftnl_nlmsg_build_hdr(nftnl_batch_buffer(ctx->batch),
-				    NFT_MSG_DELRULE,
-				    nftnl_rule_get_u32(nlr, NFTNL_RULE_FAMILY),
-				    0, ctx->seqnum);
+	if (cmd->op == CMD_DESTROY)
+		nlh = nftnl_nlmsg_build_hdr(nftnl_batch_buffer(ctx->batch),
+					    NFT_MSG_DESTROYRULE,
+					    nftnl_rule_get_u32(nlr, NFTNL_RULE_FAMILY),
+					    0, ctx->seqnum);
+	else
+		nlh = nftnl_nlmsg_build_hdr(nftnl_batch_buffer(ctx->batch),
+					    NFT_MSG_DELRULE,
+					    nftnl_rule_get_u32(nlr, NFTNL_RULE_FAMILY),
+					    0, ctx->seqnum);
cmd_add_loc(cmd, nlh->nlmsg_len, &h->table.location);
  	mnl_attr_put_strz(nlh, NFTA_RULE_TABLE, h->table.name);

These chunks become much simpler if you introduce a local variable
holding NFT_MSG_DELRULE by default and set it to NFT_MSG_DESTROYRULE if
cmd->op == CMD_DESTROY.


Makes sense, thanks!

Thanks,
Fernando.

Cheers, Phil




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

  Powered by Linux