๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Andrii Pasichnyk Fri, 27 Nov 2026 10:22
[PATCH net v3 2/2] wireguard: selftests: remove a peer under load
#23477
Author: Andrii Pasichnyk
Date: Fri, 27 Nov 2026 10:22
69 lines
14058 bytes
Remove a peer while a UDP flood keeps its receive queue busy, re-add it,
and repeat ten times. Packets left on the per-peer receive queue keep
the peer and its keypair alive, which the created/destroyed object check
at the end of netns.sh reports as "merely created".

The ping after the re-add makes the new peer handshake at once. Without
it the other side keeps using the old keypair until its own timers start
a handshake, nothing flows in the meantime, and only the first removal
happens under load.

netns.sh sets message_cost to 0, so every removal under load logs up to
1024 "Packet has unallowed src IP" lines, one per queued packet. Ten of
them overflow the 256 KB kernel log buffer; the object check then reads
an incomplete log, reports peers as "merely destroyed" and can miss real
leaks. In the worst case the loop logs about 1 MB, so raise
CONFIG_LOG_BUF_SHIFT to 21.

The loop adds about 13 seconds to a run. Without the previous patch it
fails in every run with NR_CPUS=1. With the default four CPUs the leak
is hit much less often, so NR_CPUS=1 is the configuration that checks
for it.

Signed-off-by: Andrii Pasichnyk <apasichnik9@gmail.com>
---
 tools/testing/selftests/wireguard/netns.sh         | 14 ++++++++++++++
 .../testing/selftests/wireguard/qemu/kernel.config |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/wireguard/netns.sh b/tools/testing/selftests/wireguard/netns.sh
index a8f550aec..8303802c0 100755
--- a/tools/testing/selftests/wireguard/netns.sh
+++ b/tools/testing/selftests/wireguard/netns.sh
@@ -207,6 +207,20 @@ n0 iptables -F INPUT
 ip1 link set wg0 mtu $orig_mtu
 ip2 link set wg0 mtu $orig_mtu
 
+# Remove a peer while a UDP flood keeps its receive queue busy, then re-add it;
+# packets left on the per-peer queues would keep it from being destroyed,
+# which the created/destroyed check at the end catches.
+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
+
 # Test using IPv4 that roaming works
 ip0 -4 addr del 127.0.0.1/8 dev lo
 ip0 -4 addr add 127.212.121.99/8 dev lo
diff --git a/tools/testing/selftests/wireguard/qemu/kernel.config b/tools/testing/selftests/wireguard/qemu/kernel.config
index 368fd9d60..1adf7cb6e 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_SYSFS=y
 CONFIG_TMPFS=y
 CONFIG_CONSOLE_LOGLEVEL_DEFAULT=15
-CONFIG_LOG_BUF_SHIFT=18
+CONFIG_LOG_BUF_SHIFT=21
 CONFIG_PRINTK_TIME=y
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_LEGACY_VSYSCALL_NONE=y
-- 
2.43.0
Re: [PATCH net v3 2/2] wireguard: selftests: remove a peer under load
#23842
Author: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 10:25
79 lines
11003 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] With the in-tree default VM configuration, the new loop in
  tools/testing/selftests/wireguard/netns.sh (lines 210-222) willโ€ฆ

--

wireguard: selftests: remove a peer under load

This adds a loop to netns.sh that removes a peer ten times while a UDP
flood is running, and re-adds it after each removal. The goal is to catch
packets left on the per-peer receive queue that keep the peer alive. It
also raises CONFIG_LOG_BUF_SHIFT to 21 in the qemu kernel.config so the
created/destroyed object check sees the whole log.

> 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
>  ip1 link set wg0 mtu $orig_mtu
>  ip2 link set wg0 mtu $orig_mtu
>  
> +# Remove a peer while a UDP flood keeps its receive queue busy, then re-add it;
> +# packets left on the per-peer queues would keep it from being destroyed,
> +# which the created/destroyed check at the end catches.
> +for ((i = 0; i < 10; ++i)); do

[Severity: Low]
Will this loop catch a regression of the rx_queue purge in the default
selftest configuration?

The qemu Makefile defaults to a 4-CPU guest:

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

The commit message says that with four CPUs "the leak is hit much less
often, so NR_CPUS=1 is the configuration that checks for it". The leak
needs rx_queue to still hold more than one NAPI budget of packets at
napi_disable(). With several CPUs, the decrypt workers and NAPI usually
drain the queue first.

Nothing in the tree records this. No Makefile target runs netns.sh with
NR_CPUS=1. The comment above also says the leak is something "which the
created/destroyed check at the end catches", with no mention of the
single-CPU requirement.

As a result, a plain "make -C tools/testing/selftests/wireguard/qemu" run,
including in CI, would usually pass on a kernel where
peer_remove_after_dead() no longer calls peer_purge_rx_queue().

Could the comment or the qemu Makefile mention NR_CPUS=1? Alternatively,
could a single-CPU run be added so the check is exercised by default?

> +	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
> +

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127102243.49405-1-apasichnik9%40gmail.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads