diff options
author | truckman <truckman@FreeBSD.org> | 2017-03-31 06:20:06 +0000 |
---|---|---|
committer | Luiz Souza <luiz@netgate.com> | 2017-07-15 11:14:23 -0500 |
commit | 847151a90c366430c1a9a2899ed1b4302ae5f613 (patch) | |
tree | 53f804320f4ac149691934a4686188c7e7e0e36d | |
parent | 8376e8e1d40440778d0bbc8389f521ff770db5f7 (diff) | |
download | FreeBSD-src-847151a90c366430c1a9a2899ed1b4302ae5f613.zip FreeBSD-src-847151a90c366430c1a9a2899ed1b4302ae5f613.tar.gz |
MFC r315516
Change several constants used by the PIE algorithm from unsigned to signed.
- PIE_MAX_PROB is compared to variable of int64_t and the type promotion
rules can cause the value of that variable to be treated as unsigned.
If the value is actually negative, then the result of the comparsion
is incorrect, causing the algorithm to perform poorly in some
situations. Changing the constant to be signed cause the comparision
to work correctly.
- PIE_SCALE is also compared to signed values. Fortunately they are
also compared to zero and negative values are discarded so this is
more of a cosmetic fix.
- PIE_DQ_THRESHOLD is only compared to unsigned values, but it is small
enough that the automatic promotion to unsigned is harmless.
Submitted by: Rasool Al-Saadi <ralsaadi@swin.edu.au>
(cherry picked from commit 2f199c035fbd9665f88076f9676e6b81d16376ef)
-rw-r--r-- | sys/netpfil/ipfw/dn_aqm_pie.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/netpfil/ipfw/dn_aqm_pie.h b/sys/netpfil/ipfw/dn_aqm_pie.h index aa2fceb..7512d32 100644 --- a/sys/netpfil/ipfw/dn_aqm_pie.h +++ b/sys/netpfil/ipfw/dn_aqm_pie.h @@ -37,16 +37,16 @@ #define DN_AQM_PIE 2 #define PIE_DQ_THRESHOLD_BITS 14 /* 2^14 =16KB */ -#define PIE_DQ_THRESHOLD (1UL << PIE_DQ_THRESHOLD_BITS) +#define PIE_DQ_THRESHOLD (1L << PIE_DQ_THRESHOLD_BITS) #define MEAN_PKTSIZE 800 /* 31-bits because random() generates range from 0->(2**31)-1 */ #define PIE_PROB_BITS 31 -#define PIE_MAX_PROB ((1ULL<<PIE_PROB_BITS) -1) +#define PIE_MAX_PROB ((1LL<<PIE_PROB_BITS) -1) /* for 16-bits, we have 3-bits for integer part and 13-bits for fraction */ #define PIE_FIX_POINT_BITS 13 -#define PIE_SCALE (1UL<<PIE_FIX_POINT_BITS) +#define PIE_SCALE (1L<<PIE_FIX_POINT_BITS) /* PIE options */ |