| 381 | } |
| 382 | |
| 383 | void |
| 384 | cc_conn_init(struct tcpcb *tp) |
| 385 | { |
| 386 | struct hc_metrics_lite metrics; |
| 387 | struct inpcb *inp = tp->t_inpcb; |
| 388 | u_int maxseg; |
| 389 | int rtt; |
| 390 | |
| 391 | INP_WLOCK_ASSERT(tp->t_inpcb); |
| 392 | |
| 393 | tcp_hc_get(&inp->inp_inc, &metrics); |
| 394 | maxseg = tcp_maxseg(tp); |
| 395 | |
| 396 | if (tp->t_srtt == 0 && (rtt = metrics.rmx_rtt)) { |
| 397 | tp->t_srtt = rtt; |
| 398 | tp->t_rttbest = tp->t_srtt + TCP_RTT_SCALE; |
| 399 | TCPSTAT_INC(tcps_usedrtt); |
| 400 | if (metrics.rmx_rttvar) { |
| 401 | tp->t_rttvar = metrics.rmx_rttvar; |
| 402 | TCPSTAT_INC(tcps_usedrttvar); |
| 403 | } else { |
| 404 | /* default variation is +- 1 rtt */ |
| 405 | tp->t_rttvar = |
| 406 | tp->t_srtt * TCP_RTTVAR_SCALE / TCP_RTT_SCALE; |
| 407 | } |
| 408 | TCPT_RANGESET(tp->t_rxtcur, |
| 409 | ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1, |
| 410 | tp->t_rttmin, TCPTV_REXMTMAX); |
| 411 | } |
| 412 | if (metrics.rmx_ssthresh) { |
| 413 | /* |
| 414 | * There's some sort of gateway or interface |
| 415 | * buffer limit on the path. Use this to set |
| 416 | * the slow start threshold, but set the |
| 417 | * threshold to no less than 2*mss. |
| 418 | */ |
| 419 | tp->snd_ssthresh = max(2 * maxseg, metrics.rmx_ssthresh); |
| 420 | TCPSTAT_INC(tcps_usedssthresh); |
| 421 | } |
| 422 | |
| 423 | /* |
| 424 | * Set the initial slow-start flight size. |
| 425 | * |
| 426 | * If a SYN or SYN/ACK was lost and retransmitted, we have to |
| 427 | * reduce the initial CWND to one segment as congestion is likely |
| 428 | * requiring us to be cautious. |
| 429 | */ |
| 430 | if (tp->snd_cwnd == 1) |
| 431 | tp->snd_cwnd = maxseg; /* SYN(-ACK) lost */ |
| 432 | else |
| 433 | tp->snd_cwnd = tcp_compute_initwnd(maxseg); |
| 434 | |
| 435 | if (CC_ALGO(tp)->conn_init != NULL) |
| 436 | CC_ALGO(tp)->conn_init(tp->ccv); |
| 437 | } |
| 438 | |
| 439 | void inline |
| 440 | cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type) |
no test coverage detected