mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: apasichnik9@gmail.com
Cc: Jason@zx2c4.com, wireguard@lists.zx2c4.com,
	netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, shuah@kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2 2/2] wireguard: selftests: remove a peer under load
Date: Fri, 27 Nov 2026 09:48:09 +0000	[thread overview]
Message-ID: <179577288974.3135.10854019193613008297@kernel.org> (raw)
In-Reply-To: <20261126094722.73025-3-apasichnik9@gmail.com>

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

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

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] Raising CONFIG_LOG_BUF_SHIFT from 18 to 20 leaves almost no
  headroom for the log volume the new loop in…
- [Low] The commit message gives the test's ability to detect the
  regression only for 1 vCPU ('Without the previous patch it fails in…
- [Low] The new loop in netns.sh (lines 213-222) relies on fixed waits at
  two points and checks neither result.

--

wireguard: selftests: remove a peer under load

This adds a loop to netns.sh that removes and re-adds a peer ten times
while a UDP iperf3 flood keeps its receive queue busy. The final
created/destroyed object check should then catch peers or keypairs that
queued packets keep alive. It also raises CONFIG_LOG_BUF_SHIFT from 18 to
20 in the qemu kernel.config so the log can hold the extra output.

> The loop adds about 13 seconds to a run. Without the previous patch it
> fails in every run with 1 vCPU.

[Severity: Low]
The detection rate is given only for 1 vCPU, but the qemu harness uses
4 vCPUs by default:

tools/testing/selftests/wireguard/qemu/Makefile:
NR_CPUS ?= 4
...
		-smp $(NR_CPUS) \

With 4 vCPUs, NAPI and the decrypt workers get more CPU time to drain
rx_queue before napi_disable(). The loop may therefore catch the
regression less often in a default run.

Could the commit message give the detection rate with the default
NR_CPUS? Or it could say that NR_CPUS=1 is needed to reproduce the
regression reliably.

> diff --git a/tools/testing/selftests/wireguard/netns.sh b/tools/testing/selftests/wireguard/netns.sh
> index a8f550aecb35d..8303802c02f27 100755
> --- a/tools/testing/selftests/wireguard/netns.sh
> +++ b/tools/testing/selftests/wireguard/netns.sh
> @@ -207,6 +207,20 @@ n0 iptables -F INPUT

[ ... ]

> +for ((i = 0; i < 10; ++i)); do
> +	n1 iperf3 -s -1 -B 192.168.241.1 &
> +	pids=( $! ); waitiperf $netns1 $!
> +	n2 iperf3 -Z -t 2 -b 0 -u -l 64 -P 4 -c 192.168.241.1 >/dev/null 2>&1 &
> +	pids+=( $! ); sleep 1
> +	n1 wg set wg0 peer "$pub2" remove
> +	kill "${pids[@]}" 2>/dev/null || true; wait "${pids[@]}" || true
> +	n1 wg set wg0 peer "$pub2" preshared-key <(echo "$psk") allowed-ips 192.168.241.2/32,fd00::2/128 endpoint 127.0.0.1:2
> +	n1 ping -c 1 -W 1 192.168.241.2
> +done

[Severity: Low]
Does anything confirm that the peer is actually under load when it is
removed?

The fixed sleep 1 is the only ordering between starting the flood and
the removal. The client's output goes to /dev/null, and wait ... || true
throws away its exit status.

The iperf3 UDP streams might not start within that second, which is
possible on slow TCG targets. The iteration would then remove an idle
peer and the final object check would still pass. The leak this loop
targets would go unnoticed.

Checking wg show wg0 transfer, or rx_bytes on n1, before the removal
would catch that.

Separately, can the single ping abort the whole run? It needs a full new
handshake plus a round trip within 1 second. It also runs under set -e
with no retry.

If a handshake packet is lost or late, the next attempt only comes after
REKEY_TIMEOUT (5 seconds). The ping then fails and netns.sh exits.

Right after the removal, up to 1024 queued packets may still be draining.
About 1000 KERN_DEBUG lines are also going to the console, because
init.c writes 9 to /proc/sys/kernel/printk.

Other places in netns.sh already use a single 1-second ping after a
handshake without trouble. This is a timing concern rather than an
observed failure.

> diff --git a/tools/testing/selftests/wireguard/qemu/kernel.config b/tools/testing/selftests/wireguard/qemu/kernel.config
> index 368fd9d600c83..c69a408a5a94c 100644
> --- a/tools/testing/selftests/wireguard/qemu/kernel.config
> +++ b/tools/testing/selftests/wireguard/qemu/kernel.config
> @@ -67,7 +67,7 @@ CONFIG_SYSCTL=y

[ ... ]

> -CONFIG_LOG_BUF_SHIFT=18
> +CONFIG_LOG_BUF_SHIFT=20

[Severity: Medium]
Does 1 MiB leave enough headroom for what the new loop can log?

netns.sh sets message_cost to 0, and WIREGUARD_DEBUG=y defines DEBUG.
In wg_peer_remove(), peer_make_dead() takes the peer out of allowedips
first. NAPI then keeps draining peer->rx_queue until napi_disable().

Each packet handled in that window fails the source check and logs a
line:

drivers/net/wireguard/receive.c:wg_packet_consume_data_done() {
    ...
	net_dbg_skb_ratelimited("%s: Packet has unallowed src IP (%pISc) from peer %llu (%pISpfsc)\n",
    ...
}

The only limit on the per-peer queue is in wg_prev_queue_enqueue():

	if (!atomic_add_unless(&queue->count, 1, MAX_QUEUED_PACKETS))

MAX_QUEUED_PACKETS is 1024, so one removal can log about 1024 of these
lines. Each record takes about 96 bytes in the printk data ring: about
86 bytes of text plus the 8-byte block id, rounded up.

Ten removals can then use 10 * 1024 * 96 = 983,040 bytes. That is about
94% of the 1,048,576-byte ring. Even with the commit message's estimate
of about 1000 lines per removal, it is still about 91%.

That leaves roughly 65-88 KiB for everything else netns.sh logs, from
the run's start to its end. This covers the "created" lines from
configure_peers at the start, the handshake and keepalive debug lines,
and about 80 netlink-test peers. n2's original "Peer N created" record
has to survive the whole run.

If the ring wraps, the object check at the end of netns.sh would see a
"destroyed" record without its "created" record. It would then report
"merely destroyed", which is the failure this change is meant to
prevent.

The rest of the log has not been measured, so this rests on the
arithmetic above.

Would setting a non-zero message_cost while the loop runs avoid relying
on such a thin margin? A larger shift such as 21 would also work.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126094722.73025-1-apasichnik9%40gmail.com

  reply	other threads:[~2026-11-27  9:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  9:47 [PATCH net v2 0/2] wireguard: free queued packets on peer removal, and test it Andrii Pasichnyk
2026-11-26  9:47 ` [PATCH net v2 1/2] wireguard: peer: free packets left on the per-peer queues on removal Andrii Pasichnyk
2026-11-27  9:48   ` netdev-bot+sashiko
2026-11-27  9:59     ` Andrii Pasichnyk
2026-11-26  9:47 ` [PATCH net v2 2/2] wireguard: selftests: remove a peer under load Andrii Pasichnyk
2026-11-27  9:48   ` netdev-bot+sashiko [this message]
2026-11-27  9:59     ` Andrii Pasichnyk
2026-11-26  9:52 ` [PATCH net v2 0/2] wireguard: free queued packets on peer removal, and test it netdev-bot+sinfo
2026-11-27 10:22   ` Andrii Pasichnyk

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=179577288974.3135.10854019193613008297@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=apasichnik9@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=wireguard@lists.zx2c4.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®