diff options
author | Florin Coras <fcoras@cisco.com> | 2017-11-16 15:32:50 -0800 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2017-11-17 04:50:59 +0000 |
commit | dcf55ce28d558ddeb1fd93904b54dbb843430a0f (patch) | |
tree | a43a4cbac69338f8d4ad9e4a74fa60ea050aa938 /src/vnet/session | |
parent | aa0d62a9adcb2deec6c247a4d2b8a1265356c625 (diff) |
vppcom: improve listener session handling
Change-Id: I86b2e2c5a655e53a915fbf62ff04ee23c86de234
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session')
-rw-r--r-- | src/vnet/session/session.api | 3 | ||||
-rwxr-xr-x | src/vnet/session/session_api.c | 49 |
2 files changed, 36 insertions, 16 deletions
diff --git a/src/vnet/session/session.api b/src/vnet/session/session.api index 358103a4f56..735b826f21f 100644 --- a/src/vnet/session/session.api +++ b/src/vnet/session/session.api @@ -278,6 +278,9 @@ define bind_sock_reply { u64 handle; i32 retval; u64 server_event_queue_address; + u8 lcl_is_ip4; + u8 lcl_ip[16]; + u16 lcl_port; u32 segment_size; u8 segment_name_length; u8 segment_name[128]; diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c index cd7541dcc70..16ff91d0e63 100755 --- a/src/vnet/session/session_api.c +++ b/src/vnet/session/session_api.c @@ -625,6 +625,9 @@ vl_api_bind_sock_t_handler (vl_api_bind_sock_t * mp) int rv = 0; clib_error_t *error; application_t *app; + stream_session_t *s; + transport_connection_t *tc = 0; + ip46_address_t *ip46; if (session_manager_is_enabled () == 0) { @@ -633,29 +636,43 @@ vl_api_bind_sock_t_handler (vl_api_bind_sock_t * mp) } app = application_lookup (mp->client_index); - if (app) + if (!app) { - ip46_address_t *ip46 = (ip46_address_t *) mp->ip; - memset (a, 0, sizeof (*a)); - a->sep.is_ip4 = mp->is_ip4; - a->sep.ip = *ip46; - a->sep.port = mp->port; - a->sep.fib_index = mp->vrf; - a->sep.sw_if_index = ENDPOINT_INVALID_INDEX; - a->sep.transport_proto = mp->proto; - a->app_index = app->index; + rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; + goto done; + } - if ((error = vnet_bind (a))) - { - rv = clib_error_get_code (error); - clib_error_report (error); - } + ip46 = (ip46_address_t *) mp->ip; + memset (a, 0, sizeof (*a)); + a->sep.is_ip4 = mp->is_ip4; + a->sep.ip = *ip46; + a->sep.port = mp->port; + a->sep.fib_index = mp->vrf; + a->sep.sw_if_index = ENDPOINT_INVALID_INDEX; + a->sep.transport_proto = mp->proto; + a->app_index = app->index; + + if ((error = vnet_bind (a))) + { + rv = clib_error_get_code (error); + clib_error_report (error); + } + else + { + s = listen_session_get_from_handle (a->handle); + tc = listen_session_get_transport (s); } + done: /* *INDENT-OFF* */ REPLY_MACRO2 (VL_API_BIND_SOCK_REPLY,({ if (!rv) - rmp->handle = a->handle; + { + rmp->handle = a->handle; + rmp->lcl_is_ip4 = tc->is_ip4; + clib_memcpy (rmp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip)); + rmp->lcl_port = tc->lcl_port; + } })); /* *INDENT-ON* */ } |