Subject: Re: [PATCH net v8 4/6] net/sched: netem: validate slot configuration

From: Stephen Hemminger <[email-masked]>
Date: Fri, 24 Apr 2026 16:06:09 -0700

On Fri, 24 Apr 2026 16:17:13 -0400
Jamal Hadi Salim <[email-masked]> wrote:

> () ncalls s
> 
> 
> On Fri, Apr 24, 2026 at 11:07 AM Stephen Hemminger
> <[email-masked]> wrote:
> >
> > On Thu, 23 Apr 2026 17:12:15 -0400
> > Jamal Hadi Salim <[email-masked]> wrote:
> >  
> > > > > This is intended and explicitly explained in the cover letter.  
> > > > Jamal, given the uAPI implication, could you please double check that
> > > > the change is fine?
> > > >  
> > >
> > > It should be fine; at least iproute2 will never allow the kernel to
> > > receive a negative number.
> > > Stephen brought up the fact that strtod() could return a -ve number
> > > (but at least iproute2 makes sure negative numbers are not carried
> > > forward to the kernel).
> > >
> > > cheers,
> > > jamal  
> >
> > Iproute2 blocks negative values kind of by accident.
> > The NEXT_IS_NUMBER() macro looks for digit at start of arg.
> > To hit this you need to either use raw netlink or change NEXT_IS_NUMBER()
> > to NEXT_IS_SIGNED_NUMBER() where slot values are parsed.  
> 
> For this specific attribute it was intentional:
> ...
> if (get_time64(&slot.dist_jitter, *argv)) { //get_time64 calls
> strtod() which could set dist_jitter -ve
>     explain1("slot jitter");
>      return -1;
> }
> if (slot.dist_jitter <= 0) {  // we reject -ve values
>     fprintf(stderr, "Non-positive jitter\n");
>     return -1;
> }
> 
> cheers,
> jamal

I see no cases where negative time value is a valid input.
Doing audit of netem:
- slot times
   parsing rejects -10ms for min delay and -100ms for max delay
- delay
   negative value is accepted, but internally acts like 0
- jitter
   negative value is rejected (i.e What is "-2s")
- slot distribution delay
   same as regular delay, accepted but internally acts like 0
   negative jitter is rejected "Non positive jitter"

Gate:

Codel:
  - setting negative target, interval or ce_threshold gives huge value
    4.29e+03s
Pi:
  - setting negative target gets absolute value
Hhf:
  - setting negative value gets 4.29e+03s

So I can't see any valid use for negative intervals