diff options
author | luigi <luigi@FreeBSD.org> | 2016-01-26 04:48:24 +0000 |
---|---|---|
committer | luigi <luigi@FreeBSD.org> | 2016-01-26 04:48:24 +0000 |
commit | 4b163c84bbc04f86dc4508a28e7e8d445be94413 (patch) | |
tree | 6c975a7d1c35a9cb75ab18af4a4b7e47d9ac77f0 /sys/netpfil | |
parent | 01e9d5450a8debe8d97b27d46f74625257226a5d (diff) | |
download | FreeBSD-src-4b163c84bbc04f86dc4508a28e7e8d445be94413.zip FreeBSD-src-4b163c84bbc04f86dc4508a28e7e8d445be94413.tar.gz |
Revert one chunk from commit 285362, which introduced an off-by-one error
in computing a shift index. The error was due to the use of mixed
fls() / __fls() functions in another implementation of qfq.
To avoid that the problem occurs again, properly document which
incarnation of the function we need.
Note that the bug only affects QFQ in FreeBSD head from last july, as
the patch was not merged to other versions.
Diffstat (limited to 'sys/netpfil')
-rw-r--r-- | sys/netpfil/ipfw/dn_sched_qfq.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/netpfil/ipfw/dn_sched_qfq.c b/sys/netpfil/ipfw/dn_sched_qfq.c index ea27b3e..b5f4bba 100644 --- a/sys/netpfil/ipfw/dn_sched_qfq.c +++ b/sys/netpfil/ipfw/dn_sched_qfq.c @@ -60,6 +60,10 @@ typedef unsigned long bitmap; /* * bitmaps ops are critical. Some linux versions have __fls * and the bitmap ops. Some machines have ffs + * NOTE: fls() returns 1 for the least significant bit, + * __fls() returns 0 for the same case. + * We use the base-0 version __fls() to match the description in + * the ToN QFQ paper */ #if defined(_WIN32) || (defined(__MIPSEL__) && defined(LINUX_24)) int fls(unsigned int n) @@ -409,8 +413,8 @@ qfq_make_eligible(struct qfq_sched *q, uint64_t old_V) old_vslot = old_V >> QFQ_MIN_SLOT_SHIFT; if (vslot != old_vslot) { - /* should be 1ULL not 2ULL */ - mask = (1ULL << (__fls(vslot ^ old_vslot))) - 1; + /* must be 2ULL, see ToN QFQ article fig.5, we use base-0 fls */ + mask = (2ULL << (__fls(vslot ^ old_vslot))) - 1; qfq_move_groups(q, mask, IR, ER); qfq_move_groups(q, mask, IB, EB); } |