Re: Divide error in minstrel_ht_get_tp_avg()

From: Willy Tarreau
Date: Sat Aug 21 2021 - 08:19:48 EST


On Sat, Aug 21, 2021 at 01:14:34PM +0200, Oleksandr Natalenko wrote:
> > > So, it seems `minstrel_ht_avg_ampdu_len()` can return 0, which is not
> > > really legitimate.
> > >
> > > Looking at `minstrel_ht_avg_ampdu_len()`, I see the following:
> > >
> > > ```
> > > 16:#define MINSTREL_SCALE 12
> > > ...
> > > 18:#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
> > > ```
> > >
> > > ```
> > >
> > > 401 static unsigned int
> > > 402 minstrel_ht_avg_ampdu_len(struct minstrel_ht_sta *mi)
> > > 403 {
> > >
> > > ...
> > >
> > > 406 if (mi->avg_ampdu_len)
> > > 407 return MINSTREL_TRUNC(mi->avg_ampdu_len);
> > >
> > > ```
> > >
> > > So, likely, `mi->avg_ampdu_len` is non-zero, but it's too small, hence
> > > right bitshift makes it zero.
(...)
> I've also found out that this happens exactly at midnight, IOW, at 00:00:00.
> Not every midnight, though.
>
> Does it have something to do with timekeeping? This is strange, I wouldn't
> expect kernel to act like that. Probably, some client sends malformed frame?
> How to find out?

Well, in minstrel_ht_update_stats() at line 1006 avg_ampdu_len is
explicitly set to zero. And this seems to be called based on timing
criteria from minstrel_ht_tx_status() so this could confirm your
experience. Thus there is some inconsistency there.

Willy