tcp: window update ack 03/20303/3
authorVladimir Kropylev <vladimir.kropylev@enea.com>
Mon, 24 Jun 2019 21:06:52 +0000 (00:06 +0300)
committerFlorin Coras <florin.coras@gmail.com>
Tue, 25 Jun 2019 21:51:42 +0000 (21:51 +0000)
Type: feature

Provide interface for sending Window Update ACK,
ensuring it will be sent only once, if RWND became non-zero,
after zero RWND has been advertised before.

Change-Id: I7f0d8af76d7763208625df68ab4ac3727fdaf449
Signed-off-by: Vladimir Kropylev <vladimir.kropylev@enea.com>
src/vnet/tcp/tcp.h
src/vnet/tcp/tcp_output.c

index b0c3ecc..e4980dd 100644 (file)
@@ -130,6 +130,7 @@ extern timer_expiration_handler tcp_timer_retransmit_syn_handler;
   _(FINRCVD, "FIN received")                   \
   _(RATE_SAMPLE, "Conn does rate sampling")    \
   _(TRACK_BURST, "Track burst")                        \
+  _(ZERO_RWND_SENT, "Zero RWND sent")          \
 
 typedef enum _tcp_connection_flag_bits
 {
@@ -412,6 +413,10 @@ tcp_cong_recovery_off (tcp_connection_t * tc)
   tcp_fastrecovery_first_off (tc);
 }
 
+#define tcp_zero_rwnd_sent(tc) (tc)->flags &= TCP_CONN_ZERO_RWND_SENT
+#define tcp_zero_rwnd_sent_on(tc) (tc)->flags |= TCP_CONN_ZERO_RWND_SENT
+#define tcp_zero_rwnd_sent_off(tc) (tc)->flags &= ~TCP_CONN_ZERO_RWND_SENT
+
 typedef enum _tcp_error
 {
 #define tcp_error(n,s) TCP_ERROR_##n,
@@ -682,6 +687,7 @@ void tcp_do_fastretransmits (tcp_worker_ctx_t * wrk);
 void tcp_program_ack (tcp_worker_ctx_t * wrk, tcp_connection_t * tc);
 void tcp_program_dupack (tcp_worker_ctx_t * wrk, tcp_connection_t * tc);
 void tcp_send_acks (tcp_worker_ctx_t * wrk);
+void tcp_send_window_update_ack (tcp_connection_t * tc);
 
 /*
  * Rate estimation
index d3c4ca4..7cf85c3 100644 (file)
@@ -505,6 +505,11 @@ tcp_make_ack_i (tcp_connection_t * tc, vlib_buffer_t * b, tcp_state_t state,
 
   tcp_options_write ((u8 *) (th + 1), snd_opts);
   vnet_buffer (b)->tcp.connection_index = tc->c_c_index;
+
+  if (wnd == 0)
+    tcp_zero_rwnd_sent_on (tc);
+  else
+    tcp_zero_rwnd_sent_off (tc);
 }
 
 /**
@@ -1265,6 +1270,28 @@ tcp_timer_delack_handler (u32 index)
   tcp_send_ack (tc);
 }
 
+/**
+ * Send Window Update ACK,
+ * ensuring that it will be sent once, if RWND became non-zero,
+ * after zero RWND has been advertised in ACK before
+ */
+void
+tcp_send_window_update_ack (tcp_connection_t * tc)
+{
+  tcp_worker_ctx_t *wrk = tcp_get_worker (tc->c_thread_index);
+  u32 win;
+
+  if (tcp_zero_rwnd_sent (tc))
+    {
+      win = tcp_window_to_advertise (tc, tc->state);
+      if (win > 0)
+       {
+         tcp_zero_rwnd_sent_off (tc);
+         tcp_program_ack (wrk, tc);
+       }
+    }
+}
+
 /**
  * Allocate a new buffer and build a new tcp segment
  *