]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r318511
authortruckman <truckman@FreeBSD.org>
Thu, 25 May 2017 17:22:13 +0000 (17:22 +0000)
committertruckman <truckman@FreeBSD.org>
Thu, 25 May 2017 17:22:13 +0000 (17:22 +0000)
commit61ad262512e302f69f713f8f13a6fff42dd917c7
treea1712e6200cd6b3ed9949882eb7d40e00eb6bfab
parentea8decded162c663e1a10d48adb2bf74c2f6c811
MFC r318511

The result of right shifting a negative signed value is implementation
defined.  On machines without arithmetic shift instructions, zero bits
may be shifted in from the left, giving a large positive result instead
of the desired divide-by power-of-2.  Fix this by operating on the
absolute value and compensating for the possible negation later.

Reverse the order of the underflow/overflow tests and the exponential
decay calculation to avoid the possibility of an erroneous overflow
detection if p is a sufficiently small non-negative value.  Also
check for negative values of prob before doing the exponential decay
to avoid another instance of of right shifting a negative value.

Tested by: Rasool Al-Saadi <ralsaadi@swin.edu.au>
sys/netpfil/ipfw/dn_aqm_pie.c
sys/netpfil/ipfw/dn_sched_fq_pie.c