X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ftcp%2Ftcp_input.c;h=a86161c6d34db3044e53a99ed5d038aee721d238;hb=67fe778546683d678015cc0089bbe475cb6a6f22;hp=519219e2c745ca41503401d9c39ba54d90ba33a4;hpb=f9512bff1c241a876cc882ad654e75740497c46f;p=vpp.git diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c index 519219e2c74..a86161c6d34 100644 --- a/src/vnet/tcp/tcp_input.c +++ b/src/vnet/tcp/tcp_input.c @@ -164,7 +164,7 @@ tcp_handle_rst (tcp_connection_t * tc) tcp_connection_cleanup (tc); break; case TCP_STATE_SYN_SENT: - session_stream_connect_notify (&tc->connection, 1 /* fail */ ); + session_stream_connect_notify (&tc->connection, SESSION_E_REFUSED); tcp_connection_cleanup (tc); break; case TCP_STATE_ESTABLISHED: @@ -424,31 +424,26 @@ acceptable: /** * Compute smoothed RTT as per VJ's '88 SIGCOMM and RFC6298 * - * Note that although the original article, srtt and rttvar are scaled + * Note that although in the original article srtt and rttvar are scaled * to minimize round-off errors, here we don't. Instead, we rely on * better precision time measurements. + * + * A known limitation of the algorithm is that a drop in rtt results in a + * rttvar increase and bigger RTO. + * + * mrtt must be provided in @ref TCP_TICK multiples, i.e., in us. Note that + * timestamps are measured as ms ticks so they must be converted before + * calling this function. */ static void tcp_estimate_rtt (tcp_connection_t * tc, u32 mrtt) { int err, diff; - if (tc->srtt != 0) - { - err = mrtt - tc->srtt; - - /* XXX Drop in RTT results in RTTVAR increase and bigger RTO. - * The increase should be bound */ - tc->srtt = clib_max ((int) tc->srtt + (err >> 3), 1); - diff = (clib_abs (err) - (int) tc->rttvar) >> 2; - tc->rttvar = clib_max ((int) tc->rttvar + diff, 1); - } - else - { - /* First measurement. */ - tc->srtt = mrtt; - tc->rttvar = mrtt >> 1; - } + err = mrtt - tc->srtt; + tc->srtt = clib_max ((int) tc->srtt + (err >> 3), 1); + diff = (clib_abs (err) - (int) tc->rttvar) >> 2; + tc->rttvar = clib_max ((int) tc->rttvar + diff, 1); } static inline void @@ -506,8 +501,8 @@ tcp_update_rtt (tcp_connection_t * tc, tcp_rate_sample_t * rs, u32 ack) * seq_lt (tc->snd_una, ack). This is a condition for calling update_rtt */ else if (tcp_opts_tstamp (&tc->rcv_opts) && tc->rcv_opts.tsecr) { - u32 now = tcp_tstamp (tc); - mrtt = clib_max (now - tc->rcv_opts.tsecr, 1); + mrtt = clib_max (tcp_tstamp (tc) - tc->rcv_opts.tsecr, 1); + mrtt *= TCP_TSTP_TO_HZ; } estimate_rtt: @@ -543,8 +538,8 @@ tcp_estimate_initial_rtt (tcp_connection_t * tc) } else { - mrtt = tcp_time_now_w_thread (thread_index) - tc->rcv_opts.tsecr; - mrtt = clib_max (mrtt, 1); + mrtt = tcp_tstamp (tc) - tc->rcv_opts.tsecr; + mrtt = clib_max (mrtt, 1) * TCP_TSTP_TO_HZ; /* Due to retransmits we don't know the initial mrtt */ if (tc->rto_boff && mrtt > 1 * THZ) mrtt = 1 * THZ; @@ -552,7 +547,11 @@ tcp_estimate_initial_rtt (tcp_connection_t * tc) } if (mrtt > 0 && mrtt < TCP_RTT_MAX) - tcp_estimate_rtt (tc, mrtt); + { + /* First measurement as per RFC 6298 */ + tc->srtt = mrtt; + tc->rttvar = mrtt >> 1; + } tcp_update_rto (tc); } @@ -690,7 +689,7 @@ tcp_cc_init_congestion (tcp_connection_t * tc) * three segments that have left the network and should've been * buffered at the receiver XXX */ if (!tcp_opts_sack_permitted (&tc->rcv_opts)) - tc->cwnd += 3 * tc->snd_mss; + tc->cwnd += TCP_DUPACK_THRESHOLD * tc->snd_mss; tc->fr_occurences += 1; TCP_EVT (TCP_EVT_CC_EVT, tc, 4); @@ -721,14 +720,6 @@ tcp_cc_is_spurious_retransmit (tcp_connection_t * tc) return (tcp_cc_is_spurious_timeout_rxt (tc)); } -static inline u8 -tcp_should_fastrecover_sack (tcp_connection_t * tc) -{ - return (tc->sack_sb.lost_bytes - || ((TCP_DUPACK_THRESHOLD - 1) * tc->snd_mss - < tc->sack_sb.sacked_bytes)); -} - static inline u8 tcp_should_fastrecover (tcp_connection_t * tc, u8 has_sack) { @@ -753,8 +744,7 @@ tcp_should_fastrecover (tcp_connection_t * tc, u8 has_sack) return 0; } } - return ((tc->rcv_dupacks == TCP_DUPACK_THRESHOLD) - || tcp_should_fastrecover_sack (tc)); + return tc->sack_sb.lost_bytes || tc->rcv_dupacks >= tc->sack_sb.reorder; } static int