mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: florian.fainelli@broadcom.com
Cc: netdev@vger.kernel.org, pablo@netfilter.org, fw@strlen.de,
	phil@nwl.cc, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	shuah@kernel.org, toshiaki.makita1@gmail.com,
	linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org,
	coreteam@netfilter.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net 2/4] netfilter: flowtable: restore the GRE conntrack timeout on teardown
Date: Sun, 22 Nov 2026 21:17:25 +0000	[thread overview]
Message-ID: <179538224582.3135.4873472373234094009@kernel.org> (raw)
In-Reply-To: <20261118201250.2075007-3-florian.fainelli@broadcom.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch adds a GRE branch to flow_offload_fixup_ct()
  (net/netfilter/nf_flow_table_core.c).

--

netfilter: flowtable: restore the GRE conntrack timeout on teardown

This commit adds a GRE branch to flow_offload_fixup_ct(). When a GRE flow
is torn down, its conntrack timeout is restored to the GRE replied or
unreplied timeout. Without this, the entry keeps the NF_CT_DAY timeout it
got at offload time. GRE has no offload timeout of its own, so
NF_FLOW_TIMEOUT is subtracted when the flow has expired.

> diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
> index 2aa2647ed9df0..051b15aecd893 100644
> --- a/net/netfilter/nf_flow_table_core.c
> +++ b/net/netfilter/nf_flow_table_core.c
> @@ -237,6 +237,18 @@ static void flow_offload_fixup_ct(struct flow_offload *flow)
>  		timeout = READ_ONCE(tn->timeouts[state]);
>  		expired = nf_flow_has_expired(flow);
>  		offload_timeout = READ_ONCE(tn->offload_timeout);
> +#ifdef CONFIG_NF_CT_PROTO_GRE
> +	} else if (l4num == IPPROTO_GRE) {
> +		const struct nf_gre_net *tn = nf_gre_pernet(net);
> +		enum gre_conntrack state =
> +			test_bit(IPS_SEEN_REPLY_BIT, &ct->status) ?
> +			GRE_CT_REPLIED : GRE_CT_UNREPLIED;
> +
> +		timeout = READ_ONCE(tn->timeouts[state]);

[Severity: Medium]
Should this read the per-conntrack GRE timeouts instead of the per-netns
defaults?

The GRE tracker does not refresh entries with the pernet values directly.
In nf_conntrack_gre_packet(), the per-ct fields are set from an attached
timeout policy when one exists. The pernet defaults are only the fallback:

net/netfilter/nf_conntrack_proto_gre.c:nf_conntrack_gre_packet() {
    ...
	if (!nf_ct_is_confirmed(ct)) {
		unsigned int *timeouts = nf_ct_timeout_lookup(ct);

		if (!timeouts)
			timeouts = gre_get_timeouts(nf_ct_net(ct));
		...
		ct->proto.gre.stream_timeout = timeouts[GRE_CT_REPLIED];
		ct->proto.gre.timeout = timeouts[GRE_CT_UNREPLIED];
	}
    ...
}

Every later refresh then uses ct->proto.gre.stream_timeout or
ct->proto.gre.timeout.

GRE registers .ctnl_timeout, so an nft ct timeout object or an
nfnetlink_cttimeout policy can be attached. nft_flow_offload_eval()
rejects GRE flows that are NATed, keyed, or have a helper. It does not
reject flows that have a timeout policy.

As an example, take a policy that sets the GRE replied timeout to 2h. An
offloaded GRE v0 flow goes idle, and the GC tears it down with expired
set to true. This branch then computes the default 180s minus
NF_FLOW_TIMEOUT, which is 150s. Since nf_flow_timeout_delta(ct->timeout)
is larger than that, nf_ct_refresh() makes the entry expire in about 2.5
minutes instead of 2h.

The reverse also happens: with a policy shorter than the sysctl value, the
longer default replaces it.

Would reading ct->proto.gre.stream_timeout and ct->proto.gre.timeout here
match what the GRE tracker actually uses? The UDP branch above has the
same pattern, but that code predates this patch.

> +		expired = nf_flow_has_expired(flow);
> +		/* GRE has no offload timeout: see flow_offload_get_timeout(). */
> +		offload_timeout = NF_FLOW_TIMEOUT;
> +#endif
>  	} else {
>  		return;
>  	}

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118201250.2075007-1-florian.fainelli%40broadcom.com

  parent reply	other threads:[~2026-11-22 21:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 20:12 [PATCH net 0/4] netfilter: flowtable: Preliminary fixes Florian Fainelli
2026-11-18 20:12 ` [PATCH net 1/4] netfilter: flowtable: do not queue offload work after DESTROY Florian Fainelli
2026-11-21 23:23   ` Pablo Neira Ayuso
2026-11-22 21:17   ` netdev-bot+sashiko
2026-11-22 22:16     ` Pablo Neira Ayuso
2026-11-18 20:12 ` [PATCH net 2/4] netfilter: flowtable: restore the GRE conntrack timeout on teardown Florian Fainelli
2026-11-21 23:10   ` Pablo Neira Ayuso
2026-11-22 21:17   ` netdev-bot+sashiko [this message]
2026-11-18 20:12 ` [PATCH net 3/4] selftests: netfilter: check hardware offload work after DESTROY Florian Fainelli
2026-11-22 21:17   ` netdev-bot+sashiko
2026-11-18 20:12 ` [PATCH net 4/4] selftests: netfilter: check the GRE timeout after flowtable teardown Florian Fainelli
2026-11-22 21:17   ` netdev-bot+sashiko

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=179538224582.3135.4873472373234094009@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=shuah@kernel.org \
    --cc=toshiaki.makita1@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®