aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-04-07 22:31:06 +0000
committerFlorin Coras <fcoras@cisco.com>2020-04-07 22:48:23 +0000
commita8c3b86ebebea357b89ad181bb4c141db4c6505d (patch)
tree4f98a0fd7a338265fd4ad55f466808a9b2eabdbf /src/vnet/session
parent95e19253320ab07748787f4c8a7620704563f6b8 (diff)
session: add more session errors
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I9b246eb8a99020de9e5859147c456096fe2e3389
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application.c34
-rw-r--r--src/vnet/session/session.c14
-rw-r--r--src/vnet/session/session_types.h6
3 files changed, 33 insertions, 21 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 8d7c909ba67..bf86cbff1d4 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -968,17 +968,17 @@ vnet_listen (vnet_listen_args_t * a)
app = application_get_if_valid (a->app_index);
if (!app)
- return VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
+ return SESSION_E_NOAPP;
app_wrk = application_get_worker (app, a->wrk_map_index);
if (!app_wrk)
- return VNET_API_ERROR_INVALID_VALUE;
+ return SESSION_E_INVALID_APPWRK;
a->sep_ext.app_wrk_index = app_wrk->wrk_index;
session_endpoint_update_for_app (&a->sep_ext, app, 0 /* is_connect */ );
if (!session_endpoint_in_ns (&a->sep))
- return VNET_API_ERROR_INVALID_VALUE_2;
+ return SESSION_E_INVALID_NS;
/*
* Check if we already have an app listener
@@ -987,9 +987,9 @@ vnet_listen (vnet_listen_args_t * a)
if (app_listener)
{
if (app_listener->app_index != app->app_index)
- return VNET_API_ERROR_ADDRESS_IN_USE;
- if (app_worker_start_listen (app_wrk, app_listener))
- return -1;
+ return SESSION_E_ALREADY_LISTENING;
+ if ((rv = app_worker_start_listen (app_wrk, app_listener)))
+ return rv;
a->handle = app_listener_handle (app_listener);
return 0;
}
@@ -1057,22 +1057,22 @@ vnet_unlisten (vnet_unlisten_args_t * a)
ASSERT (vlib_thread_is_main_w_barrier ());
if (!(app = application_get_if_valid (a->app_index)))
- return VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
+ return SESSION_E_NOAPP;
if (!(al = app_listener_get_w_handle (a->handle)))
- return -1;
+ return SESSION_E_NOLISTEN;
if (al->app_index != app->app_index)
{
clib_warning ("app doesn't own handle %llu!", a->handle);
- return -1;
+ return SESSION_E_OWNER;
}
app_wrk = application_get_worker (app, a->wrk_map_index);
if (!app_wrk)
{
clib_warning ("no app %u worker %u", app->app_index, a->wrk_map_index);
- return -1;
+ return SESSION_E_INVALID_APPWRK;
}
return app_worker_stop_listen (app_wrk, al);
@@ -1086,10 +1086,11 @@ vnet_disconnect_session (vnet_disconnect_args_t * a)
s = session_get_from_handle_if_valid (a->handle);
if (!s)
- return VNET_API_ERROR_INVALID_VALUE;
+ return SESSION_E_NOSESSION;
+
app_wrk = app_worker_get (s->app_wrk_index);
if (app_wrk->app_index != a->app_index)
- return VNET_API_ERROR_INVALID_VALUE;
+ return SESSION_E_OWNER;
/* We're peeking into another's thread pool. Make sure */
ASSERT (s->session_index == session_index_from_handle (a->handle));
@@ -1104,9 +1105,10 @@ application_change_listener_owner (session_t * s, app_worker_t * app_wrk)
app_worker_t *old_wrk = app_worker_get (s->app_wrk_index);
app_listener_t *app_listener;
application_t *app;
+ int rv;
if (!old_wrk)
- return -1;
+ return SESSION_E_INVALID_APPWRK;
hash_unset (old_wrk->listeners_table, listen_session_get_handle (s));
if (session_transport_service_type (s) == TRANSPORT_SERVICE_CL
@@ -1115,7 +1117,7 @@ application_change_listener_owner (session_t * s, app_worker_t * app_wrk)
app = application_get (old_wrk->app_index);
if (!app)
- return -1;
+ return SESSION_E_NOAPP;
app_listener = app_listener_get (app, s->al_index);
@@ -1123,8 +1125,8 @@ application_change_listener_owner (session_t * s, app_worker_t * app_wrk)
app_listener->workers = clib_bitmap_set (app_listener->workers,
old_wrk->wrk_map_index, 0);
- if (app_worker_start_listen (app_wrk, app_listener))
- return -1;
+ if ((rv = app_worker_start_listen (app_wrk, app_listener)))
+ return rv;
s->app_wrk_index = app_wrk->wrk_index;
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 79f93c40693..37c5d915008 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1212,7 +1212,8 @@ int
session_listen (session_t * ls, session_endpoint_cfg_t * sep)
{
transport_endpoint_t *tep;
- u32 tc_index, s_index;
+ int tc_index;
+ u32 s_index;
/* Transport bind/listen */
tep = session_endpoint_to_transport (sep);
@@ -1220,8 +1221,8 @@ session_listen (session_t * ls, session_endpoint_cfg_t * sep)
tc_index = transport_start_listen (session_get_transport_proto (ls),
s_index, tep);
- if (tc_index == (u32) ~ 0)
- return -1;
+ if (tc_index < 0)
+ return tc_index;
/* Attach transport to session. Lookup tables are populated by the app
* worker because local tables (for ct sessions) are not backed by a fib */
@@ -1243,14 +1244,17 @@ session_stop_listen (session_t * s)
transport_connection_t *tc;
if (s->session_state != SESSION_STATE_LISTENING)
- return -1;
+ return SESSION_E_NOLISTEN;
tc = transport_get_listener (tp, s->connection_index);
+
+ /* If no transport, assume everything was cleaned up already */
if (!tc)
- return VNET_API_ERROR_ADDRESS_NOT_IN_USE;
+ return SESSION_E_NONE;
if (!(tc->flags & TRANSPORT_CONNECTION_F_NO_LOOKUP))
session_lookup_del_connection (tc);
+
transport_stop_listen (tp, s->connection_index);
return 0;
}
diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h
index ca5dcc1c123..cdaaad04ca1 100644
--- a/src/vnet/session/session_types.h
+++ b/src/vnet/session/session_types.h
@@ -440,15 +440,21 @@ STATIC_ASSERT (sizeof (session_dgram_hdr_t) == (SESSION_CONN_ID_LEN + 8),
_(REFUSED, "refused") \
_(TIMEDOUT, "timedout") \
_(ALLOC, "obj/memory allocation error") \
+ _(OWNER, "object not owned by application") \
_(NOROUTE, "no route") \
_(NOINTF, "no resolving interface") \
_(NOIP, "no ip for lcl interface") \
_(NOPORT, "no lcl port") \
_(NOSUPPORT, "not supported") \
+ _(NOLISTEN, "not listening") \
+ _(NOSESSION, "session does not exist") \
+ _(NOAPP, "app not attached") \
_(PORTINUSE, "lcl port in use") \
_(IPINUSE, "ip in use") \
_(ALREADY_LISTENING, "ip port pair already listened on") \
_(INVALID_RMT_IP, "invalid remote ip") \
+ _(INVALID_APPWRK, "invalid app worker") \
+ _(INVALID_NS, "invalid namespace") \
_(SEG_NO_SPACE, "Couldn't allocate a fifo pair") \
_(SEG_NO_SPACE2, "Created segment, couldn't allocate a fifo pair") \
_(SEG_CREATE, "Couldn't create a new segment") \