From: Phil Sutter <phil@nwl.cc>
To: Fernando Fernandez Mancera <ffmancera@riseup.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft v4] src: add support to command "destroy"
Date: Fri, 28 Oct 2022 20:26:05 +0200 [thread overview]
Message-ID: <Y1weve5JsmyNLb8t@orbyte.nwl.cc> (raw)
In-Reply-To: <20221028100648.58789-1-ffmancera@riseup.net>
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.
Cheers, Phil
next prev parent reply other threads:[~2022-10-28 18:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 10:06 [PATCH nft v4] src: add support to command "destroy" Fernando Fernandez Mancera
2022-10-28 18:26 ` Phil Sutter [this message]
2022-10-29 8:57 ` Fernando Fernandez Mancera
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1weve5JsmyNLb8t@orbyte.nwl.cc \
--to=phil@nwl.cc \
--cc=ffmancera@riseup.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.