session: reset if ct close with data 14/34414/3
authorFlorin Coras <fcoras@cisco.com>
Tue, 9 Nov 2021 18:42:43 +0000 (10:42 -0800)
committerFlorin Coras <florin.coras@gmail.com>
Tue, 9 Nov 2021 19:09:22 +0000 (19:09 +0000)
Type: improvement

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I9540948b8b5476af7558d741cbf15ee838d4e01b

src/vnet/session/application_local.c

index 88536dc..f68567f 100644 (file)
@@ -963,6 +963,15 @@ ct_program_cleanup (ct_connection_t *ct)
     thread_index, ct_handle_cleanups, uword_to_pointer (thread_index, void *));
 }
 
+static inline int
+ct_close_is_reset (ct_connection_t *ct, session_t *s)
+{
+  if (ct->flags & CT_CONN_F_CLIENT)
+    return (svm_fifo_max_dequeue (ct->client_rx_fifo) > 0);
+  else
+    return (svm_fifo_max_dequeue (s->rx_fifo) > 0);
+}
+
 static void
 ct_session_close (u32 ct_index, u32 thread_index)
 {
@@ -981,7 +990,12 @@ ct_session_close (u32 ct_index, u32 thread_index)
          ct_session_connect_notify (s, SESSION_E_REFUSED);
        }
       else if (peer_ct->c_s_index != ~0)
-       session_transport_closing_notify (&peer_ct->connection);
+       {
+         if (ct_close_is_reset (ct, s))
+           session_transport_reset_notify (&peer_ct->connection);
+         else
+           session_transport_closing_notify (&peer_ct->connection);
+       }
       else
        {
          /* should not happen */