diff options
author | Florin Coras <fcoras@cisco.com> | 2019-10-16 19:28:17 -0700 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2019-11-05 10:23:52 +0000 |
commit | 3d30598b7b4dd6d7dbffc883a96692e90e4320f5 (patch) | |
tree | 62fb869363ce6230cfe1ec12d24f0fd5cb106af3 /src | |
parent | efb8db4c8a59ad5c9b66cad6f8b9c7862e3001aa (diff) |
tcp: avoid sending acks when data available
Type: fix
Change-Id: I02e2cb2d349f9ddb2bfed040a08ca448f379d565
Signed-off-by: Florin Coras <fcoras@cisco.com>
(cherry picked from commit cb711a4ec908b89edc9da29d3c2e093dab85fbbf)
Diffstat (limited to 'src')
-rw-r--r-- | src/vnet/tcp/tcp.h | 1 | ||||
-rwxr-xr-x | src/vnet/tcp/tcp_input.c | 5 | ||||
-rw-r--r-- | src/vnet/tcp/tcp_output.c | 23 |
3 files changed, 24 insertions, 5 deletions
diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h index 8636a7c85db..657f1bea449 100644 --- a/src/vnet/tcp/tcp.h +++ b/src/vnet/tcp/tcp.h @@ -786,6 +786,7 @@ void tcp_send_reset (tcp_connection_t * tc); void tcp_send_syn (tcp_connection_t * tc); void tcp_send_synack (tcp_connection_t * tc); void tcp_send_fin (tcp_connection_t * tc); +void tcp_send_ack (tcp_connection_t * tc); void tcp_update_burst_snd_vars (tcp_connection_t * tc); void tcp_update_rto (tcp_connection_t * tc); void tcp_flush_frame_to_output (tcp_worker_ctx_t * wrk, u8 is_ip4); diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c index de59a4da0af..83769465525 100755 --- a/src/vnet/tcp/tcp_input.c +++ b/src/vnet/tcp/tcp_input.c @@ -1687,6 +1687,7 @@ tcp_rcv_fin (tcp_worker_ctx_t * wrk, tcp_connection_t * tc, vlib_buffer_t * b, /* Account for the FIN and send ack */ tc->rcv_nxt += 1; + tc->flags |= TCP_CONN_FINRCVD; tcp_program_ack (tc); /* Enter CLOSE-WAIT and notify session. To avoid lingering * in CLOSE-WAIT, set timer (reuse WAITCLOSE). */ @@ -2599,7 +2600,9 @@ tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node, } else { - tcp_program_ack (new_tc0); + /* Send ack now instead of programming it because connection was + * just established and it's not optional. */ + tcp_send_ack (new_tc0); } drop: diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c index 33bfe100a10..2437b7bf28f 100644 --- a/src/vnet/tcp/tcp_output.c +++ b/src/vnet/tcp/tcp_output.c @@ -518,7 +518,6 @@ tcp_compute_checksum (tcp_connection_t * tc, vlib_buffer_t * b) return checksum; } - /** * Prepare ACK */ @@ -1086,6 +1085,10 @@ tcp_send_fin (tcp_connection_t * tc) return; } + /* If we have non-dupacks programmed, no need to send them */ + if ((tc->flags & TCP_CONN_SNDACK) && !tc->pending_dupacks) + tc->flags &= ~TCP_CONN_SNDACK; + tcp_retransmit_timer_force_update (tc); b = vlib_get_buffer (vm, bi); tcp_init_buffer (vm, b); @@ -1165,7 +1168,6 @@ tcp_push_hdr_i (tcp_connection_t * tc, vlib_buffer_t * b, u32 snd_nxt, tc->bytes_out += data_len; tc->data_segs_out += 1; - th->checksum = tcp_compute_checksum (tc, b); TCP_EVT (TCP_EVT_PKTIZE, tc); @@ -1897,6 +1899,13 @@ tcp_retransmit_should_retry_head (tcp_connection_t * tc, return (tx_adv_sack > (tc->snd_una - tc->prr_start) * rr); } +static inline u8 +tcp_max_tx_deq (tcp_connection_t * tc) +{ + return (transport_max_tx_dequeue (&tc->connection) + - (tc->snd_nxt - tc->snd_una)); +} + #define scoreboard_rescue_rxt_valid(_sb, _tc) \ (seq_geq (_sb->rescue_rxt, _tc->snd_una) \ && seq_leq (_sb->rescue_rxt, _tc->snd_congestion)) @@ -2161,8 +2170,13 @@ tcp_send_acks (tcp_connection_t * tc, u32 max_burst_size) if (!tc->pending_dupacks) { - tcp_send_ack (tc); - return 1; + if (tcp_in_cong_recovery (tc) || !tcp_max_tx_deq (tc) + || tc->state != TCP_STATE_ESTABLISHED) + { + tcp_send_ack (tc); + return 1; + } + return 0; } /* If we're supposed to send dupacks but have no ooo data @@ -2170,6 +2184,7 @@ tcp_send_acks (tcp_connection_t * tc, u32 max_burst_size) if (!vec_len (tc->snd_sacks)) { tcp_send_ack (tc); + tc->pending_dupacks = 0; return 1; } |