tcp: keep snd sack block free list
[vpp.git] / src / vnet / tcp / tcp_input.c
index 3d8ae89..df8f53d 100644 (file)
@@ -564,7 +564,7 @@ tcp_handle_postponed_dequeues (tcp_worker_ctx_t * wrk)
        continue;
 
       /* Dequeue the newly ACKed bytes */
-      stream_session_dequeue_drop (&tc->connection, tc->burst_acked);
+      session_dequeue_drop (&tc->connection, tc->burst_acked);
       tc->burst_acked = 0;
       tcp_validate_txf_size (tc, tc->snd_una_max - tc->snd_una);
 
@@ -1714,7 +1714,7 @@ tcp_sack_vector_is_sane (sack_block_t * sacks)
 void
 tcp_update_sack_list (tcp_connection_t * tc, u32 start, u32 end)
 {
-  sack_block_t *new_list = 0, *block = 0;
+  sack_block_t *new_list = tc->snd_sacks_fl, *block = 0;
   int i;
 
   /* If the first segment is ooo add it to the list. Last write might've moved
@@ -1758,7 +1758,8 @@ tcp_update_sack_list (tcp_connection_t * tc, u32 start, u32 end)
   ASSERT (vec_len (new_list) <= TCP_MAX_SACK_BLOCKS);
 
   /* Replace old vector with new one */
-  vec_free (tc->snd_sacks);
+  vec_reset_length (tc->snd_sacks);
+  tc->snd_sacks_fl = tc->snd_sacks;
   tc->snd_sacks = new_list;
 
   /* Segments should not 'touch' */
@@ -2763,7 +2764,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
          /* Reset SYN-ACK retransmit and SYN_RCV establish timers */
          tcp_retransmit_timer_reset (tc0);
          tcp_timer_reset (tc0, TCP_TIMER_ESTABLISH);
-         if (stream_session_accept_notify (&tc0->connection))
+         if (session_stream_accept_notify (&tc0->connection))
            {
              error0 = TCP_ERROR_MSG_QUEUE_FULL;
              tcp_connection_reset (tc0);
@@ -2806,8 +2807,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
 
              /* Don't try to deq the FIN acked */
              if (tc0->burst_acked > 1)
-               stream_session_dequeue_drop (&tc0->connection,
-                                            tc0->burst_acked - 1);
+               session_dequeue_drop (&tc0->connection, tc0->burst_acked - 1);
              tc0->burst_acked = 0;
            }
          break;
@@ -2950,8 +2950,17 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
        case TCP_STATE_FIN_WAIT_1:
          tc0->rcv_nxt += 1;
          tcp_connection_set_state (tc0, TCP_STATE_CLOSING);
-         tcp_program_ack (wrk, tc0);
-         /* Wait for ACK but not forever */
+         if (tc0->flags & TCP_CONN_FINPNDG)
+           {
+             /* Drop all outstanding tx data. */
+             session_dequeue_drop (&tc0->connection,
+                                   transport_max_tx_dequeue
+                                   (&tc0->connection));
+             tcp_send_fin (tc0);
+           }
+         else
+           tcp_program_ack (wrk, tc0);
+         /* Wait for ACK for our FIN but not forever */
          tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME);
          break;
        case TCP_STATE_FIN_WAIT_2: