diff options
author | t00fcxen <t00fcxen@9df1edf5-d72c-5b5f-11c0-5f5209eb73f7> | 2015-03-10 20:10:45 +0000 |
---|---|---|
committer | t00fcxen <t00fcxen@9df1edf5-d72c-5b5f-11c0-5f5209eb73f7> | 2015-03-10 20:10:45 +0000 |
commit | 3eda0f2b0ba5392ac3b53c91b50a3655208f3a21 (patch) | |
tree | 3c08826eb02c538dd7a0f48d143f960336697278 /usrsctplib/netinet/sctp_cc_functions.c | |
parent | addfd017b1b12349efd7c1fc44d963544e5420e8 (diff) | |
download | usrsctp-3eda0f2b0ba5392ac3b53c91b50a3655208f3a21.tar.gz |
Sync with Yosemite sources.
Diffstat (limited to 'usrsctplib/netinet/sctp_cc_functions.c')
-rwxr-xr-x | usrsctplib/netinet/sctp_cc_functions.c | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/usrsctplib/netinet/sctp_cc_functions.c b/usrsctplib/netinet/sctp_cc_functions.c index 3027e46f..0e01c986 100755 --- a/usrsctplib/netinet/sctp_cc_functions.c +++ b/usrsctplib/netinet/sctp_cc_functions.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 271672 2014-09-16 13:48:46Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 279859 2015-03-10 19:49:25Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -57,6 +57,19 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 271672 2014-09-16 13:48 #define SHIFT_MPTCP_MULTI 8 static void +sctp_enforce_cwnd_limit(struct sctp_association *assoc, struct sctp_nets *net) +{ + if ((assoc->max_cwnd > 0) && + (net->cwnd > assoc->max_cwnd) && + (net->cwnd > (net->mtu - sizeof(struct sctphdr)))) { + net->cwnd = assoc->max_cwnd ; + if (net->cwnd < (net->mtu - sizeof(struct sctphdr))) { + net->cwnd = net->mtu - sizeof(struct sctphdr); + } + } +} + +static void sctp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net) { struct sctp_association *assoc; @@ -84,6 +97,7 @@ sctp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net) net->cwnd = net->mtu - sizeof(struct sctphdr); } } + sctp_enforce_cwnd_limit(assoc, net); net->ssthresh = assoc->peers_rwnd; #if defined(__FreeBSD__) && __FreeBSD_version >= 803000 SDT_PROBE(sctp, cwnd, net, init, @@ -179,6 +193,7 @@ sctp_cwnd_update_after_fr(struct sctp_tcb *stcb, } } net->cwnd = net->ssthresh; + sctp_enforce_cwnd_limit(asoc, net); #if defined(__FreeBSD__) && __FreeBSD_version >= 803000 SDT_PROBE(sctp, cwnd, net, fr, stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net, @@ -300,7 +315,7 @@ cc_bw_same(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_t nb } return (1); } - if (net->rtt < net->cc_mod.rtcc.lbw_rtt-rtt_offset) { + if (net->rtt < net->cc_mod.rtcc.lbw_rtt-rtt_offset) { /* * rtt decreased, there could be more room. * we update both the bw and the rtt here to @@ -461,6 +476,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ if ((net->cc_mod.rtcc.vol_reduce) && (inst_ind != SCTP_INST_GAINING)) { net->cwnd += net->mtu; + sctp_enforce_cwnd_limit(&stcb->asoc, net); net->cc_mod.rtcc.vol_reduce--; } net->cc_mod.rtcc.last_step_state = 2; @@ -496,6 +512,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ if ((net->cc_mod.rtcc.vol_reduce) && (inst_ind != SCTP_INST_GAINING)) { net->cwnd += net->mtu; + sctp_enforce_cwnd_limit(&stcb->asoc, net); net->cc_mod.rtcc.vol_reduce--; } net->cc_mod.rtcc.last_step_state = 3; @@ -531,6 +548,7 @@ cc_bw_decrease(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_nets *net, uint64_ if ((net->cc_mod.rtcc.vol_reduce) && (inst_ind != SCTP_INST_GAINING)) { net->cwnd += net->mtu; + sctp_enforce_cwnd_limit(&stcb->asoc, net); net->cc_mod.rtcc.vol_reduce--; } net->cc_mod.rtcc.last_step_state = 4; @@ -961,6 +979,7 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, break; } net->cwnd += incr; + sctp_enforce_cwnd_limit(asoc, net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, incr, SCTP_CWND_LOG_FROM_SS); @@ -1028,6 +1047,7 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb, break; } net->cwnd += incr; + sctp_enforce_cwnd_limit(asoc, net); #if defined(__FreeBSD__) && __FreeBSD_version >= 803000 SDT_PROBE(sctp, cwnd, net, ack, stcb->asoc.my_vtag, @@ -1315,7 +1335,7 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb, /* We always have 1 MTU */ net->cwnd = net->mtu; } - + sctp_enforce_cwnd_limit(&stcb->asoc, net); if (net->cwnd - old_cwnd != 0) { /* log only changes */ #if defined(__FreeBSD__) && __FreeBSD_version >= 803000 @@ -1342,6 +1362,7 @@ sctp_cwnd_update_after_output(struct sctp_tcb *stcb, net->ssthresh = net->cwnd; if (burst_limit) { net->cwnd = (net->flight_size + (burst_limit * net->mtu)); + sctp_enforce_cwnd_limit(&stcb->asoc, net); #if defined(__FreeBSD__) && __FreeBSD_version >= 803000 SDT_PROBE(sctp, cwnd, net, bl, stcb->asoc.my_vtag, @@ -1681,6 +1702,7 @@ static void sctp_hs_cwnd_increase(struct sctp_tcb *stcb, struct sctp_nets *net) { int cur_val, i, indx, incr; + int old_cwnd = net->cwnd; cur_val = net->cwnd >> 10; indx = SCTP_HS_TABLE_SIZE - 1; @@ -1689,14 +1711,8 @@ sctp_hs_cwnd_increase(struct sctp_tcb *stcb, struct sctp_nets *net) /* normal mode */ if (net->net_ack > net->mtu) { net->cwnd += net->mtu; - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { - sctp_log_cwnd(stcb, net, net->mtu, SCTP_CWND_LOG_FROM_SS); - } } else { net->cwnd += net->net_ack; - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { - sctp_log_cwnd(stcb, net, net->net_ack, SCTP_CWND_LOG_FROM_SS); - } } } else { for (i = net->last_hs_used; i < SCTP_HS_TABLE_SIZE; i++) { @@ -1708,9 +1724,10 @@ sctp_hs_cwnd_increase(struct sctp_tcb *stcb, struct sctp_nets *net) net->last_hs_used = indx; incr = ((sctp_cwnd_adjust[indx].increase) << 10); net->cwnd += incr; - if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { - sctp_log_cwnd(stcb, net, incr, SCTP_CWND_LOG_FROM_SS); - } + } + sctp_enforce_cwnd_limit(&stcb->asoc, net); + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { + sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SS); } } @@ -1749,6 +1766,7 @@ sctp_hs_cwnd_decrease(struct sctp_tcb *stcb, struct sctp_nets *net) net->last_hs_used = indx; } } + sctp_enforce_cwnd_limit(&stcb->asoc, net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_FR); } @@ -1877,9 +1895,7 @@ sctp_hs_cwnd_update_after_sack(struct sctp_tcb *stcb, if (net->cwnd <= net->ssthresh) { /* We are in slow start */ if (net->flight_size + net->net_ack >= net->cwnd) { - sctp_hs_cwnd_increase(stcb, net); - } else { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_LOGGING_ENABLE) { sctp_log_cwnd(stcb, net, net->net_ack, @@ -1893,6 +1909,7 @@ sctp_hs_cwnd_update_after_sack(struct sctp_tcb *stcb, (net->partial_bytes_acked >= net->cwnd)) { net->partial_bytes_acked -= net->cwnd; net->cwnd += net->mtu; + sctp_enforce_cwnd_limit(asoc, net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, net->mtu, SCTP_CWND_LOG_FROM_CA); @@ -2131,6 +2148,7 @@ htcp_cong_avoid(struct sctp_tcb *stcb, struct sctp_nets *net) } } + sctp_enforce_cwnd_limit(&stcb->asoc, net); } else { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_LOGGING_ENABLE) { sctp_log_cwnd(stcb, net, net->net_ack, @@ -2151,6 +2169,7 @@ htcp_cong_avoid(struct sctp_tcb *stcb, struct sctp_nets *net) */ net->cwnd += net->mtu; net->partial_bytes_acked = 0; + sctp_enforce_cwnd_limit(&stcb->asoc, net); htcp_alpha_update(&net->cc_mod.htcp_ca); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, net->mtu, @@ -2196,6 +2215,7 @@ sctp_htcp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net) */ net->cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND)); net->ssthresh = stcb->asoc.peers_rwnd; + sctp_enforce_cwnd_limit(&stcb->asoc, net); htcp_init(net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & (SCTP_CWND_MONITOR_ENABLE|SCTP_CWND_LOGGING_ENABLE)) { @@ -2275,7 +2295,7 @@ sctp_htcp_cwnd_update_after_fr(struct sctp_tcb *stcb, struct sctp_association *asoc) { struct sctp_nets *net; - /* + /* * CMT fast recovery code. Need to debug. ((sctp_cmt_on_off > 0) && * (net->fast_retran_loss_recovery == 0))) */ @@ -2297,6 +2317,7 @@ sctp_htcp_cwnd_update_after_fr(struct sctp_tcb *stcb, htcp_reset(&net->cc_mod.htcp_ca); net->ssthresh = htcp_recalc_ssthresh(net); net->cwnd = net->ssthresh; + sctp_enforce_cwnd_limit(asoc, net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_FR); @@ -2375,6 +2396,7 @@ sctp_htcp_cwnd_update_after_ecn_echo(struct sctp_tcb *stcb, net->RTO <<= 1; } net->cwnd = net->ssthresh; + sctp_enforce_cwnd_limit(&stcb->asoc, net); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) { sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT); } |