Index | Thread | Search

From:
Crystal Kolipe <kolipe.c@exoticsilicon.com>
Subject:
Re: pfctl checking of bandwidth specs
To:
Alexandr Nedvedicky <sashan@fastmail.net>, Andy Lemin <andrew.lemin@gmail.com>, tech@openbsd.org
Date:
Thu, 19 Mar 2026 14:52:39 +0000

Download raw body.

Thread
On Thu, Mar 19, 2026 at 12:56:53PM +0000, Stuart Henderson wrote:
> pfctl has some issue with setting bandwidth specs to >=1000G that
> I don't fully understand:
> 
> $ echo 'queue rootq on lo0 bandwidth 999999999K
>     queue defq parent rootq bandwidth 8G default' | pfctl -nvf -
> queue rootq on lo0 bandwidth 999999999K
> queue defq parent rootq bandwidth 8G default
> 
> $ echo 'queue rootq on lo0 bandwidth 1000000000K
>     queue defq parent rootq bandwidth 8G default' | pfctl -nvf -
> queue rootq on lo0 bandwidth 1
> queue defq parent rootq bandwidth 8G default
> 
> this only applies with unit specifiers, not raw numbers.

I am able to reproduce the issue on 7.8-release using raw numbers.

> Worried about wraparounds with casts, I tried a separate multiplier
> variable and checking for bps > (double)(LLONG-MAX / mult) but that
> didn't help.
> 
> Unless someone has a better idea, the parser could be changed like
> this to reject values causing the problem.

The issue is with the printing code in pfctl_parser.c.

Have a look at print_bwspec(), there is a hard coded array of unit specifiers,
" KMG", and the 'i' loop is hard-coded to loop to 3.

Adding "T" and changing the loop condition makes it work for me.

Either that, or I've completely mis-understood what you're complaining about.