Re: [PATCH net 2/4] netfilter: flowtable: restore the GRE conntrack timeout on teardown

From: netdev-bot+sashiko

Date: Sun Nov 22 2026 - 16:17:39 EST


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