summaryrefslogtreecommitdiffstats
path: root/src/plugins/hs_apps/sapi/vpp_echo_common.c
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2019-09-25 17:58:24 -0400
committerFlorin Coras <florin.coras@gmail.com>2019-10-09 00:29:41 +0000
commitff5a9b6ecd744ff5c42e6c2388dd31a338ea6a0c (patch)
tree7b756ed4cd8f631db0096b7e7b6dfb71735ea9c2 /src/plugins/hs_apps/sapi/vpp_echo_common.c
parent2fd44a00aa26188ca75f0accd734f21758c199bf (diff)
hsa: fix vpp_echo session close
- Convert asserts in vpp_echo to conditional checks - Refactor error logging for session creation/deletion - Fix session close anomalies - Fix ECHO_* macros - Add rx/tx results different cmdline options to specify pass when counters are different - Update close tests to send more than the fifo sizes of data - Specify rx/tx results diff options for early close tests - Set listen session state to closed on handling unlisten reply Type: fix Signed-off-by: Dave Wallace <dwallacelf@gmail.com> Change-Id: I9d0075fcb18e20829f420da104d69523897b0552
Diffstat (limited to 'src/plugins/hs_apps/sapi/vpp_echo_common.c')
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_common.c86
1 files changed, 72 insertions, 14 deletions
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_common.c b/src/plugins/hs_apps/sapi/vpp_echo_common.c
index 0f6c2ec7135..dbe8d92661f 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_common.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo_common.c
@@ -167,29 +167,82 @@ init_error_string_table ()
}
u8 *
+echo_format_session (u8 * s, va_list * args)
+{
+ echo_session_t *session = va_arg (*args, echo_session_t *);
+
+ return format (s, "%U 0x%lx S[%u]", echo_format_session_type,
+ session->session_type, session->vpp_session_handle,
+ session->session_index);
+}
+
+u8 *
+echo_format_session_type (u8 * s, va_list * args)
+{
+ u32 session_type = va_arg (*args, u32);
+ switch (session_type)
+ {
+ case ECHO_SESSION_TYPE_QUIC:
+ return format (s, "Qsession");
+ case ECHO_SESSION_TYPE_STREAM:
+ return format (s, "Stream");
+ case ECHO_SESSION_TYPE_LISTEN:
+ return format (s, "Lsession");
+ default:
+ break;
+ }
+ return format (s, "BadSession");
+}
+
+u8 *
+echo_format_session_state (u8 * s, va_list * args)
+{
+ u32 session_state = va_arg (*args, u32);
+ switch (session_state)
+ {
+ case ECHO_SESSION_STATE_INITIAL:
+ return format (s, "ECHO_SESSION_STATE_INITIAL (%u)", session_state);
+ case ECHO_SESSION_STATE_READY:
+ return format (s, "ECHO_SESSION_STATE_READY (%u)", session_state);
+ case ECHO_SESSION_STATE_AWAIT_CLOSING:
+ return format (s, "ECHO_SESSION_STATE_AWAIT_CLOSING (%u)",
+ session_state);
+ case ECHO_SESSION_STATE_AWAIT_DATA:
+ return format (s, "ECHO_SESSION_STATE_AWAIT_DATA (%u)", session_state);
+ case ECHO_SESSION_STATE_CLOSING:
+ return format (s, "ECHO_SESSION_STATE_CLOSING (%u)", session_state);
+ case ECHO_SESSION_STATE_CLOSED:
+ return format (s, "ECHO_SESSION_STATE_CLOSED (%u)", session_state);
+ default:
+ break;
+ }
+ return format (s, "unknown session state (%u)", session_state);
+}
+
+u8 *
echo_format_app_state (u8 * s, va_list * args)
{
u32 state = va_arg (*args, u32);
if (state == STATE_START)
- return format (s, "STATE_START");
+ return format (s, "STATE_START (%u)", state);
if (state == STATE_ATTACHED)
- return format (s, "STATE_ATTACHED");
+ return format (s, "STATE_ATTACHED (%u)", state);
if (state == STATE_ATTACHED_NO_CERT)
- return format (s, "STATE_ATTACHED_NO_CERT");
+ return format (s, "STATE_ATTACHED_NO_CERT (%u)", state);
if (state == STATE_ATTACHED_ONE_CERT)
- return format (s, "STATE_ATTACHED_ONE_CERT");
+ return format (s, "STATE_ATTACHED_ONE_CERT (%u)", state);
if (state == STATE_LISTEN)
- return format (s, "STATE_LISTEN");
+ return format (s, "STATE_LISTEN (%u)", state);
if (state == STATE_READY)
- return format (s, "STATE_READY");
+ return format (s, "STATE_READY (%u)", state);
if (state == STATE_DATA_DONE)
- return format (s, "STATE_DATA_DONE");
+ return format (s, "STATE_DATA_DONE (%u)", state);
if (state == STATE_DISCONNECTED)
- return format (s, "STATE_DISCONNECTED");
+ return format (s, "STATE_DISCONNECTED (%u)", state);
if (state == STATE_DETACHED)
- return format (s, "STATE_DETACHED");
+ return format (s, "STATE_DETACHED (%u)", state);
else
- return format (s, "unknown state");
+ return format (s, "unknown state (%u)", state);
}
uword
@@ -475,9 +528,15 @@ echo_session_handle_add_del (echo_main_t * em, u64 handle, u32 sid)
{
clib_spinlock_lock (&em->sid_vpp_handles_lock);
if (sid == SESSION_INVALID_INDEX)
- hash_unset (em->session_index_by_vpp_handles, handle);
+ {
+ ECHO_LOG (2, "hash_unset(0x%lx)", handle);
+ hash_unset (em->session_index_by_vpp_handles, handle);
+ }
else
- hash_set (em->session_index_by_vpp_handles, handle, sid);
+ {
+ ECHO_LOG (2, "hash_set(0x%lx) S[%d]", handle, sid);
+ hash_set (em->session_index_by_vpp_handles, handle, sid);
+ }
clib_spinlock_unlock (&em->sid_vpp_handles_lock);
}
@@ -525,8 +584,7 @@ echo_get_session_from_handle (echo_main_t * em, u64 handle)
clib_spinlock_unlock (&em->sid_vpp_handles_lock);
if (!p)
{
- ECHO_FAIL (ECHO_FAIL_GET_SESSION_FROM_HANDLE,
- "unknown handle 0x%lx", handle);
+ ECHO_LOG (1, "unknown handle 0x%lx", handle);
return 0;
}
return pool_elt_at_index (em->sessions, p[0]);