X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=inline;f=src%2Fvnet%2Fsession%2Fsession_api.c;h=1fd84ab7c43e78866392848096bb6fc4bb972c78;hb=refs%2Fchanges%2F04%2F9804%2F2;hp=cd7541dcc70e35d7ae16e0f9dd91d34783238c8e;hpb=de5fec943ab12933696db5b0abf287dea335e312;p=vpp.git diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c index cd7541dcc70..1fd84ab7c43 100755 --- a/src/vnet/session/session_api.c +++ b/src/vnet/session/session_api.c @@ -69,7 +69,7 @@ send_add_segment_callback (u32 api_client_index, const u8 * segment_name, if (!q) return -1; - mp = vl_msg_api_alloc (sizeof (*mp)); + mp = vl_msg_api_alloc_as_if_client (sizeof (*mp)); memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MAP_ANOTHER_SEGMENT); mp->segment_size = segment_size; @@ -97,15 +97,25 @@ send_session_accept_callback (stream_session_t * s) if (!q) return -1; - mp = vl_msg_api_alloc (sizeof (*mp)); + mp = vl_msg_api_alloc_as_if_client (sizeof (*mp)); memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_ACCEPT_SESSION); mp->context = server->index; listener = listen_session_get (s->session_type, s->listener_index); - tp_vft = transport_protocol_get_vft (s->session_type); + tp_vft = transport_protocol_get_vft (session_get_transport_proto (s)); tc = tp_vft->get_connection (s->connection_index, s->thread_index); mp->listener_handle = listen_session_get_handle (listener); + + if (application_is_proxy (server)) + { + listener = + application_first_listener (server, + transport_connection_fib_proto (tc), + tc->proto); + if (listener) + mp->listener_handle = listen_session_get_handle (listener); + } mp->handle = session_handle (s); mp->server_rx_fifo = pointer_to_uword (s->server_rx_fifo); mp->server_tx_fifo = pointer_to_uword (s->server_tx_fifo); @@ -130,7 +140,7 @@ send_session_disconnect_callback (stream_session_t * s) if (!q) return; - mp = vl_msg_api_alloc (sizeof (*mp)); + mp = vl_msg_api_alloc_as_if_client (sizeof (*mp)); memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_DISCONNECT_SESSION); mp->handle = session_handle (s); @@ -149,7 +159,7 @@ send_session_reset_callback (stream_session_t * s) if (!q) return; - mp = vl_msg_api_alloc (sizeof (*mp)); + mp = vl_msg_api_alloc_as_if_client (sizeof (*mp)); memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_RESET_SESSION); mp->handle = session_handle (s); @@ -172,7 +182,7 @@ send_session_connected_callback (u32 app_index, u32 api_context, if (!q) return -1; - mp = vl_msg_api_alloc (sizeof (*mp)); + mp = vl_msg_api_alloc_as_if_client (sizeof (*mp)); mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_CONNECT_SESSION_REPLY); mp->context = api_context; @@ -243,8 +253,8 @@ redirect_connect_callback (u32 server_api_client_index, void *mp_arg) } props = segment_manager_properties_get (app->sm_properties); - mp->options[SESSION_OPTIONS_RX_FIFO_SIZE] = props->rx_fifo_size; - mp->options[SESSION_OPTIONS_TX_FIFO_SIZE] = props->tx_fifo_size; + mp->options[APP_OPTIONS_RX_FIFO_SIZE] = props->rx_fifo_size; + mp->options[APP_OPTIONS_TX_FIFO_SIZE] = props->tx_fifo_size; /* * Bounce message handlers MUST NOT block the data-plane. @@ -311,7 +321,7 @@ vl_api_application_attach_t_handler (vl_api_application_attach_t * mp) goto done; } - STATIC_ASSERT (sizeof (u64) * SESSION_OPTIONS_N_OPTIONS <= + STATIC_ASSERT (sizeof (u64) * APP_OPTIONS_N_OPTIONS <= sizeof (mp->options), "Out of options, fix api message definition"); @@ -624,7 +634,10 @@ vl_api_bind_sock_t_handler (vl_api_bind_sock_t * mp) vnet_bind_args_t _a, *a = &_a; int rv = 0; clib_error_t *error; - application_t *app; + application_t *app = 0; + stream_session_t *s; + transport_connection_t *tc = 0; + ip46_address_t *ip46; if (session_manager_is_enabled () == 0) { @@ -633,29 +646,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); } + done: /* *INDENT-OFF* */ REPLY_MACRO2 (VL_API_BIND_SOCK_REPLY,({ if (!rv) - rmp->handle = a->handle; + { + rmp->handle = a->handle; + rmp->lcl_port = mp->port; + if (application_has_global_scope (app)) + { + s = listen_session_get_from_handle (a->handle); + tc = listen_session_get_transport (s); + rmp->lcl_is_ip4 = tc->is_ip4; + clib_memcpy (rmp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip)); + } + } })); /* *INDENT-ON* */ } @@ -817,14 +844,15 @@ vl_api_session_rule_add_del_t_handler (vl_api_session_rule_add_del_t * mp) table_args->lcl.fp_proto = fib_proto; table_args->rmt.fp_len = mp->rmt_plen; table_args->rmt.fp_proto = fib_proto; - table_args->lcl_port = clib_net_to_host_u16 (mp->lcl_port); - table_args->rmt_port = clib_net_to_host_u16 (mp->rmt_port); + table_args->lcl_port = mp->lcl_port; + table_args->rmt_port = mp->rmt_port; table_args->action_index = clib_net_to_host_u32 (mp->action_index); table_args->is_add = mp->is_add; mp->tag[sizeof (mp->tag) - 1] = 0; table_args->tag = format (0, "%s", mp->tag); args.appns_index = clib_net_to_host_u32 (mp->appns_index); args.scope = mp->scope; + args.transport_proto = mp->transport_proto; memset (&table_args->lcl.fp_addr, 0, sizeof (table_args->lcl.fp_addr)); memset (&table_args->rmt.fp_addr, 0, sizeof (table_args->rmt.fp_addr)); @@ -861,8 +889,8 @@ send_session_rule_details4 (mma_rule_16_t * rule, u8 is_local, clib_memcpy (rmp->rmt_ip, &match->rmt_ip, sizeof (match->rmt_ip)); rmp->lcl_plen = ip4_mask_to_preflen (&mask->lcl_ip); rmp->rmt_plen = ip4_mask_to_preflen (&mask->rmt_ip); - rmp->lcl_port = clib_host_to_net_u16 (match->lcl_port); - rmp->rmt_port = clib_host_to_net_u16 (match->rmt_port); + rmp->lcl_port = match->lcl_port; + rmp->rmt_port = match->rmt_port; rmp->action_index = clib_host_to_net_u32 (rule->action_index); rmp->scope = is_local ? SESSION_RULE_SCOPE_LOCAL : SESSION_RULE_SCOPE_GLOBAL; @@ -898,8 +926,8 @@ send_session_rule_details6 (mma_rule_40_t * rule, u8 is_local, clib_memcpy (rmp->rmt_ip, &match->rmt_ip, sizeof (match->rmt_ip)); rmp->lcl_plen = ip6_mask_to_preflen (&mask->lcl_ip); rmp->rmt_plen = ip6_mask_to_preflen (&mask->rmt_ip); - rmp->lcl_port = clib_host_to_net_u16 (match->lcl_port); - rmp->rmt_port = clib_host_to_net_u16 (match->rmt_port); + rmp->lcl_port = match->lcl_port; + rmp->rmt_port = match->rmt_port; rmp->action_index = clib_host_to_net_u32 (rule->action_index); rmp->scope = is_local ? SESSION_RULE_SCOPE_LOCAL : SESSION_RULE_SCOPE_GLOBAL;