From e7dda6b034b9b8dd56da71280a796e18d88a99bd Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Tue, 9 Nov 2021 10:42:43 -0800 Subject: [PATCH] session: reset if ct close with data Type: improvement Signed-off-by: Florin Coras Change-Id: I9540948b8b5476af7558d741cbf15ee838d4e01b --- src/vnet/session/application_local.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c index 88536dc27c6..f68567f7fd3 100644 --- a/src/vnet/session/application_local.c +++ b/src/vnet/session/application_local.c @@ -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 */ -- 2.16.6