tcp: add cc cleanup function 34/20034/1
authorFlorin Coras <fcoras@cisco.com>
Fri, 7 Jun 2019 16:35:20 +0000 (09:35 -0700)
committerFlorin Coras <fcoras@cisco.com>
Fri, 7 Jun 2019 16:35:20 +0000 (09:35 -0700)
Type: feature

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

index b792930..835bd48 100644 (file)
@@ -70,6 +70,38 @@ tcp_add_del_adjacency (tcp_connection_t * tc, u8 is_add)
                             sizeof (args));
 }
 
+static void
+tcp_cc_init (tcp_connection_t * tc)
+{
+  tc->cc_algo = tcp_cc_algo_get (tcp_main.cc_algo);
+  tc->cc_algo->init (tc);
+}
+
+static void
+tcp_cc_cleanup (tcp_connection_t * tc)
+{
+  if (tc->cc_algo->cleanup)
+    tc->cc_algo->cleanup (tc);
+}
+
+void
+tcp_cc_algo_register (tcp_cc_algorithm_type_e type,
+                     const tcp_cc_algorithm_t * vft)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  vec_validate (tm->cc_algos, type);
+
+  tm->cc_algos[type] = *vft;
+  hash_set_mem (tm->cc_algo_by_name, vft->name, type);
+}
+
+tcp_cc_algorithm_t *
+tcp_cc_algo_get (tcp_cc_algorithm_type_e type)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  return &tm->cc_algos[type];
+}
+
 static u32
 tcp_connection_bind (u32 session_index, transport_endpoint_t * lcl)
 {
@@ -226,6 +258,7 @@ 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);
 
+      tcp_cc_cleanup (tc);
       vec_free (tc->snd_sacks);
       vec_free (tc->snd_sacks_fl);
 
@@ -546,31 +579,6 @@ tcp_connection_fib_attach (tcp_connection_t * tc)
 }
 #endif /* 0 */
 
-static void
-tcp_cc_init (tcp_connection_t * tc)
-{
-  tc->cc_algo = tcp_cc_algo_get (tcp_main.cc_algo);
-  tc->cc_algo->init (tc);
-}
-
-void
-tcp_cc_algo_register (tcp_cc_algorithm_type_e type,
-                     const tcp_cc_algorithm_t * vft)
-{
-  tcp_main_t *tm = vnet_get_tcp_main ();
-  vec_validate (tm->cc_algos, type);
-
-  tm->cc_algos[type] = *vft;
-  hash_set_mem (tm->cc_algo_by_name, vft->name, type);
-}
-
-tcp_cc_algorithm_t *
-tcp_cc_algo_get (tcp_cc_algorithm_type_e type)
-{
-  tcp_main_t *tm = vnet_get_tcp_main ();
-  return &tm->cc_algos[type];
-}
-
 /**
  * Generate random iss as per rfc6528
  */
index 46d72b7..48bbb3e 100644 (file)
@@ -333,6 +333,7 @@ struct _tcp_cc_algorithm
   void (*congestion) (tcp_connection_t * tc);
   void (*recovered) (tcp_connection_t * tc);
   void (*init) (tcp_connection_t * tc);
+  void (*cleanup) (tcp_connection_t * tc);
 };
 /* *INDENT-ON* */