OpenBSD: PF queues break the 4 Gbps barrier
Source: Hacker News
Introduction
OpenBSD’s PF packet filter has long supported HFSC traffic shaping with the queue rules in pf.conf(5). However, an internal 32‑bit limitation in the HFSC service‑curve structure (struct hfsc_sc) capped bandwidth values at approximately 4.29 Gbps – the maximum value of a u_int.
With 10 G, 25 G, and 100 G network interfaces now commonplace, and ongoing kernel work for SMP and high‑speed drivers, this limitation became a practical obstacle. Configuring bandwidth 10G on a queue would silently wrap around, leading to incorrect and unpredictable scheduling behavior.
The Patch
A new patch widens the bandwidth fields in the kernel’s HFSC scheduler from 32‑bit to 64‑bit integers, removing the bottleneck entirely. The same change also fixes a display bug in pftop(1) where bandwidth values above 4 Gbps were shown incorrectly.
Key Changes
- Bandwidth fields in HFSC scheduler are now 64‑bit.
pftopcorrectly displays high‑speed bandwidth values.- No impact on existing configurations that use values below 4 Gbps.
Practical Impact
PF queue bandwidth configuration now works correctly for modern high‑speed interfaces. The familiar syntax remains unchanged:
queue rootq on em0 bandwidth 10G
queue defq parent rootq bandwidth 8G default
Values up to 999 G are supported, more than enough for today’s and future interfaces. Existing configurations using values below 4 G continue to work without modification.
Usage Example
# Define a root queue on interface em0 with 10 Gbps bandwidth
queue rootq on em0 bandwidth 10G
# Define a default child queue with 8 Gbps bandwidth
queue defq parent rootq bandwidth 8G default
References
- OpenBSD project: https://www.openbsd.org/
- PF manual page: https://man.openbsd.org/pf
- PF queueing documentation: https://man.openbsd.org/pf.conf#QUEUEING
pftopsource: https://cvsweb.openbsd.org/ports/sysutils/pftop- Patch discussion: https://marc.info/?l=openbsd-tech&m=177375870004342&w=2
- Patch conclusion (ready to commit): https://marc.info/?l=openbsd-tech&m=177379810031898&w=2
- OpenBSD Foundation donations: https://www.openbsdfoundation.org/donations.html