aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session/session_api.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-10-21 16:07:46 -0700
committerDave Barach <openvpp@barachs.net>2020-04-03 22:10:22 +0000
commit00e01d3e875bb18397ff81e0f58f9b468477f473 (patch)
tree277b9ce692a465644de5d3481b42e6cce6394f46 /src/vnet/session/session_api.c
parent39aa7a5202a6a875bd6f5d341cb07f19ab0bf51e (diff)
session: improve error reporting
Type: improvement Change-Id: I9dd850a1ce85b0adb5136233f176117e0ee38817 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/session_api.c')
-rw-r--r--src/vnet/session/session_api.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index 6dcf06bd724..43ecf2b07e9 100644
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -100,15 +100,12 @@ session_send_fds (vl_api_registration_t * reg, int fds[], int n_fds)
{
clib_error_t *error;
if (vl_api_registration_file_index (reg) == VL_API_INVALID_FI)
- {
- clib_warning ("can't send memfd fd");
- return -1;
- }
+ return SESSION_E_BAPI_NO_FD;
error = vl_api_send_fd_msg (reg, fds, n_fds);
if (error)
{
clib_error_report (error);
- return -1;
+ return SESSION_E_BAPI_SEND_FD;
}
return 0;
}
@@ -146,7 +143,7 @@ mq_send_session_accepted_cb (session_t * s)
app = application_get (app_wrk->app_index);
app_mq = app_wrk->event_queue;
if (mq_try_lock_and_alloc_msg (app_mq, msg))
- return -1;
+ return SESSION_E_MQ_MSG_ALLOC;
evt = svm_msg_q_msg_data (app_mq, msg);
clib_memset (evt, 0, sizeof (*evt));
@@ -265,7 +262,7 @@ mq_send_session_reset_cb (session_t * s)
int
mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
- session_t * s, u8 is_fail)
+ session_t * s, session_error_t err)
{
svm_msg_q_msg_t _msg, *msg = &_msg;
session_connected_msg_t *mp;
@@ -284,7 +281,7 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
}
if (mq_try_lock_and_alloc_msg (app_mq, msg))
- return -1;
+ return SESSION_E_MQ_MSG_ALLOC;
evt = svm_msg_q_msg_data (app_mq, msg);
clib_memset (evt, 0, sizeof (*evt));
@@ -293,7 +290,7 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
clib_memset (mp, 0, sizeof (*mp));
mp->context = api_context;
- if (is_fail)
+ if (err)
goto done;
if (session_has_transport (s))
@@ -301,7 +298,8 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
tc = session_get_transport (s);
if (!tc)
{
- is_fail = 1;
+ clib_warning ("failed to retrieve transport!");
+ err = SESSION_E_REFUSED;
goto done;
}
@@ -336,8 +334,7 @@ mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context,
}
done:
- mp->retval = is_fail ?
- clib_host_to_net_u32 (VNET_API_ERROR_SESSION_CONNECT) : 0;
+ mp->retval = err;
svm_msg_q_add_and_unlock (app_mq, msg);
return 0;
@@ -365,7 +362,7 @@ mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context,
}
if (mq_try_lock_and_alloc_msg (app_mq, msg))
- return -1;
+ return SESSION_E_MQ_MSG_ALLOC;
evt = svm_msg_q_msg_data (app_mq, msg);
clib_memset (evt, 0, sizeof (*evt));