session: add forced reset api to ct transport 08/40108/3
authorFlorin Coras <fcoras@cisco.com>
Thu, 14 Dec 2023 19:46:11 +0000 (11:46 -0800)
committerDave Barach <vpp@barachs.net>
Fri, 15 Dec 2023 00:47:49 +0000 (00:47 +0000)
Type: improvement

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

index b14386a..8fd3d44 100644 (file)
@@ -1034,6 +1034,8 @@ global_scope:
 static inline int
 ct_close_is_reset (ct_connection_t *ct, session_t *s)
 {
+  if (ct->flags & CT_CONN_F_RESET)
+    return 1;
   if (ct->flags & CT_CONN_F_CLIENT)
     return (svm_fifo_max_dequeue (ct->client_rx_fifo) > 0);
   else
@@ -1194,6 +1196,15 @@ ct_session_close (u32 ct_index, u32 thread_index)
   ct_program_cleanup (ct);
 }
 
+static void
+ct_session_reset (u32 ct_index, u32 thread_index)
+{
+  ct_connection_t *ct;
+  ct = ct_connection_get (ct_index, thread_index);
+  ct->flags |= CT_CONN_F_RESET;
+  ct_session_close (ct_index, thread_index);
+}
+
 static transport_connection_t *
 ct_session_get (u32 ct_index, u32 thread_index)
 {
@@ -1358,6 +1369,7 @@ static const transport_proto_vft_t cut_thru_proto = {
   .cleanup_ho = ct_cleanup_ho,
   .connect = ct_session_connect,
   .close = ct_session_close,
+  .reset = ct_session_reset,
   .custom_tx = ct_custom_tx,
   .app_rx_evt = ct_app_rx_evt,
   .format_listener = format_ct_listener,
index 86edf24..fd2804c 100644 (file)
@@ -22,7 +22,8 @@
 
 #define foreach_ct_flags                                                      \
   _ (CLIENT, "client")                                                        \
-  _ (HALF_OPEN, "half-open")
+  _ (HALF_OPEN, "half-open")                                                  \
+  _ (RESET, "reset")
 
 enum
 {