All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf,v2 3/3] netfilter: nf_tables: add hook transactions for device deletions
Date: Wed, 15 Apr 2026 22:51:09 +0200	[thread overview]
Message-ID: <ad_6PaOwZJRHWgTd@strlen.de> (raw)
In-Reply-To: <20260415171038.41442-2-pablo@netfilter.org>

Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> Restore the flag that indicates that the hook is going away, ie.
> NFT_HOOK_REMOVE, but add a new transaction object to track deletion
> of hooks without altering the basechain/flowtable hook_list during
> the preparation phase.
> 
> The existing approach that moves the hook from the basechain/flowtable
> hook_list to transaction hook_list breaks netlink dump path readers
> of this RCU-protected list.
> 
> It should be possible use an array for nft_trans_hook to store the
> deleted hooks to compact the representation but I am not expecting
> many hook object, specially now that wildcard support for devices
> is in place.
> 
> Note that the nft_trans_chain_hooks() list contains a list of struct
> nft_trans_hook objects for DELCHAIN and DELFLOWTABLE commands, while
> this list stores struct nft_hook objects for NEWCHAIN and NEWFLOWTABLE.
> Note that new commands can be updated to use nft_trans_hook for
> consistency.
> 
> Fixes: 7d937b107108 ("netfilter: nf_tables: support for deleting devices in an existing netdev chain")
> Fixes: b6d9014a3335 ("netfilter: nf_tables: delete flowtable hooks via transaction list")
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> v2: no changes.
> 
>  include/net/netfilter/nf_tables.h |  13 ++++
>  net/netfilter/nf_tables_api.c     | 124 ++++++++++++++++++++++++++----
>  2 files changed, 120 insertions(+), 17 deletions(-)
> 
> diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
> index ec8a8ec9c0aa..3ec41574af77 100644
> --- a/include/net/netfilter/nf_tables.h
> +++ b/include/net/netfilter/nf_tables.h
> @@ -1216,12 +1216,15 @@ struct nft_stats {
>  	struct u64_stats_sync	syncp;
>  };
>  
> +#define NFT_HOOK_REMOVE	(1 << 0)
> +
>  struct nft_hook {
>  	struct list_head	list;
>  	struct list_head	ops_list;
>  	struct rcu_head		rcu;
>  	char			ifname[IFNAMSIZ];
>  	u8			ifnamelen;
> +	u8			flags;
>  };
>  
>  struct nf_hook_ops *nft_hook_find_ops(const struct nft_hook *hook,
> @@ -1676,6 +1679,16 @@ struct nft_trans {
>  	u8				put_net:1;
>  };
>  
> +/**
> + * struct nft_trans_hook - nf_tables hook update in transaction
> + * @list: used internally
> + * @hook: struct nft_hook with the device hook
> + */
> +struct nft_trans_hook {
> +	struct list_head		list;
> +	struct nft_hook			*hook;
> +};

Do I get this correctly?

nft_trans_container_flowtable(trans)->hook_list
and
nft_trans_container_chain(trans)->hook_list

Either hold 'struct nft_hook' objects or nft_trans_hook objects?
Former when adding, latter when removing from existing base hook?

> +		trans_hook = kmalloc(sizeof(*trans_hook), GFP_KERNEL);

Note that 69050f8d6d07 ("treewide: Replace kmalloc with kmalloc_obj for non-scalar types")
transformed such allocation requests to use "kmalloc_obj(*trans_hook, GFP_KERNEL);"
instead.

  reply	other threads:[~2026-04-15 20:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-15 17:10 [PATCH nf,v2 2/3] netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase Pablo Neira Ayuso
2026-04-15 17:10 ` [PATCH nf,v2 3/3] netfilter: nf_tables: add hook transactions for device deletions Pablo Neira Ayuso
2026-04-15 20:51   ` Florian Westphal [this message]
2026-04-15 21:05     ` Pablo Neira Ayuso

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=ad_6PaOwZJRHWgTd@strlen.de \
    --to=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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.