From: Paul Blakey <paulb@nvidia.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Cc: vladbu@nvidia.com, fw@strlen.de
Subject: Re: [PATCH nf] netfilter: nf_flow_table: GC pushes back packets to classic path
Date: Wed, 25 Oct 2023 10:03:13 +0300 [thread overview]
Message-ID: <40400a62-9f00-de68-3740-d64f17c72ca3@nvidia.com> (raw)
In-Reply-To: <20231024193815.1987-1-pablo@netfilter.org>
On 24/10/2023 22:38, Pablo Neira Ayuso wrote:
> Since 41f2c7c342d3 ("net/sched: act_ct: Fix promotion of offloaded
> unreplied tuple"), flowtable GC pushes back flows with IPS_SEEN_REPLY
> back to classic path in every run, ie. every second. This is because of
> a new check for NF_FLOW_HW_ESTABLISHED which is specific of sched/act_ct.
>
> In Netfilter's flowtable case, NF_FLOW_HW_ESTABLISHED never gets set on
> and IPS_SEEN_REPLY is unreliable since users decide when to offload the
> flow before, such bit might be set on at a later stage.
>
> Fix it by adding a custom .gc handler that sched/act_ct can use to
> deal with its NF_FLOW_HW_ESTABLISHED bit.
>
> Fixes: 41f2c7c342d3 ("net/sched: act_ct: Fix promotion of offloaded unreplied tuple")
> Reported-by: Vladimir Smelhaus <vl.sm@email.cz>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> include/net/netfilter/nf_flow_table.h | 1 +
> net/netfilter/nf_flow_table_core.c | 14 +++++++-------
> net/sched/act_ct.c | 7 +++++++
> 3 files changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/include/net/netfilter/nf_flow_table.h b/include/net/netfilter/nf_flow_table.h
> index d466e1a3b0b1..fe1507c1db82 100644
> --- a/include/net/netfilter/nf_flow_table.h
> +++ b/include/net/netfilter/nf_flow_table.h
> @@ -53,6 +53,7 @@ struct nf_flowtable_type {
> struct list_head list;
> int family;
> int (*init)(struct nf_flowtable *ft);
> + bool (*gc)(const struct flow_offload *flow);
> int (*setup)(struct nf_flowtable *ft,
> struct net_device *dev,
> enum flow_block_command cmd);
> diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
> index 1d34d700bd09..920a5a29ae1d 100644
> --- a/net/netfilter/nf_flow_table_core.c
> +++ b/net/netfilter/nf_flow_table_core.c
> @@ -316,12 +316,6 @@ void flow_offload_refresh(struct nf_flowtable *flow_table,
> }
> EXPORT_SYMBOL_GPL(flow_offload_refresh);
>
> -static bool nf_flow_is_outdated(const struct flow_offload *flow)
> -{
> - return test_bit(IPS_SEEN_REPLY_BIT, &flow->ct->status) &&
> - !test_bit(NF_FLOW_HW_ESTABLISHED, &flow->flags);
> -}
> -
> static inline bool nf_flow_has_expired(const struct flow_offload *flow)
> {
> return nf_flow_timeout_delta(flow->timeout) <= 0;
> @@ -407,12 +401,18 @@ nf_flow_table_iterate(struct nf_flowtable *flow_table,
> return err;
> }
>
> +static bool nf_flow_custom_gc(struct nf_flowtable *flow_table,
> + const struct flow_offload *flow)
> +{
> + return flow_table->type->gc && flow_table->type->gc(flow);
> +}
> +
> static void nf_flow_offload_gc_step(struct nf_flowtable *flow_table,
> struct flow_offload *flow, void *data)
> {
> if (nf_flow_has_expired(flow) ||
> nf_ct_is_dying(flow->ct) ||
> - nf_flow_is_outdated(flow))
> + nf_flow_custom_gc(flow_table, flow))
> flow_offload_teardown(flow);
>
> if (test_bit(NF_FLOW_TEARDOWN, &flow->flags)) {
> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
> index 7c652d14528b..0d44da4e8c8e 100644
> --- a/net/sched/act_ct.c
> +++ b/net/sched/act_ct.c
> @@ -278,7 +278,14 @@ static int tcf_ct_flow_table_fill_actions(struct net *net,
> return err;
> }
>
> +static bool tcf_ct_flow_is_outdated(const struct flow_offload *flow)
> +{
> + return test_bit(IPS_SEEN_REPLY_BIT, &flow->ct->status) &&
> + !test_bit(NF_FLOW_HW_ESTABLISHED, &flow->flags);
> +}
> +
> static struct nf_flowtable_type flowtable_ct = {
> + .gc = tcf_ct_flow_is_outdated,
> .action = tcf_ct_flow_table_fill_actions,
> .owner = THIS_MODULE,
> };
Reviewed-by: Paul Blakey <paulb@nvidia.com>
prev parent reply other threads:[~2023-10-25 7:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-24 19:38 [PATCH nf] netfilter: nf_flow_table: GC pushes back packets to classic path Pablo Neira Ayuso
2023-10-25 7:03 ` Paul Blakey [this message]
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=40400a62-9f00-de68-3740-d64f17c72ca3@nvidia.com \
--to=paulb@nvidia.com \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=vladbu@nvidia.com \
/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.