Thread View: muc.lists.freebsd.bugs
3 messages
3 total messages
Started by bugzilla-noreply
Sat, 28 Nov 2026 09:27
[Bug 301217] tun(4): make tunwrite_l3() packet entropy harvesting optional behind RANDOM_ENABLE_TUN
Author: bugzilla-noreply
Date: Sat, 28 Nov 2026 09:27
Date: Sat, 28 Nov 2026 09:27
82 lines
5608 bytes
5608 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301217
Bug ID: 301217
Summary: tun(4): make tunwrite_l3() packet entropy harvesting
optional behind RANDOM_ENABLE_TUN
Product: Base System
Version: 16.0-CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: laamalif@proton.me
Commit a6bc59f20340 disabled ether_input() entropy harvesting behind
RANDOM_ENABLE_ETHER because packet-rate harvesting acquires the global
harvest_context.hc_mtx spinlock and stirs minimal entropy at a steep
packet-rate cost. In sys/net/if_tuntap.c (main 2534dcb233ad),
tunwrite_l3() still harvests every outbound L3 tunnel packet by default:
random_harvest_queue(m, sizeof(*m), RANDOM_NET_TUN);
Because RANDOM_NET_TUN remains enabled in almost_everything_mask in
sys/dev/random/random_harvestq.c (and in /etc/defaults/rc.conf
harvest_mask), every packet written to /dev/tun acquires the global
MTX_SPIN harvest lock with interrupts disabled and runs jenkins_hash()
over all 256 bytes of struct mbuf.
On FreeBSD 16.0-CURRENT amd64 GENERIC-NODEBUG (main 2534dcb233ad, Xeon
6975P-C, 8 vCPUs), injecting 50000 28-byte IPv4 UDP packets per thread
across 8 pinned threads on tun0..tun7 (million packets/sec total, 10
runs):
cc -O2 -Wall -Wextra -Werror -pthread -o tun_tx_bench tun_tx_bench.c
for i in $(jot 10); do sudo ./tun_tx_bench 8 50000; done
x base_tun8.txt
+ patched_tun8.txt
+--------------------------------------------------------------------------+
| x +|
| x + +|
| x +++|
|xx ++++|
||A |A||
+--------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 10 8.778 9.139 9.0165 8.9973 0.09908812
+ 10 27.602 28.392 28.154 28.0824 0.29064839
Difference at 95.0% confidence
19.0851 +/- 0.204019
212.12% +/- 3.13403%
(Student's t, pooled s = 0.217135)
Single-thread throughput (sudo cpuset -l 2 ./tun_tx_bench 1 100000,
N=10) rises from 4.656 Mpps to 5.291 Mpps (+13.63% +/- 0.64% at 95%
confidence), SIOCGIFDATA confirms all packets traverse tunwrite_l3(),
and debug GENERIC (INVARIANTS and WITNESS) runs cleanly. Without
RANDOM_ENABLE_TUN, user_immutable_mask masks off RANDOM_NET_TUN when
/etc/rc.d/random applies /etc/defaults/rc.conf harvest_mask="4607", so
mask_symbolic reports [NET_TUN] and fbt::random_harvest_queue_:entry is
0; built with options RANDOM_ENABLE_TUN, harvesting is active at boot
(56000 calls on ./tun_tx_bench 8 5000), drops to 0 when cleared in
harvest.mask, and resumes (56000 calls) when re-enabled.
Making tunnel packet entropy harvesting optional behind
RANDOM_ENABLE_TUN (documented in random(4), matching RANDOM_ENABLE_ETHER)
avoids per-packet entropy harvesting overhead when RANDOM_ENABLE_TUN is
not configured.
Source inspection shows the same tunwrite_l3() harvesting on stable/15
and stable/14; I have only runtime-tested 16.0-CURRENT amd64.
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 301217] tun(4): make tunwrite_l3() packet entropy harvesting optional behind RANDOM_ENABLE_TUN
Author: bugzilla-noreply
Date: Sat, 28 Nov 2026 09:27
Date: Sat, 28 Nov 2026 09:27
18 lines
2562 bytes
2562 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301217 --- Comment #1 from laamalif@proton.me --- Created attachment 277862 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277862&action=edit gate tunwrite_l3() entropy harvesting behind RANDOM_ENABLE_TUN and document in random(4), matching RANDOM_ENABLE_ETHER -- You are receiving this mail because: You are the assignee for the bug. -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 301217] tun(4): make tunwrite_l3() packet entropy harvesting optional behind RANDOM_ENABLE_TUN
Author: bugzilla-noreply
Date: Sat, 28 Nov 2026 09:27
Date: Sat, 28 Nov 2026 09:27
17 lines
2537 bytes
2537 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301217 --- Comment #2 from laamalif@proton.me --- Created attachment 277863 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277863&action=edit benchmark: multi-threaded L3 /dev/tun packet injection rate; build with -pthread and run as root -- You are receiving this mail because: You are the assignee for the bug. -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
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