aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/cc/cc_chd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet/cc/cc_chd.c')
-rw-r--r--sys/netinet/cc/cc_chd.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/sys/netinet/cc/cc_chd.c b/sys/netinet/cc/cc_chd.c
index 52048a7c05ae..1d440f43578f 100644
--- a/sys/netinet/cc/cc_chd.c
+++ b/sys/netinet/cc/cc_chd.c
@@ -58,6 +58,7 @@
#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/module.h>
+#include <sys/prng.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
@@ -85,8 +86,8 @@
*/
#define CC_CHD_DELAY 0x02000000
-/* Largest possible number returned by random(). */
-#define RANDOM_MAX INT_MAX
+/* Largest possible number returned by prng32(). */
+#define RANDOM_MAX UINT32_MAX
static void chd_ack_received(struct cc_var *ccv, ccsignal_t ack_type);
static void chd_cb_destroy(struct cc_var *ccv);
@@ -146,10 +147,11 @@ static __inline void
chd_window_decrease(struct cc_var *ccv)
{
unsigned long win;
+ uint32_t mss = tcp_fixed_maxseg(ccv->tp);
- win = min(CCV(ccv, snd_wnd), CCV(ccv, snd_cwnd)) / CCV(ccv, t_maxseg);
+ win = min(CCV(ccv, snd_wnd), CCV(ccv, snd_cwnd)) / mss;
win -= max((win / 2), 1);
- CCV(ccv, snd_ssthresh) = max(win, 2) * CCV(ccv, t_maxseg);
+ CCV(ccv, snd_ssthresh) = max(win, 2) * mss;
}
/*
@@ -159,9 +161,9 @@ chd_window_decrease(struct cc_var *ccv)
static __inline int
should_backoff(int qdly, int maxqdly, struct chd *chd_data)
{
- unsigned long p, rand;
+ uint32_t rand, p;
- rand = random();
+ rand = prng32();
if (qdly < V_chd_qthresh) {
chd_data->loss_compete = 0;
@@ -189,6 +191,7 @@ chd_window_increase(struct cc_var *ccv, int new_measurement)
{
struct chd *chd_data;
int incr;
+ uint32_t mss = tcp_fixed_maxseg(ccv->tp);
chd_data = ccv->cc_data;
incr = 0;
@@ -200,23 +203,22 @@ chd_window_increase(struct cc_var *ccv, int new_measurement)
if (CCV(ccv, snd_nxt) == CCV(ccv, snd_max)) {
/* Not due to RTO. */
incr = min(ccv->bytes_this_ack,
- V_tcp_abc_l_var * CCV(ccv, t_maxseg));
+ V_tcp_abc_l_var * mss);
} else {
/* Due to RTO. */
- incr = min(ccv->bytes_this_ack,
- CCV(ccv, t_maxseg));
+ incr = min(ccv->bytes_this_ack, mss);
}
} else
- incr = CCV(ccv, t_maxseg);
+ incr = mss;
} else { /* Congestion avoidance. */
if (V_tcp_do_rfc3465) {
if (ccv->flags & CCF_ABC_SENTAWND) {
ccv->flags &= ~CCF_ABC_SENTAWND;
- incr = CCV(ccv, t_maxseg);
+ incr = mss;
}
} else if (new_measurement)
- incr = CCV(ccv, t_maxseg);
+ incr = mss;
}
if (chd_data->shadow_w > 0) {
@@ -321,7 +323,7 @@ chd_cb_init(struct cc_var *ccv, void *ptr)
{
struct chd *chd_data;
- INP_WLOCK_ASSERT(tptoinpcb(ccv->ccvc.tcp));
+ INP_WLOCK_ASSERT(tptoinpcb(ccv->tp));
if (ptr == NULL) {
chd_data = malloc(sizeof(struct chd), M_CC_MEM, M_NOWAIT);
if (chd_data == NULL)
@@ -379,8 +381,9 @@ chd_cong_signal(struct cc_var *ccv, ccsignal_t signal_type)
}
if (chd_data->shadow_w > 0) {
+ uint32_t mss = tcp_fixed_maxseg(ccv->tp);
chd_data->shadow_w = max(chd_data->shadow_w /
- CCV(ccv, t_maxseg) / 2, 2) * CCV(ccv, t_maxseg);
+ mss / 2, 2) * mss;
}
ENTER_FASTRECOVERY(CCV(ccv, t_flags));
break;