[PATCH net v2 0/2] wireguard: free queued packets on peer removal, and test it

From: Andrii Pasichnyk

Date: Thu Nov 26 2026 - 04:47:43 EST


Removing a peer while its receive queue is busy can leave packets on the
per-peer queues. Each of them holds a keypair and a peer reference, so
the peer and the keypair are never freed. Patch 1 frees what is left;
patch 2 adds the test Jason asked for in the v1 thread to netns.sh.

Tested on net e50972666 with the WireGuard selftest VM (x86_64 KVM):

both patches, 4 vCPUs: pass
both patches, NR_CPUS=1: pass
patch 2 only, NR_CPUS=1: fail, 4 peers and 4 keypairs
"merely created" in 10 removals

Changes in v2:
- Patch 1: code unchanged. The reproduction paragraph in the commit
message is corrected: the first reproducer only put load on the first
removal of each run, so "5 in 2140" understated how often this
happens. Under load it is 25-40% of removals with 1 vCPU.
- Patch 2: new, the netns.sh loop from my reply in the v1 thread plus
the larger log buffer it needs.
- Rebased on current net.

v1: https://lore.kernel.org/netdev/20261003201625.4572-1-apasichnik9@xxxxxxxxx/

Andrii Pasichnyk (2):
wireguard: peer: free packets left on the per-peer queues on removal
wireguard: selftests: remove a peer under load

drivers/net/wireguard/peer.c | 24 +++++++++++++++++++
tools/testing/selftests/wireguard/netns.sh | 14 +++++++++++
.../selftests/wireguard/qemu/kernel.config | 2 +-
3 files changed, 39 insertions(+), 1 deletion(-)


base-commit: e509726660dd06ce107437aecf7c106c9d3fc1e7
--
2.43.0