OpenBSD: PF队列突破4 Gbps 限制
OpenBSD: PF queues break the 4 Gbps barrier

原始链接: https://undeadly.org/cgi?action=article;sid=20260319125859

## OpenBSD PF 数据包过滤器的带宽限制已移除 OpenBSD 的 PF 数据包过滤器最近的补丁移除了长期存在的带宽配置限制。 之前,HFSC 调度器中的 32 位整数上限会静默地将队列带宽限制在约 4.29 Gbps,导致与现代 10G、25G 和 100G 网络接口出现问题。 该更新将带宽字段扩展到 64 位整数,允许精确配置高达 999G。 这解决了较高速度下的不可预测的调度行为,并修复了 `pftop(1)` 中一个显示错误,该错误之前错误地表示超过 4Gbps 的带宽值。 使用低于 4G 带宽的现有配置不受影响。 此更改确保 PF 队列带宽配置能够与当前和未来的高速网络硬件按预期工作。 该补丁计划于 2026 年 3 月 20 日提交。

OpenBSD的PF防火墙最近的更新打破了队列编排的4 Gbps限制,但Hacker News上的讨论显示,这一改进实际上开发得相当滞后。虽然PF*支持*高达999G(近1 Tbps)的带宽值,但最初的限制引发了争论,因为现代硬件中2.5G和10G端口已经很常见。 用户质疑为什么这个修复没有更早地被优先处理,并推测其根本原因——代码中与2^40限制相关的任意验证上限。有人指出,甚至更快的以太网标准(如1.6T)已经在开发中,这意味着999G的限制可能会比预期更快地变得相关。尽管如此,普遍的看法是,以太网很可能在可预见的未来仍然是主导的网络技术。
相关文章

原文

Contributed by Peter N. M. Hansteen on from the queueing for Terabitia dept.

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) meant that bandwidth values were silently capped at approximately 4.29 Gbps, ” the maximum value of a u_int ".

With 10G, 25G, and 100G network interfaces now commonplace, OpenBSD devs making huge progress unlocking the kernel for SMP, and adding drivers for cards supporting some of these speeds, this limitation started to get in the way. Configuring bandwidth 10G on a queue would silently wrap around, producing incorrect and unpredictable scheduling behaviour.

A new patch widens the bandwidth fields in the kernel's HFSC scheduler from 32-bit to 64-bit integers, removing this bottleneck entirely. The diff also fixes a pre-existing display bug in pftop(1) where bandwidth values above 4 Gbps would be shown incorrectly.

For end users, the practical impact is: PF queue bandwidth configuration now works correctly for modern high-speed interfaces. The familiar syntax just does what you'd expect:


queue rootq on em0 bandwidth 10G
queue defq parent rootq bandwidth 8G default

Values up to 999G are supported, more than enough for interfaces today and the future. Existing configurations using values below 4G continue to work - no changes are needed.

As always, testing of -current snapshots and donations to the OpenBSD Foundation are encouraged.

The editors note that the thread titled PF Queue bandwidth now 64bit for >4Gbps queues on tech@ has the patch and a brief discussion with the conclusion that the code is ready to commit by Friday, March 20th, 2026.

联系我们 contact @ memedata.com