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

From: Florian Fainelli

Date: Wed Nov 18 2026 - 15:14:46 EST


flow_offload_add() sets the timeout of the conntrack entry to NF_CT_DAY
for every offloaded flow, and the GC keeps extending it for GRE too.
flow_offload_fixup_ct() only restores the conntrack timeout of TCP and
UDP flows when the flow is torn down, so an offloaded GRE entry which does
not see any other packet on the slow path stays for up to a day instead
of expiring after the GRE conntrack timeout.

Restore the GRE timeout, replied or unreplied, as for UDP. GRE has no
offload timeout of its own, flow_offload_get_timeout() uses the default
flowtable timeout for it, so use that one when the flow expired.

Fixes: 4e8d9584d154 ("netfilter: flowtable: Support GRE")
Signed-off-by: Florian Fainelli <florian.fainelli@xxxxxxxxxxxx>
---
net/netfilter/nf_flow_table_core.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
index 2aa2647ed9df..051b15aecd89 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]);
+ expired = nf_flow_has_expired(flow);
+ /* GRE has no offload timeout: see flow_offload_get_timeout(). */
+ offload_timeout = NF_FLOW_TIMEOUT;
+#endif
} else {
return;
}
--
2.53.0