tcp: keep snd sack block free list 91/17791/3
authorFlorin Coras <fcoras@cisco.com>
Fri, 22 Feb 2019 17:07:20 +0000 (09:07 -0800)
committerDamjan Marion <dmarion@me.com>
Fri, 22 Feb 2019 20:45:19 +0000 (20:45 +0000)
Instead of constantly reallocating the new sack block list, keep the old
one as a reusable free list.

Change-Id: Iad79a72204f97b96352c1c6eea66c2839a35cfe6
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/tcp/tcp.c
src/vnet/tcp/tcp.h
src/vnet/tcp/tcp_input.c

index 9f35b82..8969f7b 100644 (file)
@@ -223,6 +223,9 @@ tcp_connection_cleanup (tcp_connection_t * tc)
       if (!tc->c_is_ip4 && ip6_address_is_link_local_unicast (&tc->c_rmt_ip6))
        tcp_add_del_adjacency (tc, 0);
 
+      vec_free (tc->snd_sacks);
+      vec_free (tc->snd_sacks_fl);
+
       /* Poison the entry */
       if (CLIB_DEBUG > 0)
        clib_memset (tc, 0xFA, sizeof (*tc));
index a4e7935..65182c4 100644 (file)
@@ -304,6 +304,7 @@ typedef struct _tcp_connection
 
   sack_block_t *snd_sacks;     /**< Vector of SACKs to send. XXX Fixed size? */
   u8 snd_sack_pos;             /**< Position in vec of first block to send */
+  sack_block_t *snd_sacks_fl;  /**< Vector for building new list */
   sack_scoreboard_t sack_sb;   /**< SACK "scoreboard" that tracks holes */
 
   u16 rcv_dupacks;     /**< Number of DUPACKs received */
index dbe1fc4..df8f53d 100644 (file)
@@ -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' */