From a678974cc52ac61dd6094c3f6649f9e3202be1cb Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Wed, 7 Aug 2019 19:12:38 -0700 Subject: session: allow closed transports to send Type:fix Transports like tcp may notify session layer of a close but they may defer the connection's deletion (e.g., tcp time-wait). During that time, transports may still want to send packets. So, unless the session has no transport (transport-deleted state), allow the transport to send. Change-Id: I3ae335c7b951ff64be8529a5e3f3ad790feddc84 Signed-off-by: Florin Coras --- src/vnet/session/session_node.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/vnet/session') diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index c2e3dd005a8..5af54a8165a 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -512,12 +512,21 @@ session_tx_not_ready (session_t * s, u8 peek_data) { if (peek_data) { + if (PREDICT_TRUE (s->session_state == SESSION_STATE_READY)) + return 0; /* Can retransmit for closed sessions but can't send new data if * session is not ready or closed */ - if (s->session_state < SESSION_STATE_READY) + else if (s->session_state < SESSION_STATE_READY) return 1; - if (s->session_state >= SESSION_STATE_TRANSPORT_CLOSED) - return 2; + else if (s->session_state >= SESSION_STATE_TRANSPORT_CLOSED) + { + /* Allow closed transports to still send custom packets. + * For instance, tcp may want to send acks in time-wait. */ + if (s->session_state != SESSION_STATE_TRANSPORT_DELETED + && (s->flags & SESSION_F_CUSTOM_TX)) + return 0; + return 2; + } } return 0; } @@ -639,7 +648,6 @@ session_tx_fifo_read_and_snd_i (session_worker_t * wrk, tp = session_get_transport_proto (ctx->s); ctx->transport_vft = transport_protocol_get_vft (tp); ctx->tc = session_tx_get_transport (ctx, peek_data); - ctx->snd_mss = ctx->transport_vft->send_mss (ctx->tc); if (PREDICT_FALSE (e->event_type == SESSION_IO_EVT_TX_FLUSH)) { @@ -653,6 +661,9 @@ session_tx_fifo_read_and_snd_i (session_worker_t * wrk, ctx->s->flags &= ~SESSION_F_CUSTOM_TX; n_custom_tx = ctx->transport_vft->custom_tx (ctx->tc, max_burst); *n_tx_packets += n_custom_tx; + if (PREDICT_FALSE + (ctx->s->session_state >= SESSION_STATE_TRANSPORT_CLOSED)) + return SESSION_TX_OK; max_burst -= n_custom_tx; if (!max_burst) { @@ -661,6 +672,7 @@ session_tx_fifo_read_and_snd_i (session_worker_t * wrk, } } + ctx->snd_mss = ctx->transport_vft->send_mss (ctx->tc); ctx->snd_space = transport_connection_snd_space (ctx->tc, vm->clib_time. last_cpu_time, -- cgit 1.2.3-korg