aboutsummaryrefslogtreecommitdiffstats
path: root/src/vcl/vppcom.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vcl/vppcom.c')
-rw-r--r--src/vcl/vppcom.c62
1 files changed, 58 insertions, 4 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index f95e72fc94e..05c1dbbb501 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -466,7 +466,7 @@ done_unlock:
}
static u32
-vcl_reset_handler (session_reset_msg_t * reset_msg)
+vcl_session_reset_handler (session_reset_msg_t * reset_msg)
{
vcl_session_t *session;
u32 sid;
@@ -485,6 +485,57 @@ vcl_reset_handler (session_reset_msg_t * reset_msg)
return sid;
}
+static u32
+vcl_session_bound_handler (session_bound_msg_t * mp)
+{
+ vcl_session_t *session;
+ u32 sid = mp->context;
+
+ session = vcl_session_get (sid);
+ if (mp->retval)
+ {
+ VDBG (0, "VCL<%d>: ERROR: vpp handle 0x%llx, sid %u: bind failed: %U",
+ getpid (), mp->handle, sid, format_api_error, ntohl (mp->retval));
+ if (session)
+ {
+ session->session_state = STATE_FAILED;
+ session->vpp_handle = mp->handle;
+ return sid;
+ }
+ else
+ {
+ clib_warning ("[%s] ERROR: vpp handle 0x%llx, sid %u: "
+ "Invalid session index (%u)!",
+ getpid (), mp->handle, sid);
+ return VCL_INVALID_SESSION_INDEX;
+ }
+ }
+
+ session->vpp_handle = mp->handle;
+ session->transport.is_ip4 = mp->lcl_is_ip4;
+ clib_memcpy (&session->transport.lcl_ip, mp->lcl_ip,
+ sizeof (ip46_address_t));
+ session->transport.lcl_port = mp->lcl_port;
+ vppcom_session_table_add_listener (mp->handle, sid);
+ session->session_state = STATE_LISTEN;
+
+ if (session->is_dgram)
+ {
+ svm_fifo_t *rx_fifo, *tx_fifo;
+ session->vpp_evt_q = uword_to_pointer (mp->vpp_evt_q, svm_msg_q_t *);
+ rx_fifo = uword_to_pointer (mp->rx_fifo, svm_fifo_t *);
+ rx_fifo->client_session_index = sid;
+ tx_fifo = uword_to_pointer (mp->tx_fifo, svm_fifo_t *);
+ tx_fifo->client_session_index = sid;
+ session->rx_fifo = rx_fifo;
+ session->tx_fifo = tx_fifo;
+ }
+
+ VDBG (1, "VCL<%d>: vpp handle 0x%llx, sid %u: bind succeeded!",
+ getpid (), mp->handle, sid);
+ return sid;
+}
+
int
vcl_handle_mq_ctrl_event (session_event_t * e)
{
@@ -534,7 +585,10 @@ vcl_handle_mq_ctrl_event (session_event_t * e)
sid);
break;
case SESSION_CTRL_EVT_RESET:
- vcl_reset_handler ((session_reset_msg_t *) e->data);
+ vcl_session_reset_handler ((session_reset_msg_t *) e->data);
+ break;
+ case SESSION_CTRL_EVT_BOUND:
+ vcl_session_bound_handler ((session_bound_msg_t *) e->data);
break;
default:
clib_warning ("unhandled %u", e->event_type);
@@ -1780,7 +1834,7 @@ vcl_select_handle_mq (svm_msg_q_t * mq, unsigned long n_bits,
}
break;
case SESSION_CTRL_EVT_RESET:
- sid = vcl_reset_handler ((session_reset_msg_t *) e->data);
+ sid = vcl_session_reset_handler ((session_reset_msg_t *) e->data);
if (sid < n_bits && except_map)
{
clib_bitmap_set_no_check (except_map, sid, 1);
@@ -2404,7 +2458,7 @@ vcl_epoll_wait_handle_mq (svm_msg_q_t * mq, struct epoll_event *events,
clib_spinlock_unlock (&vcm->sessions_lockp);
break;
case SESSION_CTRL_EVT_RESET:
- sid = vcl_reset_handler ((session_reset_msg_t *) e->data);
+ sid = vcl_session_reset_handler ((session_reset_msg_t *) e->data);
if (!(session = vcl_session_get (sid)))
break;
add_event = 1;