The Linux Kernel Mailing List
 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 4/4] selftests: netfilter: check the GRE timeout after flowtable teardown
Date: Sun, 22 Nov 2026 21:17:29 +0000	[thread overview]
Message-ID: <179538224965.3135.5112190126089308317@kernel.org> (raw)
In-Reply-To: <20261118201250.2075007-5-florian.fainelli@broadcom.com>

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

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

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] In nft_flowtable_gre.sh the test treats `nft delete table inet
  filter` as tearing down the offloaded GRE flow before the command…
- [Low] The timeout check in nft_flowtable_gre.sh (lines 127-135) fails
  only when the restored timeout is greater than…

--

selftests: netfilter: check the GRE timeout after flowtable teardown

This adds a selftest that offloads a GRE flow through a flowtable in a
router namespace and then deletes the flowtable. It checks that the
conntrack entry timeout goes back to the GRE stream timeout instead of
the one-day offload timeout. The GRE and PPTP options are also added to
the selftest config.

> diff --git a/tools/testing/selftests/net/netfilter/nft_flowtable_gre.sh b/tools/testing/selftests/net/netfilter/nft_flowtable_gre.sh
> new file mode 100755
> index 0000000000000..5efad6908b3fc
> --- /dev/null
> +++ b/tools/testing/selftests/net/netfilter/nft_flowtable_gre.sh
> @@ -0,0 +1,137 @@

[ ... ]

> +# The entry has the timeout of an offloaded flow: remove the flowtable, which
> +# tears down its flows. Nothing else refreshes the conntrack entry.
> +if ! ip netns exec "$nsr1" nft delete table inet filter; then
> +	echo "FAIL: could not remove the flowtable"
> +	exit 1
> +fi
> +
> +if gre_entry_offloaded; then
> +	echo "FAIL: the GRE entry is still marked as offloaded"
> +	ret=1
> +fi
> +
> +timeout=$(gre_entry_timeout)

[Severity: Medium]
Is the flowtable teardown guaranteed to be finished by the time nft delete
table returns?

In net/netfilter/nf_tables_api.c, flowtable destruction seems to be
deferred to a workqueue:

nf_tables_commit_release()
    schedule_work(&nft_net->destroy_work);

The work item also waits for an RCU grace period before it frees the
flowtable:

nf_tables_trans_destroy_work()
    synchronize_rcu();
    nft_commit_release()
        nf_tables_flowtable_destroy()
            nf_flow_table_free()
                ... flow_offload_teardown()

IPS_OFFLOAD_BIT is cleared and the GRE timeout restored only in
flow_offload_teardown():

net/netfilter/nf_flow_table_core.c:flow_offload_teardown() {
	clear_bit(IPS_OFFLOAD_BIT, &flow->ct->status);
	if (!test_and_set_bit(NF_FLOW_TEARDOWN, &flow->flags))
		flow_offload_fixup_ct(flow);
}

If conntrack -L runs before the deferred work completes,
gre_entry_offloaded() would still see OFFLOAD and print "still marked as
offloaded".

gre_entry_timeout() would also return nothing. While the entry is
offloaded, ctnetlink_dump_info() in nf_conntrack_netlink.c does not dump
the timeout:

	if (!test_bit(IPS_OFFLOAD_BIT, &ct->status) &&
	    (ctnetlink_dump_timeout(skb, ct, false) < 0 ||

In that case the test also prints the misleading "no conntrack entry for
the GRE flow" message, even though the entry exists.

Can this make the test fail at random on a fixed kernel? That seems most
likely on loaded or virtualized CI, where synchronize_rcu() can be slow.
Would polling with busywait or slowwait from lib.sh, until OFFLOAD clears
and a timeout is printed, avoid the race?

The comment above ("remove the flowtable, which tears down its flows") and
the commit message both describe the teardown as synchronous.

> +max=$(ip netns exec "$nsr1" sysctl -n net.netfilter.nf_conntrack_gre_timeout_stream 2>/dev/null)
> +[ -z "$max" ] && max=180
> +
> +if [ -z "$timeout" ]; then
> +	echo "FAIL: no conntrack entry for the GRE flow"
> +	ret=1
> +elif [ "$timeout" -gt "$max" ]; then

[Severity: Low]
This isn't a bug, but only an upper bound is checked here, so any timeout
from 0 to 180 is reported as PASS. The check does catch the 86399 regression
the commit targets.

The "ct state established" rule requires IPS_SEEN_REPLY, and the flow has
not expired. So flow_offload_fixup_ct() should pick
tn->timeouts[GRE_CT_REPLIED] without subtracting NF_FLOW_TIMEOUT, giving
about 179-180 seconds.

The following broken fixups would all still pass this check:

- one that picks GRE_CT_UNREPLIED (30s)
- one that wrongly subtracts NF_FLOW_TIMEOUT (about 150s)
- one that clamps the timeout to 0

Would a lower bound, such as max minus a small slack, better match the
"restored to the GRE timeout" behaviour described in the header comment?

> +	echo "FAIL: the GRE entry timeout is $timeout seconds after teardown, expected at most $max"
> +	ret=1
> +else
> +	echo "PASS: the GRE entry timeout was restored to $timeout seconds"
> +fi

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

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

Thread overview: 11+ 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-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
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 [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=179538224965.3135.5112190126089308317@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