aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-07-22 19:03:03 -0700
committerDave Barach <openvpp@barachs.net>2019-07-25 17:59:17 +0000
commit5f06632fc700e5f5c72b7238aee3fd84663ddf4f (patch)
tree2b8b74650fcd3d826805493c13dc4a74b1272ebf /src
parent6c84fb2ee1bf230951aaf92d9db595d4c0feac45 (diff)
session: add transport deleted state
Type: fix Distinguish between closed and deleted states to avoid deleting the session prior to the transport connection. Change-Id: Ia285ce94b26a70773f8c0ce9d2c73095d3e2a337 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/session/session.c19
-rwxr-xr-xsrc/vnet/session/session_cli.c4
-rw-r--r--src/vnet/session/session_types.h1
-rw-r--r--src/vnet/tcp/tcp.c1
4 files changed, 14 insertions, 11 deletions
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index ea1a8c9fc5e..477215e3d34 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -793,13 +793,14 @@ session_transport_delete_notify (transport_connection_t * tc)
case SESSION_STATE_ACCEPTING:
case SESSION_STATE_TRANSPORT_CLOSING:
case SESSION_STATE_CLOSING:
+ case SESSION_STATE_TRANSPORT_CLOSED:
/* If transport finishes or times out before we get a reply
* from the app, mark transport as closed and wait for reply
* before removing the session. Cleanup session table in advance
* because transport will soon be closed and closed sessions
* are assumed to have been removed from the lookup table */
session_lookup_del_session (s);
- s->session_state = SESSION_STATE_TRANSPORT_CLOSED;
+ s->session_state = SESSION_STATE_TRANSPORT_DELETED;
session_cleanup_notify (s, SESSION_CLEANUP_TRANSPORT);
svm_fifo_dequeue_drop_all (s->tx_fifo);
break;
@@ -815,7 +816,7 @@ session_transport_delete_notify (transport_connection_t * tc)
svm_fifo_dequeue_drop_all (s->tx_fifo);
session_program_transport_close (s);
break;
- case SESSION_STATE_TRANSPORT_CLOSED:
+ case SESSION_STATE_TRANSPORT_DELETED:
break;
case SESSION_STATE_CLOSED:
session_cleanup_notify (s, SESSION_CLEANUP_TRANSPORT);
@@ -858,11 +859,10 @@ session_transport_closed_notify (transport_connection_t * tc)
* a transport close, only mark the session transport as closed */
else if (s->session_state <= SESSION_STATE_CLOSING)
{
- session_lookup_del_session (s);
s->session_state = SESSION_STATE_TRANSPORT_CLOSED;
}
- /* In all closing states but transport closed switch to closed */
- else if (s->session_state != SESSION_STATE_TRANSPORT_CLOSED)
+ /* If app also closed, switch to closed */
+ else if (s->session_state == SESSION_STATE_APP_CLOSED)
s->session_state = SESSION_STATE_CLOSED;
app_wrk = app_worker_get_if_valid (s->app_wrk_index);
@@ -1118,7 +1118,8 @@ session_close (session_t * s)
{
/* Session will only be removed once both app and transport
* acknowledge the close */
- if (s->session_state == SESSION_STATE_TRANSPORT_CLOSED)
+ if (s->session_state == SESSION_STATE_TRANSPORT_CLOSED
+ || s->session_state == SESSION_STATE_TRANSPORT_DELETED)
session_program_transport_close (s);
return;
}
@@ -1139,8 +1140,10 @@ session_transport_close (session_t * s)
{
if (s->session_state >= SESSION_STATE_APP_CLOSED)
{
- /* If transport is already closed, just free the session */
- if (s->session_state >= SESSION_STATE_TRANSPORT_CLOSED)
+ if (s->session_state == SESSION_STATE_TRANSPORT_CLOSED)
+ s->session_state = SESSION_STATE_CLOSED;
+ /* If transport is already deleted, just free the session */
+ else if (s->session_state >= SESSION_STATE_TRANSPORT_DELETED)
session_free_w_fifos (s);
return;
}
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index ca4b8c12f8d..fd598f45d3e 100755
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -59,7 +59,7 @@ format_session (u8 * s, va_list * args)
u32 tp = session_get_transport_proto (ss);
u8 *str = 0;
- if (ss->session_state >= SESSION_STATE_TRANSPORT_CLOSED)
+ if (ss->session_state >= SESSION_STATE_TRANSPORT_DELETED)
{
s = format (s, "[%u:%u] CLOSED", ss->thread_index, ss->session_index);
return s;
@@ -330,7 +330,7 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
/* *INDENT-OFF* */
pool_foreach (s, pool, ({
- if (s->session_state >= SESSION_STATE_TRANSPORT_CLOSED)
+ if (s->session_state >= SESSION_STATE_TRANSPORT_DELETED)
{
n_closed += 1;
continue;
diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h
index 682094c9cb6..25b61166b11 100644
--- a/src/vnet/session/session_types.h
+++ b/src/vnet/session/session_types.h
@@ -133,6 +133,7 @@ typedef enum
SESSION_STATE_CLOSING,
SESSION_STATE_APP_CLOSED,
SESSION_STATE_TRANSPORT_CLOSED,
+ SESSION_STATE_TRANSPORT_DELETED,
SESSION_STATE_CLOSED,
SESSION_STATE_N_STATES,
} session_state_t;
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index f0d6478df18..928d1bac257 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -358,7 +358,6 @@ tcp_connection_reset (tcp_connection_t * tc)
tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME);
/* Make sure we mark the session as closed. In some states we may
* be still trying to send data */
- session_transport_closed_notify (&tc->connection);
tcp_connection_set_state (tc, TCP_STATE_CLOSED);
session_transport_closed_notify (&tc->connection);
break;