Page MenuHomeFreeBSD

D19118.id53775.diff
No OneTemporary

D19118.id53775.diff

Index: sys/netinet/cc/cc_cubic.h
===================================================================
--- sys/netinet/cc/cc_cubic.h
+++ sys/netinet/cc/cc_cubic.h
@@ -41,6 +41,8 @@
#ifndef _NETINET_CC_CUBIC_H_
#define _NETINET_CC_CUBIC_H_
+#include <sys/limits.h>
+
/* Number of bits of precision for fixed point math calcs. */
#define CUBIC_SHIFT 8
@@ -172,7 +174,17 @@
/* K is in fixed point form with CUBIC_SHIFT worth of precision. */
/* t - K, with CUBIC_SHIFT worth of precision. */
- cwnd = ((int64_t)(ticks_since_cong << CUBIC_SHIFT) - (K * hz)) / hz;
+ cwnd = (((int64_t)ticks_since_cong << CUBIC_SHIFT) - (K * hz)) / hz;
+
+ /*
+ * (2^21)^3 is long max. Dividing (2^63) by Cubic_C_factor
+ * and taking cube-root yields 448845 as the effective useful limit
+ */
+
+ if (cwnd > 448845)
+ return INT_MAX;
+ if (cwnd < -448845)
+ return 0;
/* (t - K)^3, with CUBIC_SHIFT^3 worth of precision. */
cwnd *= (cwnd * cwnd);
@@ -183,9 +195,13 @@
* CUBIC_SHIFT included in the value. 3 from the cubing of cwnd above,
* and an extra from multiplying through by CUBIC_C_FACTOR.
*/
- cwnd = ((cwnd * CUBIC_C_FACTOR * smss) >> CUBIC_SHIFT_4) + wmax;
- return ((unsigned long)cwnd);
+ cwnd = ((cwnd * CUBIC_C_FACTOR) >> CUBIC_SHIFT_4) * smss + wmax;
+
+ /*
+ * for negative cwnd, limiting to zero as lower bound
+ */
+ return (lmax(0,cwnd));
}
/*
@@ -223,8 +239,10 @@
{
/* Equation 4 of I-D. */
- return (((wmax * CUBIC_BETA) + (((THREE_X_PT3 * ticks_since_cong *
- smss) << CUBIC_SHIFT) / TWO_SUB_PT3 / rtt_ticks)) >> CUBIC_SHIFT);
+ return (((wmax * CUBIC_BETA) +
+ (((THREE_X_PT3 * (unsigned long)ticks_since_cong *
+ (unsigned long)smss) << CUBIC_SHIFT) / (TWO_SUB_PT3 * rtt_ticks)))
+ >> CUBIC_SHIFT);
}
#endif /* _NETINET_CC_CUBIC_H_ */
Index: sys/netinet/cc/cc_cubic.c
===================================================================
--- sys/netinet/cc/cc_cubic.c
+++ sys/netinet/cc/cc_cubic.c
@@ -52,6 +52,7 @@
#include <sys/param.h>
#include <sys/kernel.h>
+#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/socket.h>
@@ -138,7 +139,14 @@
cubic_data->min_rtt_ticks == TCPTV_SRTTBASE)
newreno_cc_algo.ack_received(ccv, type);
else {
- ticks_since_cong = ticks - cubic_data->t_last_cong;
+ if ((ticks_since_cong =
+ ticks - cubic_data->t_last_cong) < 0) {
+ /*
+ * dragging t_last_cong along
+ */
+ ticks_since_cong = INT_MAX;
+ cubic_data->t_last_cong = ticks - INT_MAX;
+ }
/*
* The mean RTT is used to best reflect the equations in
@@ -157,12 +165,14 @@
ccv->flags &= ~CCF_ABC_SENTAWND;
- if (w_cubic_next < w_tf)
+ if (w_cubic_next < w_tf) {
/*
* TCP-friendly region, follow tf
* cwnd growth.
*/
- CCV(ccv, snd_cwnd) = w_tf;
+ if (CCV(ccv, snd_cwnd) < w_tf)
+ CCV(ccv, snd_cwnd) = ulmin(w_tf, INT_MAX);
+ }
else if (CCV(ccv, snd_cwnd) < w_cubic_next) {
/*
@@ -170,12 +180,14 @@
* cwnd growth.
*/
if (V_tcp_do_rfc3465)
- CCV(ccv, snd_cwnd) = w_cubic_next;
+ CCV(ccv, snd_cwnd) = ulmin(w_cubic_next,
+ INT_MAX);
else
- CCV(ccv, snd_cwnd) += ((w_cubic_next -
+ CCV(ccv, snd_cwnd) += ulmax(1,
+ ((ulmin(w_cubic_next, INT_MAX) -
CCV(ccv, snd_cwnd)) *
CCV(ccv, t_maxseg)) /
- CCV(ccv, snd_cwnd);
+ CCV(ccv, snd_cwnd));
}
/*

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 2, 10:14 AM (10 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30705020
Default Alt Text
D19118.id53775.diff (3 KB)

Event Timeline