summaryrefslogtreecommitdiffstats
path: root/src/vcl/vppcom.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vcl/vppcom.c')
-rw-r--r--src/vcl/vppcom.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 8476ea44d68..05b84d4674b 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -411,6 +411,7 @@ vcl_session_connected_handler (vcl_worker_t * wrk,
format_session_error, mp->retval);
session->session_state = VCL_STATE_DETACHED;
session->vpp_handle = VCL_INVALID_SESSION_HANDLE;
+ session->vpp_error = mp->retval;
return session_index;
}
@@ -1398,6 +1399,7 @@ vppcom_session_create (u8 proto, u8 is_nonblocking)
session->session_state = VCL_STATE_CLOSED;
session->vpp_handle = ~0;
session->is_dgram = vcl_proto_is_dgram (proto);
+ session->vpp_error = SESSION_E_NONE;
if (is_nonblocking)
vcl_session_set_attr (session, VCL_SESS_ATTR_NONBLOCK);
@@ -4420,6 +4422,10 @@ vppcom_retval_str (int retval)
st = "VPPCOM_ETIMEDOUT";
break;
+ case VPPCOM_EADDRINUSE:
+ st = "VPPCOM_EADDRINUSE";
+ break;
+
default:
st = "UNKNOWN_STATE";
break;
@@ -4446,6 +4452,32 @@ vppcom_del_cert_key_pair (uint32_t ckpair_index)
return vcl_bapi_del_cert_key_pair (ckpair_index);
}
+int
+vppcom_session_get_error (uint32_t session_handle)
+{
+ vcl_worker_t *wrk = vcl_worker_get_current ();
+ vcl_session_t *session = 0;
+
+ session = vcl_session_get_w_handle (wrk, session_handle);
+ if (!session)
+ return VPPCOM_EBADFD;
+
+ if (PREDICT_FALSE (session->flags & VCL_SESSION_F_IS_VEP))
+ {
+ VWRN ("epoll session %u! will not have connect", session->session_index);
+ return VPPCOM_EBADFD;
+ }
+
+ if (session->vpp_error == SESSION_E_PORTINUSE)
+ return VPPCOM_EADDRINUSE;
+ else if (session->vpp_error == SESSION_E_REFUSED)
+ return VPPCOM_ECONNREFUSED;
+ else if (session->vpp_error != SESSION_E_NONE)
+ return VPPCOM_EFAULT;
+ else
+ return VPPCOM_OK;
+}
+
/*
* fd.io coding-style-patch-verification: ON
*