From: Stefano Brivio <sbrivio@redhat.com>
To: Florian Westphal <fw@strlen.de>
Cc: <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH nf-next 8/9] netfilter: nft_set_pipapo: move cloning of match info to insert/removal path
Date: Mon, 8 Apr 2024 17:45:52 +0200 [thread overview]
Message-ID: <20240408174552.6c1dc303@elisabeth> (raw)
In-Reply-To: <20240403084113.18823-9-fw@strlen.de>
On Wed, 3 Apr 2024 10:41:08 +0200
Florian Westphal <fw@strlen.de> wrote:
> This set type keeps two copies of the sets' content,
> priv->match (live version, used to match from packet path)
> priv->clone (work-in-progress version of the 'future' priv->match).
>
> All additions and removals are done on priv->clone. When transaction
> completes, priv->clone becomes priv->match and a new clone is allocated
> for use by next transaction.
>
> Problem is that the cloning requires GFP_KERNEL allocations but we
> cannot fail at either commit or abort time.
>
> This patch defers the clone until we get an insertion or removal
> request. This allows us to handle OOM situations correctly.
>
> This also allows to remove ->dirty in a followup change:
>
> If ->clone exists, ->dirty is always true
> If ->clone is NULL, ->dirty is always false, no elements were added
> or removed (except catchall elements which are external to the specific
> set backend).
>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
> net/netfilter/nft_set_pipapo.c | 62 ++++++++++++++++++++++------------
> 1 file changed, 41 insertions(+), 21 deletions(-)
>
> diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c
> index 2cc905e92889..eef6a978561f 100644
> --- a/net/netfilter/nft_set_pipapo.c
> +++ b/net/netfilter/nft_set_pipapo.c
> @@ -615,6 +615,9 @@ nft_pipapo_get(const struct net *net, const struct nft_set *set,
> struct nft_pipapo_match *m = priv->clone;
> struct nft_pipapo_elem *e;
>
> + if (!m)
> + m = rcu_dereference(priv->match);
> +
> e = pipapo_get(net, set, m, (const u8 *)elem->key.val.data,
> nft_genmask_cur(net), get_jiffies_64(),
> GFP_ATOMIC);
> @@ -1259,6 +1262,23 @@ static bool nft_pipapo_transaction_mutex_held(const struct nft_set *set)
> #endif
> }
>
> +static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old);
> +
> +static struct nft_pipapo_match *pipapo_maybe_clone(const struct nft_set *set)
Nit:
/**
* pipapo_maybe_clone() - Build clone for pending data changes, if not existing
* @set: nftables API set representation
*
* Return: newly created or existing clone, if any. NULL on allocation failure
*/
The rest of the series looks good (and like a big improvement) to me,
thanks! For all the patches minus 3/9,
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
--
Stefano
next prev parent reply other threads:[~2024-04-08 15:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 8:41 [PATCH nf-next 0/9] nft_set_pipapo: remove cannot-fail allocations on commit and abort Florian Westphal
2024-04-03 8:41 ` [PATCH nf-next 1/9] netfilter: nft_set_pipapo: move prove_locking helper around Florian Westphal
2024-04-03 8:41 ` [PATCH nf-next 2/9] netfilter: nft_set_pipapo: make pipapo_clone helper return NULL Florian Westphal
2024-04-03 8:41 ` [PATCH nf-next 3/9] netfilter: nft_set_pipapo: prepare destroy function for on-demand clone Florian Westphal
2024-04-08 15:45 ` Stefano Brivio
2024-04-09 11:07 ` Florian Westphal
2024-04-09 12:54 ` Stefano Brivio
2024-04-09 13:04 ` Florian Westphal
2024-04-09 13:10 ` Stefano Brivio
2024-04-03 8:41 ` [PATCH nf-next 4/9] netfilter: nft_set_pipapo: prepare walk " Florian Westphal
2024-04-03 8:41 ` [PATCH nf-next 5/9] netfilter: nf_tables: pass new nft_iter_type hint to walker Florian Westphal
2024-04-03 8:41 ` [PATCH nf-next 6/9] netfilter: nft_set_pipapo: merge deactivate helper into caller Florian Westphal
2024-04-03 8:41 ` [PATCH nf-next 7/9] netfilter: nft_set_pipapo: prepare pipapo_get helper for on-demand clone Florian Westphal
2024-04-03 8:41 ` [PATCH nf-next 8/9] netfilter: nft_set_pipapo: move cloning of match info to insert/removal path Florian Westphal
2024-04-08 15:45 ` Stefano Brivio [this message]
2024-04-03 8:41 ` [PATCH nf-next 9/9] netfilter: nft_set_pipapo: remove dirty flag Florian Westphal
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=20240408174552.6c1dc303@elisabeth \
--to=sbrivio@redhat.com \
--cc=fw@strlen.de \
--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.