From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>
Cc: Florian Westphal <fw@strlen.de>, netfilter-devel@vger.kernel.org
Subject: Re: [nf PATCH v2 7/8] netfilter: nf_tables: Pass reset bit in nft_set_dump_ctx
Date: Thu, 28 Sep 2023 20:53:11 +0200 [thread overview]
Message-ID: <ZRXLlwkeCBWgXqGZ@calendula> (raw)
In-Reply-To: <20230928165244.7168-8-phil@nwl.cc>
On Thu, Sep 28, 2023 at 06:52:43PM +0200, Phil Sutter wrote:
> Relieve the dump callback from having to check nlmsg_type upon each
> call. Prep work for set element reset locking.
Maybe add this as a preparation patch first place in this series,
rather making this cleanup at this late stage of the batch.
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> Changes since v1:
> - New patch
> ---
> net/netfilter/nf_tables_api.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index f154fcc341421..1491d4c65fed9 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -5731,6 +5731,7 @@ static void audit_log_nft_set_reset(const struct nft_table *table,
> struct nft_set_dump_ctx {
> const struct nft_set *set;
> struct nft_ctx ctx;
> + bool reset;
> };
>
> static int nft_set_catchall_dump(struct net *net, struct sk_buff *skb,
> @@ -5770,7 +5771,6 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)
> bool set_found = false;
> struct nlmsghdr *nlh;
> struct nlattr *nest;
> - bool reset = false;
> u32 portid, seq;
> int event;
>
> @@ -5818,12 +5818,9 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)
> if (nest == NULL)
> goto nla_put_failure;
>
> - if (NFNL_MSG_TYPE(cb->nlh->nlmsg_type) == NFT_MSG_GETSETELEM_RESET)
> - reset = true;
> -
> args.cb = cb;
> args.skb = skb;
> - args.reset = reset;
> + args.reset = dump_ctx->reset;
> args.iter.genmask = nft_genmask_cur(net);
> args.iter.skip = cb->args[0];
> args.iter.count = 0;
> @@ -5833,11 +5830,11 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)
>
> if (!args.iter.err && args.iter.count == cb->args[0])
> args.iter.err = nft_set_catchall_dump(net, skb, set,
> - reset, cb->seq);
> + dump_ctx->reset, cb->seq);
> nla_nest_end(skb, nest);
> nlmsg_end(skb, nlh);
>
> - if (reset && args.iter.count > args.iter.skip)
> + if (dump_ctx->reset && args.iter.count > args.iter.skip)
> audit_log_nft_set_reset(table, cb->seq,
> args.iter.count - args.iter.skip);
>
> @@ -6088,6 +6085,9 @@ static int nf_tables_getsetelem(struct sk_buff *skb,
>
> nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla);
>
> + if (NFNL_MSG_TYPE(info->nlh->nlmsg_type) == NFT_MSG_GETSETELEM_RESET)
> + reset = true;
> +
> if (info->nlh->nlmsg_flags & NLM_F_DUMP) {
> struct netlink_dump_control c = {
> .start = nf_tables_dump_set_start,
> @@ -6098,6 +6098,7 @@ static int nf_tables_getsetelem(struct sk_buff *skb,
> struct nft_set_dump_ctx dump_ctx = {
> .set = set,
> .ctx = ctx,
> + .reset = reset,
> };
>
> c.data = &dump_ctx;
> @@ -6107,9 +6108,6 @@ static int nf_tables_getsetelem(struct sk_buff *skb,
> if (!nla[NFTA_SET_ELEM_LIST_ELEMENTS])
> return -EINVAL;
>
> - if (NFNL_MSG_TYPE(info->nlh->nlmsg_type) == NFT_MSG_GETSETELEM_RESET)
> - reset = true;
> -
> nla_for_each_nested(attr, nla[NFTA_SET_ELEM_LIST_ELEMENTS], rem) {
> err = nft_get_set_elem(&ctx, set, attr, reset);
> if (err < 0) {
> --
> 2.41.0
>
next prev parent reply other threads:[~2023-09-28 18:53 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-28 16:52 [nf PATCH v2 0/8] Introduce locking for reset requests Phil Sutter
2023-09-28 16:52 ` [nf PATCH v2 1/8] netfilter: nf_tables: Don't allocate nft_rule_dump_ctx Phil Sutter
2023-09-28 18:49 ` Pablo Neira Ayuso
2023-09-29 10:15 ` Phil Sutter
2023-09-28 19:00 ` Florian Westphal
2023-09-29 10:13 ` Phil Sutter
2023-09-28 16:52 ` [nf PATCH v2 2/8] netfilter: nf_tables: Introduce nf_tables_getrule_single() Phil Sutter
2023-09-28 16:52 ` [nf PATCH v2 3/8] netfilter: nf_tables: Add locking for NFT_MSG_GETRULE_RESET requests Phil Sutter
2023-09-28 16:52 ` [nf PATCH v2 4/8] netfilter: nf_tables: Introduce struct nft_obj_dump_ctx Phil Sutter
2023-09-28 16:52 ` [nf PATCH v2 5/8] netfilter: nf_tables: Introduce nf_tables_getobj_single Phil Sutter
2023-09-28 16:52 ` [nf PATCH v2 6/8] netfilter: nf_tables: Add locking for NFT_MSG_GETOBJ_RESET requests Phil Sutter
2023-09-28 16:52 ` [nf PATCH v2 7/8] netfilter: nf_tables: Pass reset bit in nft_set_dump_ctx Phil Sutter
2023-09-28 18:53 ` Pablo Neira Ayuso [this message]
2023-09-29 10:08 ` Phil Sutter
2023-09-29 10:15 ` Pablo Neira Ayuso
2023-09-29 10:18 ` Phil Sutter
2023-09-29 10:56 ` Pablo Neira Ayuso
2023-09-29 11:12 ` Phil Sutter
2023-09-28 16:52 ` [nf PATCH v2 8/8] netfilter: nf_tables: Add locking for NFT_MSG_GETSETELEM_RESET requests Phil Sutter
2023-09-28 17:46 ` Florian Westphal
2023-09-28 18:47 ` Pablo Neira Ayuso
2023-09-28 18:57 ` Florian Westphal
2023-09-28 19:04 ` Pablo Neira Ayuso
2023-09-28 19:21 ` Florian Westphal
2023-09-28 20:07 ` Florian Westphal
2023-09-29 11:25 ` Phil Sutter
2023-09-29 11:30 ` Florian Westphal
2023-09-29 11:45 ` Phil Sutter
2023-09-28 19:39 ` Jozsef Kadlecsik
2023-09-28 20:09 ` Florian Westphal
2023-09-28 20:25 ` Jozsef Kadlecsik
2023-09-29 11:03 ` Phil Sutter
2023-09-28 18:51 ` Pablo Neira Ayuso
2023-09-29 10:28 ` Phil Sutter
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=ZRXLlwkeCBWgXqGZ@calendula \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox