aboutsummaryrefslogtreecommitdiffstats
path: root/src/vcl/vppcom.c
diff options
context:
space:
mode:
authorRadha krishna Saragadam <krishna_srk2003@yahoo.com>2022-07-18 19:41:05 +0530
committerFlorin Coras <florin.coras@gmail.com>2022-07-20 14:47:09 +0000
commitdd92bdeb0735dac940d32f651c0b0b9ed65a6d7d (patch)
treed1f722eb0068f6c2eb1578c3e3600718b868312f /src/vcl/vppcom.c
parent3f245e687c6bd837dcf7c6734aeed788bdbb4220 (diff)
vcl: new vcl api to get detailed session errors
Sometimes VPP rejects application connection requests due to various reasons. Some errors application can retry to get a successful connection. In a non-blocking session, VCL sends EPOLLHUP. An application can call a new API vppcom_session_get_error to find the details and retry depending on the error. Type: fix Signed-off-by: Radha krishna Saragadam <krishna_srk2003@yahoo.com> Change-Id: If0e21a8e25701f66a190a2799b2209e0c31f897c
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
*