Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1 | /* |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 2 | * Copyright (c) 2015-2019 Cisco and/or its affiliates. |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #include <vnet/vnet.h> |
| 17 | #include <vlibmemory/api.h> |
| 18 | #include <vnet/session/application.h> |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 19 | #include <vnet/session/application_interface.h> |
Florin Coras | ba7d8f5 | 2019-02-22 13:11:38 -0800 | [diff] [blame] | 20 | #include <vnet/session/application_local.h> |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 21 | #include <vnet/session/session_rules_table.h> |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 22 | #include <vnet/session/session_table.h> |
Florin Coras | c9940fc | 2019-02-05 20:55:11 -0800 | [diff] [blame] | 23 | #include <vnet/session/session.h> |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 24 | |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 25 | #include <vnet/ip/ip_types_api.h> |
| 26 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 27 | #include <vnet/vnet_msg_enum.h> |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 28 | |
| 29 | #define vl_typedefs /* define message structures */ |
| 30 | #include <vnet/vnet_all_api_h.h> |
| 31 | #undef vl_typedefs |
| 32 | |
| 33 | #define vl_endianfun /* define message structures */ |
| 34 | #include <vnet/vnet_all_api_h.h> |
| 35 | #undef vl_endianfun |
| 36 | |
| 37 | /* instantiate all the print functions we know about */ |
| 38 | #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) |
| 39 | #define vl_printfun |
| 40 | #include <vnet/vnet_all_api_h.h> |
| 41 | #undef vl_printfun |
| 42 | |
| 43 | #include <vlibapi/api_helper_macros.h> |
| 44 | |
| 45 | #define foreach_session_api_msg \ |
| 46 | _(MAP_ANOTHER_SEGMENT_REPLY, map_another_segment_reply) \ |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 47 | _(APPLICATION_ATTACH, application_attach) \ |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 48 | _(APP_ATTACH, app_attach) \ |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 49 | _(APPLICATION_DETACH, application_detach) \ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 50 | _(BIND_URI, bind_uri) \ |
| 51 | _(UNBIND_URI, unbind_uri) \ |
| 52 | _(CONNECT_URI, connect_uri) \ |
| 53 | _(DISCONNECT_SESSION, disconnect_session) \ |
| 54 | _(DISCONNECT_SESSION_REPLY, disconnect_session_reply) \ |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 55 | _(BIND_SOCK, bind_sock) \ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 56 | _(UNBIND_SOCK, unbind_sock) \ |
| 57 | _(CONNECT_SOCK, connect_sock) \ |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 58 | _(SESSION_ENABLE_DISABLE, session_enable_disable) \ |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 59 | _(APP_NAMESPACE_ADD_DEL, app_namespace_add_del) \ |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 60 | _(SESSION_RULE_ADD_DEL, session_rule_add_del) \ |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 61 | _(SESSION_RULES_DUMP, session_rules_dump) \ |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 62 | _(APPLICATION_TLS_CERT_ADD, application_tls_cert_add) \ |
| 63 | _(APPLICATION_TLS_KEY_ADD, application_tls_key_add) \ |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 64 | _(APP_ADD_CERT_KEY_PAIR, app_add_cert_key_pair) \ |
| 65 | _(APP_DEL_CERT_KEY_PAIR, app_del_cert_key_pair) \ |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 66 | _(APP_WORKER_ADD_DEL, app_worker_add_del) \ |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 67 | |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 68 | static transport_proto_t |
| 69 | api_session_transport_proto_decode (const vl_api_transport_proto_t * api_tp) |
| 70 | { |
| 71 | switch (*api_tp) |
| 72 | { |
| 73 | case TRANSPORT_PROTO_API_TCP: |
| 74 | return TRANSPORT_PROTO_TCP; |
| 75 | case TRANSPORT_PROTO_API_UDP: |
| 76 | return TRANSPORT_PROTO_UDP; |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 77 | case TRANSPORT_PROTO_API_TLS: |
| 78 | return TRANSPORT_PROTO_TLS; |
| 79 | case TRANSPORT_PROTO_API_UDPC: |
| 80 | return TRANSPORT_PROTO_UDPC; |
| 81 | case TRANSPORT_PROTO_API_QUIC: |
| 82 | return TRANSPORT_PROTO_QUIC; |
| 83 | default: |
| 84 | return TRANSPORT_PROTO_NONE; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | static vl_api_transport_proto_t |
| 89 | api_session_transport_proto_encode (const transport_proto_t tp) |
| 90 | { |
| 91 | switch (tp) |
| 92 | { |
| 93 | case TRANSPORT_PROTO_TCP: |
| 94 | return TRANSPORT_PROTO_API_TCP; |
| 95 | case TRANSPORT_PROTO_UDP: |
| 96 | return TRANSPORT_PROTO_API_UDP; |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 97 | case TRANSPORT_PROTO_TLS: |
| 98 | return TRANSPORT_PROTO_API_TLS; |
| 99 | case TRANSPORT_PROTO_UDPC: |
| 100 | return TRANSPORT_PROTO_API_UDPC; |
| 101 | case TRANSPORT_PROTO_QUIC: |
| 102 | return TRANSPORT_PROTO_API_QUIC; |
| 103 | default: |
| 104 | return TRANSPORT_PROTO_API_NONE; |
| 105 | } |
| 106 | } |
| 107 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 108 | static int |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 109 | session_send_fds (vl_api_registration_t * reg, int fds[], int n_fds) |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 110 | { |
| 111 | clib_error_t *error; |
| 112 | if (vl_api_registration_file_index (reg) == VL_API_INVALID_FI) |
| 113 | { |
| 114 | clib_warning ("can't send memfd fd"); |
| 115 | return -1; |
| 116 | } |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 117 | error = vl_api_send_fd_msg (reg, fds, n_fds); |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 118 | if (error) |
| 119 | { |
| 120 | clib_error_report (error); |
| 121 | return -1; |
| 122 | } |
| 123 | return 0; |
| 124 | } |
| 125 | |
Florin Coras | c4c4cf5 | 2019-08-24 18:17:34 -0700 | [diff] [blame] | 126 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 127 | static int |
Florin Coras | fa76a76 | 2018-11-29 12:40:10 -0800 | [diff] [blame] | 128 | send_add_segment_callback (u32 api_client_index, u64 segment_handle) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 129 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 130 | int fds[SESSION_N_FD_TYPE], n_fds = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 131 | vl_api_map_another_segment_t *mp; |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 132 | vl_api_registration_t *reg; |
Florin Coras | 88001c6 | 2019-04-24 14:44:46 -0700 | [diff] [blame] | 133 | fifo_segment_t *fs; |
Florin Coras | fa76a76 | 2018-11-29 12:40:10 -0800 | [diff] [blame] | 134 | ssvm_private_t *sp; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 135 | u8 fd_flags = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 136 | |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 137 | reg = vl_mem_api_client_index_to_registration (api_client_index); |
| 138 | if (!reg) |
| 139 | { |
Florin Coras | fa76a76 | 2018-11-29 12:40:10 -0800 | [diff] [blame] | 140 | clib_warning ("no api registration for client: %u", api_client_index); |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 141 | return -1; |
| 142 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 143 | |
Florin Coras | fa76a76 | 2018-11-29 12:40:10 -0800 | [diff] [blame] | 144 | fs = segment_manager_get_segment_w_handle (segment_handle); |
| 145 | sp = &fs->ssvm; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 146 | if (ssvm_type (sp) == SSVM_SEGMENT_MEMFD) |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 147 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 148 | if (vl_api_registration_file_index (reg) == VL_API_INVALID_FI) |
| 149 | { |
| 150 | clib_warning ("can't send memfd fd"); |
| 151 | return -1; |
| 152 | } |
| 153 | |
| 154 | fd_flags |= SESSION_FD_F_MEMFD_SEGMENT; |
| 155 | fds[n_fds] = sp->fd; |
| 156 | n_fds += 1; |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 157 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 158 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 159 | mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp)); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 160 | clib_memset (mp, 0, sizeof (*mp)); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 161 | mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MAP_ANOTHER_SEGMENT); |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 162 | mp->segment_size = sp->ssvm_size; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 163 | mp->fd_flags = fd_flags; |
Florin Coras | fa76a76 | 2018-11-29 12:40:10 -0800 | [diff] [blame] | 164 | mp->segment_handle = clib_host_to_net_u64 (segment_handle); |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 165 | strncpy ((char *) mp->segment_name, (char *) sp->name, |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 166 | sizeof (mp->segment_name) - 1); |
| 167 | |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 168 | vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp); |
| 169 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 170 | if (n_fds) |
| 171 | return session_send_fds (reg, fds, n_fds); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 172 | |
| 173 | return 0; |
| 174 | } |
| 175 | |
Florin Coras | c4c4cf5 | 2019-08-24 18:17:34 -0700 | [diff] [blame] | 176 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 177 | static int |
Florin Coras | fa76a76 | 2018-11-29 12:40:10 -0800 | [diff] [blame] | 178 | send_del_segment_callback (u32 api_client_index, u64 segment_handle) |
Florin Coras | f8f516a | 2018-02-08 15:10:09 -0800 | [diff] [blame] | 179 | { |
| 180 | vl_api_unmap_segment_t *mp; |
| 181 | vl_api_registration_t *reg; |
| 182 | |
| 183 | reg = vl_mem_api_client_index_to_registration (api_client_index); |
| 184 | if (!reg) |
| 185 | { |
| 186 | clib_warning ("no registration: %u", api_client_index); |
| 187 | return -1; |
| 188 | } |
| 189 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 190 | mp = vl_mem_api_alloc_as_if_client_w_reg (reg, sizeof (*mp)); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 191 | clib_memset (mp, 0, sizeof (*mp)); |
Florin Coras | f8f516a | 2018-02-08 15:10:09 -0800 | [diff] [blame] | 192 | mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_UNMAP_SEGMENT); |
Florin Coras | fa76a76 | 2018-11-29 12:40:10 -0800 | [diff] [blame] | 193 | mp->segment_handle = clib_host_to_net_u64 (segment_handle); |
Florin Coras | f8f516a | 2018-02-08 15:10:09 -0800 | [diff] [blame] | 194 | vl_msg_api_send_shmem (reg->vl_input_queue, (u8 *) & mp); |
| 195 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | static int |
Florin Coras | 83ea669 | 2018-10-12 16:55:14 -0700 | [diff] [blame] | 200 | mq_try_lock_and_alloc_msg (svm_msg_q_t * app_mq, svm_msg_q_msg_t * msg) |
| 201 | { |
| 202 | int rv; |
| 203 | u8 try = 0; |
| 204 | while (try < 100) |
| 205 | { |
| 206 | rv = svm_msg_q_lock_and_alloc_msg_w_ring (app_mq, |
| 207 | SESSION_MQ_CTRL_EVT_RING, |
| 208 | SVM_Q_NOWAIT, msg); |
| 209 | if (!rv) |
| 210 | return 0; |
| 211 | try++; |
Florin Coras | e2ea193 | 2018-12-17 23:08:14 -0800 | [diff] [blame] | 212 | usleep (1); |
Florin Coras | 83ea669 | 2018-10-12 16:55:14 -0700 | [diff] [blame] | 213 | } |
Florin Coras | dc2e251 | 2018-12-03 17:47:26 -0800 | [diff] [blame] | 214 | clib_warning ("failed to alloc msg"); |
Florin Coras | 83ea669 | 2018-10-12 16:55:14 -0700 | [diff] [blame] | 215 | return -1; |
| 216 | } |
| 217 | |
| 218 | static int |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 219 | mq_send_session_accepted_cb (session_t * s) |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 220 | { |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 221 | app_worker_t *app_wrk = app_worker_get (s->app_wrk_index); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 222 | svm_msg_q_msg_t _msg, *msg = &_msg; |
| 223 | svm_msg_q_t *vpp_queue, *app_mq; |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 224 | session_t *listener; |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 225 | session_accepted_msg_t *mp; |
| 226 | session_event_t *evt; |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 227 | application_t *app; |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 228 | |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 229 | app = application_get (app_wrk->app_index); |
| 230 | app_mq = app_wrk->event_queue; |
Florin Coras | 83ea669 | 2018-10-12 16:55:14 -0700 | [diff] [blame] | 231 | if (mq_try_lock_and_alloc_msg (app_mq, msg)) |
| 232 | return -1; |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 233 | |
| 234 | evt = svm_msg_q_msg_data (app_mq, msg); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 235 | clib_memset (evt, 0, sizeof (*evt)); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 236 | evt->event_type = SESSION_CTRL_EVT_ACCEPTED; |
| 237 | mp = (session_accepted_msg_t *) evt->data; |
Florin Coras | 87c6570 | 2019-01-26 14:33:26 -0800 | [diff] [blame] | 238 | clib_memset (mp, 0, sizeof (*mp)); |
Florin Coras | ab2f6db | 2018-08-31 14:31:41 -0700 | [diff] [blame] | 239 | mp->context = app->app_index; |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 240 | mp->server_rx_fifo = pointer_to_uword (s->rx_fifo); |
| 241 | mp->server_tx_fifo = pointer_to_uword (s->tx_fifo); |
Florin Coras | fa76a76 | 2018-11-29 12:40:10 -0800 | [diff] [blame] | 242 | mp->segment_handle = session_segment_handle (s); |
Nathan Skrzypczak | c00f480 | 2019-12-03 16:25:11 +0100 | [diff] [blame] | 243 | mp->flags = s->flags; |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 244 | |
| 245 | if (session_has_transport (s)) |
| 246 | { |
Nathan Skrzypczak | 2f0f96b | 2019-06-13 10:14:28 +0200 | [diff] [blame] | 247 | listener = listen_session_get_from_handle (s->listener_handle); |
Florin Coras | 87d6633 | 2019-06-11 12:31:31 -0700 | [diff] [blame] | 248 | mp->listener_handle = app_listen_session_handle (listener); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 249 | if (application_is_proxy (app)) |
| 250 | { |
| 251 | listener = |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 252 | app_worker_first_listener (app_wrk, session_get_fib_proto (s), |
| 253 | session_get_transport_proto (s)); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 254 | if (listener) |
| 255 | mp->listener_handle = listen_session_get_handle (listener); |
| 256 | } |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 257 | vpp_queue = session_main_get_vpp_event_queue (s->thread_index); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 258 | mp->vpp_event_queue_address = pointer_to_uword (vpp_queue); |
| 259 | mp->handle = session_handle (s); |
Aloys Augustin | cdb7170 | 2019-04-08 17:54:39 +0200 | [diff] [blame] | 260 | |
Florin Coras | 09d18c2 | 2019-04-24 11:10:02 -0700 | [diff] [blame] | 261 | session_get_endpoint (s, &mp->rmt, 0 /* is_lcl */ ); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 262 | } |
| 263 | else |
| 264 | { |
Florin Coras | 2b81e3c | 2019-02-27 07:55:46 -0800 | [diff] [blame] | 265 | ct_connection_t *ct; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 266 | |
Florin Coras | 2b81e3c | 2019-02-27 07:55:46 -0800 | [diff] [blame] | 267 | ct = (ct_connection_t *) session_get_transport (s); |
Nathan Skrzypczak | 2f0f96b | 2019-06-13 10:14:28 +0200 | [diff] [blame] | 268 | listener = listen_session_get_from_handle (s->listener_handle); |
Florin Coras | 87d6633 | 2019-06-11 12:31:31 -0700 | [diff] [blame] | 269 | mp->listener_handle = app_listen_session_handle (listener); |
Florin Coras | 09d18c2 | 2019-04-24 11:10:02 -0700 | [diff] [blame] | 270 | mp->rmt.is_ip4 = session_type_is_ip4 (listener->session_type); |
| 271 | mp->rmt.port = ct->c_rmt_port; |
Florin Coras | 2b81e3c | 2019-02-27 07:55:46 -0800 | [diff] [blame] | 272 | mp->handle = session_handle (s); |
Florin Coras | 653e43f | 2019-03-04 10:56:23 -0800 | [diff] [blame] | 273 | vpp_queue = session_main_get_vpp_event_queue (0); |
Florin Coras | 54693d2 | 2018-07-17 10:46:29 -0700 | [diff] [blame] | 274 | mp->vpp_event_queue_address = pointer_to_uword (vpp_queue); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 275 | } |
Florin Coras | 537b17e | 2018-09-28 10:35:45 -0700 | [diff] [blame] | 276 | svm_msg_q_add_and_unlock (app_mq, msg); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 277 | |
| 278 | return 0; |
| 279 | } |
| 280 | |
Florin Coras | 72b0428 | 2019-01-14 17:23:11 -0800 | [diff] [blame] | 281 | static inline void |
| 282 | mq_send_session_close_evt (app_worker_t * app_wrk, session_handle_t sh, |
| 283 | session_evt_type_t evt_type) |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 284 | { |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 285 | svm_msg_q_msg_t _msg, *msg = &_msg; |
| 286 | session_disconnected_msg_t *mp; |
| 287 | svm_msg_q_t *app_mq; |
| 288 | session_event_t *evt; |
| 289 | |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 290 | app_mq = app_wrk->event_queue; |
Florin Coras | 83ea669 | 2018-10-12 16:55:14 -0700 | [diff] [blame] | 291 | if (mq_try_lock_and_alloc_msg (app_mq, msg)) |
| 292 | return; |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 293 | evt = svm_msg_q_msg_data (app_mq, msg); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 294 | clib_memset (evt, 0, sizeof (*evt)); |
Florin Coras | 72b0428 | 2019-01-14 17:23:11 -0800 | [diff] [blame] | 295 | evt->event_type = evt_type; |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 296 | mp = (session_disconnected_msg_t *) evt->data; |
Florin Coras | 72b0428 | 2019-01-14 17:23:11 -0800 | [diff] [blame] | 297 | mp->handle = sh; |
Florin Coras | c1f5a43 | 2018-11-20 11:31:26 -0800 | [diff] [blame] | 298 | mp->context = app_wrk->api_client_index; |
Florin Coras | 537b17e | 2018-09-28 10:35:45 -0700 | [diff] [blame] | 299 | svm_msg_q_add_and_unlock (app_mq, msg); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 300 | } |
| 301 | |
Florin Coras | 72b0428 | 2019-01-14 17:23:11 -0800 | [diff] [blame] | 302 | static inline void |
| 303 | mq_notify_close_subscribers (u32 app_index, session_handle_t sh, |
| 304 | svm_fifo_t * f, session_evt_type_t evt_type) |
| 305 | { |
| 306 | app_worker_t *app_wrk; |
| 307 | application_t *app; |
| 308 | int i; |
| 309 | |
| 310 | app = application_get (app_index); |
| 311 | if (!app) |
| 312 | return; |
| 313 | |
| 314 | for (i = 0; i < f->n_subscribers; i++) |
| 315 | { |
| 316 | if (!(app_wrk = application_get_worker (app, f->subscribers[i]))) |
| 317 | continue; |
| 318 | mq_send_session_close_evt (app_wrk, sh, SESSION_CTRL_EVT_DISCONNECTED); |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | static void |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 323 | mq_send_session_disconnected_cb (session_t * s) |
Florin Coras | 72b0428 | 2019-01-14 17:23:11 -0800 | [diff] [blame] | 324 | { |
| 325 | app_worker_t *app_wrk = app_worker_get (s->app_wrk_index); |
| 326 | session_handle_t sh = session_handle (s); |
| 327 | |
| 328 | mq_send_session_close_evt (app_wrk, session_handle (s), |
| 329 | SESSION_CTRL_EVT_DISCONNECTED); |
| 330 | |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 331 | if (svm_fifo_n_subscribers (s->rx_fifo)) |
| 332 | mq_notify_close_subscribers (app_wrk->app_index, sh, s->rx_fifo, |
Florin Coras | 72b0428 | 2019-01-14 17:23:11 -0800 | [diff] [blame] | 333 | SESSION_CTRL_EVT_DISCONNECTED); |
| 334 | } |
| 335 | |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 336 | static void |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 337 | mq_send_session_reset_cb (session_t * s) |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 338 | { |
Florin Coras | 72b0428 | 2019-01-14 17:23:11 -0800 | [diff] [blame] | 339 | app_worker_t *app_wrk = app_worker_get (s->app_wrk_index); |
| 340 | session_handle_t sh = session_handle (s); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 341 | |
Florin Coras | 72b0428 | 2019-01-14 17:23:11 -0800 | [diff] [blame] | 342 | mq_send_session_close_evt (app_wrk, sh, SESSION_CTRL_EVT_RESET); |
| 343 | |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 344 | if (svm_fifo_n_subscribers (s->rx_fifo)) |
| 345 | mq_notify_close_subscribers (app_wrk->app_index, sh, s->rx_fifo, |
Florin Coras | 72b0428 | 2019-01-14 17:23:11 -0800 | [diff] [blame] | 346 | SESSION_CTRL_EVT_RESET); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 347 | } |
| 348 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 349 | int |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 350 | mq_send_session_connected_cb (u32 app_wrk_index, u32 api_context, |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 351 | session_t * s, u8 is_fail) |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 352 | { |
| 353 | svm_msg_q_msg_t _msg, *msg = &_msg; |
| 354 | session_connected_msg_t *mp; |
| 355 | svm_msg_q_t *vpp_mq, *app_mq; |
| 356 | transport_connection_t *tc; |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 357 | app_worker_t *app_wrk; |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 358 | session_event_t *evt; |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 359 | |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 360 | app_wrk = app_worker_get (app_wrk_index); |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 361 | app_mq = app_wrk->event_queue; |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 362 | if (!app_mq) |
| 363 | { |
Florin Coras | c1f5a43 | 2018-11-20 11:31:26 -0800 | [diff] [blame] | 364 | clib_warning ("app %u with api index: %u not attached", |
| 365 | app_wrk->app_index, app_wrk->api_client_index); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 366 | return -1; |
| 367 | } |
| 368 | |
Florin Coras | 83ea669 | 2018-10-12 16:55:14 -0700 | [diff] [blame] | 369 | if (mq_try_lock_and_alloc_msg (app_mq, msg)) |
| 370 | return -1; |
Florin Coras | dc2e251 | 2018-12-03 17:47:26 -0800 | [diff] [blame] | 371 | |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 372 | evt = svm_msg_q_msg_data (app_mq, msg); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 373 | clib_memset (evt, 0, sizeof (*evt)); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 374 | evt->event_type = SESSION_CTRL_EVT_CONNECTED; |
| 375 | mp = (session_connected_msg_t *) evt->data; |
Florin Coras | 87c6570 | 2019-01-26 14:33:26 -0800 | [diff] [blame] | 376 | clib_memset (mp, 0, sizeof (*mp)); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 377 | mp->context = api_context; |
| 378 | |
| 379 | if (is_fail) |
| 380 | goto done; |
| 381 | |
| 382 | if (session_has_transport (s)) |
| 383 | { |
| 384 | tc = session_get_transport (s); |
| 385 | if (!tc) |
| 386 | { |
| 387 | is_fail = 1; |
| 388 | goto done; |
| 389 | } |
| 390 | |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 391 | vpp_mq = session_main_get_vpp_event_queue (s->thread_index); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 392 | mp->handle = session_handle (s); |
| 393 | mp->vpp_event_queue_address = pointer_to_uword (vpp_mq); |
Aloys Augustin | cdb7170 | 2019-04-08 17:54:39 +0200 | [diff] [blame] | 394 | |
Florin Coras | 09d18c2 | 2019-04-24 11:10:02 -0700 | [diff] [blame] | 395 | session_get_endpoint (s, &mp->lcl, 1 /* is_lcl */ ); |
Aloys Augustin | cdb7170 | 2019-04-08 17:54:39 +0200 | [diff] [blame] | 396 | |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 397 | mp->server_rx_fifo = pointer_to_uword (s->rx_fifo); |
| 398 | mp->server_tx_fifo = pointer_to_uword (s->tx_fifo); |
Florin Coras | 2b81e3c | 2019-02-27 07:55:46 -0800 | [diff] [blame] | 399 | mp->segment_handle = session_segment_handle (s); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 400 | } |
| 401 | else |
| 402 | { |
Florin Coras | 2b81e3c | 2019-02-27 07:55:46 -0800 | [diff] [blame] | 403 | ct_connection_t *cct; |
| 404 | session_t *ss; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 405 | |
Florin Coras | 2b81e3c | 2019-02-27 07:55:46 -0800 | [diff] [blame] | 406 | cct = (ct_connection_t *) session_get_transport (s); |
Florin Coras | 2b81e3c | 2019-02-27 07:55:46 -0800 | [diff] [blame] | 407 | mp->handle = session_handle (s); |
Florin Coras | 09d18c2 | 2019-04-24 11:10:02 -0700 | [diff] [blame] | 408 | mp->lcl.port = cct->c_lcl_port; |
| 409 | mp->lcl.is_ip4 = cct->c_is_ip4; |
Florin Coras | 653e43f | 2019-03-04 10:56:23 -0800 | [diff] [blame] | 410 | vpp_mq = session_main_get_vpp_event_queue (0); |
Florin Coras | 54693d2 | 2018-07-17 10:46:29 -0700 | [diff] [blame] | 411 | mp->vpp_event_queue_address = pointer_to_uword (vpp_mq); |
Florin Coras | 653e43f | 2019-03-04 10:56:23 -0800 | [diff] [blame] | 412 | mp->server_rx_fifo = pointer_to_uword (s->rx_fifo); |
| 413 | mp->server_tx_fifo = pointer_to_uword (s->tx_fifo); |
| 414 | mp->segment_handle = session_segment_handle (s); |
Florin Coras | 2b81e3c | 2019-02-27 07:55:46 -0800 | [diff] [blame] | 415 | ss = ct_session_get_peer (s); |
Florin Coras | 653e43f | 2019-03-04 10:56:23 -0800 | [diff] [blame] | 416 | mp->ct_rx_fifo = pointer_to_uword (ss->tx_fifo); |
| 417 | mp->ct_tx_fifo = pointer_to_uword (ss->rx_fifo); |
| 418 | mp->ct_segment_handle = session_segment_handle (ss); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | done: |
| 422 | mp->retval = is_fail ? |
| 423 | clib_host_to_net_u32 (VNET_API_ERROR_SESSION_CONNECT) : 0; |
| 424 | |
Florin Coras | 537b17e | 2018-09-28 10:35:45 -0700 | [diff] [blame] | 425 | svm_msg_q_add_and_unlock (app_mq, msg); |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 426 | return 0; |
| 427 | } |
| 428 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 429 | int |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 430 | mq_send_session_bound_cb (u32 app_wrk_index, u32 api_context, |
| 431 | session_handle_t handle, int rv) |
| 432 | { |
| 433 | svm_msg_q_msg_t _msg, *msg = &_msg; |
| 434 | svm_msg_q_t *app_mq, *vpp_evt_q; |
Yu Ping | 0b81915 | 2019-05-07 02:24:30 +0800 | [diff] [blame] | 435 | transport_endpoint_t tep; |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 436 | session_bound_msg_t *mp; |
| 437 | app_worker_t *app_wrk; |
| 438 | session_event_t *evt; |
Florin Coras | c9940fc | 2019-02-05 20:55:11 -0800 | [diff] [blame] | 439 | app_listener_t *al; |
| 440 | session_t *ls = 0; |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 441 | app_wrk = app_worker_get (app_wrk_index); |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 442 | app_mq = app_wrk->event_queue; |
| 443 | if (!app_mq) |
| 444 | { |
Florin Coras | c1f5a43 | 2018-11-20 11:31:26 -0800 | [diff] [blame] | 445 | clib_warning ("app %u with api index: %u not attached", |
| 446 | app_wrk->app_index, app_wrk->api_client_index); |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 447 | return -1; |
| 448 | } |
| 449 | |
Florin Coras | 83ea669 | 2018-10-12 16:55:14 -0700 | [diff] [blame] | 450 | if (mq_try_lock_and_alloc_msg (app_mq, msg)) |
| 451 | return -1; |
| 452 | |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 453 | evt = svm_msg_q_msg_data (app_mq, msg); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 454 | clib_memset (evt, 0, sizeof (*evt)); |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 455 | evt->event_type = SESSION_CTRL_EVT_BOUND; |
| 456 | mp = (session_bound_msg_t *) evt->data; |
| 457 | mp->context = api_context; |
| 458 | |
| 459 | if (rv) |
| 460 | goto done; |
| 461 | |
| 462 | mp->handle = handle; |
Florin Coras | d4295e6 | 2019-02-22 13:11:38 -0800 | [diff] [blame] | 463 | al = app_listener_get_w_handle (handle); |
| 464 | if (al->session_index != SESSION_INVALID_INDEX) |
| 465 | ls = app_listener_get_session (al); |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 466 | else |
Florin Coras | d4295e6 | 2019-02-22 13:11:38 -0800 | [diff] [blame] | 467 | ls = app_listener_get_local_session (al); |
Yu Ping | 0b81915 | 2019-05-07 02:24:30 +0800 | [diff] [blame] | 468 | |
| 469 | session_get_endpoint (ls, &tep, 1 /* is_lcl */ ); |
| 470 | mp->lcl_port = tep.port; |
| 471 | mp->lcl_is_ip4 = tep.is_ip4; |
| 472 | clib_memcpy_fast (mp->lcl_ip, &tep.ip, sizeof (tep.ip)); |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 473 | |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 474 | vpp_evt_q = session_main_get_vpp_event_queue (0); |
Florin Coras | 5f45e01 | 2019-01-23 09:21:30 -0800 | [diff] [blame] | 475 | mp->vpp_evt_q = pointer_to_uword (vpp_evt_q); |
| 476 | |
Florin Coras | 2b81e3c | 2019-02-27 07:55:46 -0800 | [diff] [blame] | 477 | if (session_transport_service_type (ls) == TRANSPORT_SERVICE_CL) |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 478 | { |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 479 | mp->rx_fifo = pointer_to_uword (ls->rx_fifo); |
| 480 | mp->tx_fifo = pointer_to_uword (ls->tx_fifo); |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | done: |
| 484 | mp->retval = rv; |
Florin Coras | 537b17e | 2018-09-28 10:35:45 -0700 | [diff] [blame] | 485 | svm_msg_q_add_and_unlock (app_mq, msg); |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 486 | return 0; |
| 487 | } |
| 488 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 489 | void |
| 490 | mq_send_unlisten_reply (app_worker_t * app_wrk, session_handle_t sh, |
| 491 | u32 context, int rv) |
| 492 | { |
| 493 | svm_msg_q_msg_t _msg, *msg = &_msg; |
| 494 | session_unlisten_reply_msg_t *ump; |
| 495 | svm_msg_q_t *app_mq; |
| 496 | session_event_t *evt; |
| 497 | |
| 498 | app_mq = app_wrk->event_queue; |
| 499 | if (mq_try_lock_and_alloc_msg (app_mq, msg)) |
| 500 | return; |
| 501 | |
| 502 | evt = svm_msg_q_msg_data (app_mq, msg); |
| 503 | clib_memset (evt, 0, sizeof (*evt)); |
| 504 | evt->event_type = SESSION_CTRL_EVT_UNLISTEN_REPLY; |
| 505 | ump = (session_unlisten_reply_msg_t *) evt->data; |
| 506 | ump->context = context; |
| 507 | ump->handle = sh; |
| 508 | ump->retval = rv; |
| 509 | svm_msg_q_add_and_unlock (app_mq, msg); |
| 510 | } |
| 511 | |
Florin Coras | 49568af | 2019-07-31 16:46:24 -0700 | [diff] [blame] | 512 | static void |
| 513 | mq_send_session_migrate_cb (session_t * s, session_handle_t new_sh) |
| 514 | { |
Florin Coras | 68b7e58 | 2020-01-21 18:33:23 -0800 | [diff] [blame] | 515 | svm_msg_q_msg_t _msg, *msg = &_msg; |
| 516 | session_migrated_msg_t *mp; |
| 517 | svm_msg_q_t *vpp_evt_q; |
| 518 | app_worker_t *app_wrk; |
| 519 | session_event_t *evt; |
| 520 | svm_msg_q_t *app_mq; |
| 521 | |
| 522 | app_wrk = app_worker_get (s->app_wrk_index); |
| 523 | app_mq = app_wrk->event_queue; |
| 524 | if (mq_try_lock_and_alloc_msg (app_mq, msg)) |
| 525 | return; |
| 526 | |
| 527 | evt = svm_msg_q_msg_data (app_mq, msg); |
| 528 | clib_memset (evt, 0, sizeof (*evt)); |
| 529 | evt->event_type = SESSION_CTRL_EVT_MIGRATED; |
| 530 | mp = (session_migrated_msg_t *) evt->data; |
| 531 | mp->handle = session_handle (s); |
| 532 | mp->new_handle = new_sh; |
| 533 | mp->vpp_thread_index = session_thread_from_handle (new_sh); |
| 534 | vpp_evt_q = session_main_get_vpp_event_queue (mp->vpp_thread_index); |
| 535 | mp->vpp_evt_q = pointer_to_uword (vpp_evt_q); |
| 536 | svm_msg_q_add_and_unlock (app_mq, msg); |
Florin Coras | 49568af | 2019-07-31 16:46:24 -0700 | [diff] [blame] | 537 | } |
| 538 | |
Florin Coras | c4c4cf5 | 2019-08-24 18:17:34 -0700 | [diff] [blame] | 539 | static int |
| 540 | mq_send_add_segment_cb (u32 app_wrk_index, u64 segment_handle) |
| 541 | { |
| 542 | int fds[SESSION_N_FD_TYPE], n_fds = 0; |
| 543 | svm_msg_q_msg_t _msg, *msg = &_msg; |
| 544 | session_app_add_segment_msg_t *mp; |
| 545 | vl_api_registration_t *reg; |
| 546 | app_worker_t *app_wrk; |
| 547 | session_event_t *evt; |
| 548 | svm_msg_q_t *app_mq; |
| 549 | fifo_segment_t *fs; |
| 550 | ssvm_private_t *sp; |
| 551 | u8 fd_flags = 0; |
| 552 | |
| 553 | app_wrk = app_worker_get (app_wrk_index); |
| 554 | |
| 555 | reg = vl_mem_api_client_index_to_registration (app_wrk->api_client_index); |
| 556 | if (!reg) |
| 557 | { |
| 558 | clib_warning ("no api registration for client: %u", |
| 559 | app_wrk->api_client_index); |
| 560 | return -1; |
| 561 | } |
| 562 | |
| 563 | fs = segment_manager_get_segment_w_handle (segment_handle); |
| 564 | sp = &fs->ssvm; |
| 565 | if (ssvm_type (sp) == SSVM_SEGMENT_MEMFD) |
| 566 | { |
| 567 | if (vl_api_registration_file_index (reg) == VL_API_INVALID_FI) |
| 568 | { |
| 569 | clib_warning ("can't send memfd fd"); |
| 570 | return -1; |
| 571 | } |
| 572 | |
| 573 | fd_flags |= SESSION_FD_F_MEMFD_SEGMENT; |
| 574 | fds[n_fds] = sp->fd; |
| 575 | n_fds += 1; |
| 576 | } |
| 577 | |
| 578 | app_mq = app_wrk->event_queue; |
| 579 | if (mq_try_lock_and_alloc_msg (app_mq, msg)) |
| 580 | return -1; |
| 581 | |
| 582 | if (n_fds) |
| 583 | session_send_fds (reg, fds, n_fds); |
| 584 | |
| 585 | evt = svm_msg_q_msg_data (app_mq, msg); |
| 586 | clib_memset (evt, 0, sizeof (*evt)); |
| 587 | evt->event_type = SESSION_CTRL_EVT_APP_ADD_SEGMENT; |
| 588 | mp = (session_app_add_segment_msg_t *) evt->data; |
| 589 | clib_memset (mp, 0, sizeof (*mp)); |
| 590 | mp->segment_size = sp->ssvm_size; |
| 591 | mp->fd_flags = fd_flags; |
| 592 | mp->segment_handle = segment_handle; |
| 593 | strncpy ((char *) mp->segment_name, (char *) sp->name, |
| 594 | sizeof (mp->segment_name) - 1); |
| 595 | |
| 596 | svm_msg_q_add_and_unlock (app_mq, msg); |
| 597 | |
| 598 | return 0; |
| 599 | } |
| 600 | |
| 601 | static int |
| 602 | mq_send_del_segment_cb (u32 app_wrk_index, u64 segment_handle) |
| 603 | { |
| 604 | svm_msg_q_msg_t _msg, *msg = &_msg; |
| 605 | session_app_del_segment_msg_t *mp; |
| 606 | vl_api_registration_t *reg; |
| 607 | app_worker_t *app_wrk; |
| 608 | session_event_t *evt; |
| 609 | svm_msg_q_t *app_mq; |
| 610 | |
| 611 | app_wrk = app_worker_get (app_wrk_index); |
| 612 | reg = vl_mem_api_client_index_to_registration (app_wrk->api_client_index); |
| 613 | if (!reg) |
| 614 | { |
| 615 | clib_warning ("no registration: %u", app_wrk->api_client_index); |
| 616 | return -1; |
| 617 | } |
| 618 | |
| 619 | app_mq = app_wrk->event_queue; |
| 620 | if (mq_try_lock_and_alloc_msg (app_mq, msg)) |
| 621 | return -1; |
| 622 | |
| 623 | evt = svm_msg_q_msg_data (app_mq, msg); |
| 624 | clib_memset (evt, 0, sizeof (*evt)); |
| 625 | evt->event_type = SESSION_CTRL_EVT_APP_DEL_SEGMENT; |
| 626 | mp = (session_app_del_segment_msg_t *) evt->data; |
| 627 | clib_memset (mp, 0, sizeof (*mp)); |
| 628 | mp->segment_handle = segment_handle; |
| 629 | svm_msg_q_add_and_unlock (app_mq, msg); |
| 630 | |
| 631 | return 0; |
| 632 | } |
| 633 | |
Florin Coras | 9ace36d | 2019-10-28 13:14:17 -0700 | [diff] [blame] | 634 | static void |
| 635 | mq_send_session_cleanup_cb (session_t * s, session_cleanup_ntf_t ntf) |
| 636 | { |
| 637 | svm_msg_q_msg_t _msg, *msg = &_msg; |
| 638 | session_cleanup_msg_t *mp; |
| 639 | svm_msg_q_t *app_mq; |
| 640 | session_event_t *evt; |
| 641 | app_worker_t *app_wrk; |
| 642 | |
| 643 | /* Only propagate session cleanup notification */ |
| 644 | if (ntf == SESSION_CLEANUP_TRANSPORT) |
| 645 | return; |
| 646 | |
| 647 | app_wrk = app_worker_get_if_valid (s->app_wrk_index); |
| 648 | if (!app_wrk) |
| 649 | return; |
| 650 | |
| 651 | app_mq = app_wrk->event_queue; |
| 652 | if (mq_try_lock_and_alloc_msg (app_mq, msg)) |
| 653 | return; |
| 654 | |
| 655 | evt = svm_msg_q_msg_data (app_mq, msg); |
| 656 | clib_memset (evt, 0, sizeof (*evt)); |
| 657 | evt->event_type = SESSION_CTRL_EVT_CLEANUP; |
| 658 | mp = (session_cleanup_msg_t *) evt->data; |
| 659 | mp->handle = session_handle (s); |
| 660 | svm_msg_q_add_and_unlock (app_mq, msg); |
| 661 | } |
| 662 | |
Florin Coras | c4c4cf5 | 2019-08-24 18:17:34 -0700 | [diff] [blame] | 663 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
| 664 | static session_cb_vft_t session_mq_cb_vft_old = { |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 665 | .session_accept_callback = mq_send_session_accepted_cb, |
| 666 | .session_disconnect_callback = mq_send_session_disconnected_cb, |
| 667 | .session_connected_callback = mq_send_session_connected_cb, |
| 668 | .session_reset_callback = mq_send_session_reset_cb, |
Florin Coras | 49568af | 2019-07-31 16:46:24 -0700 | [diff] [blame] | 669 | .session_migrate_callback = mq_send_session_migrate_cb, |
Florin Coras | 52207f1 | 2018-07-12 14:48:06 -0700 | [diff] [blame] | 670 | .add_segment_callback = send_add_segment_callback, |
| 671 | .del_segment_callback = send_del_segment_callback, |
| 672 | }; |
| 673 | |
Florin Coras | c4c4cf5 | 2019-08-24 18:17:34 -0700 | [diff] [blame] | 674 | static session_cb_vft_t session_mq_cb_vft = { |
| 675 | .session_accept_callback = mq_send_session_accepted_cb, |
| 676 | .session_disconnect_callback = mq_send_session_disconnected_cb, |
| 677 | .session_connected_callback = mq_send_session_connected_cb, |
| 678 | .session_reset_callback = mq_send_session_reset_cb, |
| 679 | .session_migrate_callback = mq_send_session_migrate_cb, |
Florin Coras | 9ace36d | 2019-10-28 13:14:17 -0700 | [diff] [blame] | 680 | .session_cleanup_callback = mq_send_session_cleanup_cb, |
Florin Coras | c4c4cf5 | 2019-08-24 18:17:34 -0700 | [diff] [blame] | 681 | .add_segment_callback = mq_send_add_segment_cb, |
| 682 | .del_segment_callback = mq_send_del_segment_cb, |
| 683 | }; |
| 684 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 685 | static void |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 686 | vl_api_session_enable_disable_t_handler (vl_api_session_enable_disable_t * mp) |
| 687 | { |
| 688 | vl_api_session_enable_disable_reply_t *rmp; |
| 689 | vlib_main_t *vm = vlib_get_main (); |
| 690 | int rv = 0; |
| 691 | |
| 692 | vnet_session_enable_disable (vm, mp->is_enable); |
| 693 | REPLY_MACRO (VL_API_SESSION_ENABLE_DISABLE_REPLY); |
| 694 | } |
| 695 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 696 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 697 | static void |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 698 | vl_api_application_attach_t_handler (vl_api_application_attach_t * mp) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 699 | { |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 700 | int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 701 | vl_api_application_attach_reply_t *rmp; |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 702 | ssvm_private_t *segp, *evt_q_segment; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 703 | vnet_app_attach_args_t _a, *a = &_a; |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 704 | vl_api_registration_t *reg; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 705 | u8 fd_flags = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 706 | |
Florin Coras | fc804d9 | 2018-01-26 01:27:01 -0800 | [diff] [blame] | 707 | reg = vl_api_client_index_to_registration (mp->client_index); |
| 708 | if (!reg) |
| 709 | return; |
| 710 | |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 711 | if (session_main_is_enabled () == 0) |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 712 | { |
| 713 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 714 | goto done; |
| 715 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 716 | |
Florin Coras | ff6e769 | 2017-12-11 04:59:01 -0800 | [diff] [blame] | 717 | STATIC_ASSERT (sizeof (u64) * APP_OPTIONS_N_OPTIONS <= |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 718 | sizeof (mp->options), |
| 719 | "Out of options, fix api message definition"); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 720 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 721 | clib_memset (a, 0, sizeof (*a)); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 722 | a->api_client_index = mp->client_index; |
| 723 | a->options = mp->options; |
Florin Coras | c4c4cf5 | 2019-08-24 18:17:34 -0700 | [diff] [blame] | 724 | a->session_cb_vft = &session_mq_cb_vft_old; |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 725 | a->namespace_id = |
| 726 | (u8 *) vl_api_from_api_to_new_c_string (&mp->namespace_id); |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 727 | |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 728 | if ((rv = vnet_application_attach (a))) |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 729 | { |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 730 | clib_warning ("attach returned: %d", rv); |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 731 | vec_free (a->namespace_id); |
| 732 | goto done; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 733 | } |
| 734 | vec_free (a->namespace_id); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 735 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 736 | /* Send event queues segment */ |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 737 | if ((evt_q_segment = session_main_get_evt_q_segment ())) |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 738 | { |
| 739 | fd_flags |= SESSION_FD_F_VPP_MQ_SEGMENT; |
| 740 | fds[n_fds] = evt_q_segment->fd; |
| 741 | n_fds += 1; |
| 742 | } |
| 743 | /* Send fifo segment fd if needed */ |
| 744 | if (ssvm_type (a->segment) == SSVM_SEGMENT_MEMFD) |
| 745 | { |
| 746 | fd_flags |= SESSION_FD_F_MEMFD_SEGMENT; |
| 747 | fds[n_fds] = a->segment->fd; |
| 748 | n_fds += 1; |
| 749 | } |
| 750 | if (a->options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD) |
| 751 | { |
| 752 | fd_flags |= SESSION_FD_F_MQ_EVENTFD; |
| 753 | fds[n_fds] = svm_msg_q_get_producer_eventfd (a->app_evt_q); |
| 754 | n_fds += 1; |
| 755 | } |
| 756 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 757 | done: |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 758 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 759 | /* *INDENT-OFF* */ |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 760 | REPLY_MACRO2 (VL_API_APPLICATION_ATTACH_REPLY, ({ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 761 | if (!rv) |
| 762 | { |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 763 | segp = a->segment; |
Florin Coras | c1f5a43 | 2018-11-20 11:31:26 -0800 | [diff] [blame] | 764 | rmp->app_index = clib_host_to_net_u32 (a->app_index); |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 765 | vl_api_vec_to_api_string (segp->name, &rmp->segment_name); |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 766 | rmp->segment_size = segp->ssvm_size; |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 767 | rmp->app_event_queue_address = pointer_to_uword (a->app_evt_q); |
| 768 | rmp->n_fds = n_fds; |
| 769 | rmp->fd_flags = fd_flags; |
Florin Coras | d85de68 | 2018-11-29 17:02:29 -0800 | [diff] [blame] | 770 | rmp->segment_handle = clib_host_to_net_u64 (a->segment_handle); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 771 | } |
| 772 | })); |
| 773 | /* *INDENT-ON* */ |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 774 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 775 | if (n_fds) |
| 776 | session_send_fds (reg, fds, n_fds); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | static void |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 780 | vl_api_app_attach_t_handler (vl_api_app_attach_t * mp) |
| 781 | { |
| 782 | int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0; |
| 783 | vl_api_app_attach_reply_t *rmp; |
| 784 | ssvm_private_t *segp, *evt_q_segment; |
| 785 | vnet_app_attach_args_t _a, *a = &_a; |
| 786 | u8 fd_flags = 0, ctrl_thread; |
| 787 | vl_api_registration_t *reg; |
| 788 | svm_msg_q_t *ctrl_mq; |
| 789 | |
| 790 | reg = vl_api_client_index_to_registration (mp->client_index); |
| 791 | if (!reg) |
| 792 | return; |
| 793 | |
| 794 | if (session_main_is_enabled () == 0) |
| 795 | { |
| 796 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 797 | goto done; |
| 798 | } |
| 799 | |
| 800 | STATIC_ASSERT (sizeof (u64) * APP_OPTIONS_N_OPTIONS <= |
| 801 | sizeof (mp->options), |
| 802 | "Out of options, fix api message definition"); |
| 803 | |
| 804 | clib_memset (a, 0, sizeof (*a)); |
| 805 | a->api_client_index = mp->client_index; |
| 806 | a->options = mp->options; |
| 807 | a->session_cb_vft = &session_mq_cb_vft; |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 808 | |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 809 | a->namespace_id = vl_api_from_api_to_new_vec (&mp->namespace_id); |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 810 | |
| 811 | if ((rv = vnet_application_attach (a))) |
| 812 | { |
| 813 | clib_warning ("attach returned: %d", rv); |
| 814 | vec_free (a->namespace_id); |
| 815 | goto done; |
| 816 | } |
| 817 | vec_free (a->namespace_id); |
| 818 | |
| 819 | /* Send event queues segment */ |
| 820 | if ((evt_q_segment = session_main_get_evt_q_segment ())) |
| 821 | { |
| 822 | fd_flags |= SESSION_FD_F_VPP_MQ_SEGMENT; |
| 823 | fds[n_fds] = evt_q_segment->fd; |
| 824 | n_fds += 1; |
| 825 | } |
| 826 | /* Send fifo segment fd if needed */ |
| 827 | if (ssvm_type (a->segment) == SSVM_SEGMENT_MEMFD) |
| 828 | { |
| 829 | fd_flags |= SESSION_FD_F_MEMFD_SEGMENT; |
| 830 | fds[n_fds] = a->segment->fd; |
| 831 | n_fds += 1; |
| 832 | } |
| 833 | if (a->options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD) |
| 834 | { |
| 835 | fd_flags |= SESSION_FD_F_MQ_EVENTFD; |
| 836 | fds[n_fds] = svm_msg_q_get_producer_eventfd (a->app_evt_q); |
| 837 | n_fds += 1; |
| 838 | } |
| 839 | |
| 840 | done: |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 841 | /* *INDENT-OFF* */ |
| 842 | REPLY_MACRO2 (VL_API_APP_ATTACH_REPLY, ({ |
| 843 | if (!rv) |
| 844 | { |
Vratko Polak | 4f59985 | 2019-11-08 10:32:39 +0100 | [diff] [blame] | 845 | ctrl_thread = vlib_num_workers () ? 1 : 0; |
Nathan Skrzypczak | 9d3e1b4 | 2019-11-07 10:29:24 +0100 | [diff] [blame] | 846 | ctrl_mq = session_main_get_vpp_event_queue (ctrl_thread); |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 847 | segp = a->segment; |
| 848 | rmp->app_index = clib_host_to_net_u32 (a->app_index); |
| 849 | rmp->app_mq = pointer_to_uword (a->app_evt_q); |
| 850 | rmp->vpp_ctrl_mq = pointer_to_uword (ctrl_mq); |
| 851 | rmp->vpp_ctrl_mq_thread = ctrl_thread; |
| 852 | rmp->n_fds = n_fds; |
| 853 | rmp->fd_flags = fd_flags; |
| 854 | if (vec_len (segp->name)) |
| 855 | { |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 856 | vl_api_vec_to_api_string (segp->name, &rmp->segment_name); |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 857 | } |
| 858 | rmp->segment_size = segp->ssvm_size; |
| 859 | rmp->segment_handle = clib_host_to_net_u64 (a->segment_handle); |
| 860 | } |
| 861 | })); |
| 862 | /* *INDENT-ON* */ |
| 863 | |
| 864 | if (n_fds) |
| 865 | session_send_fds (reg, fds, n_fds); |
| 866 | } |
| 867 | |
| 868 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
| 869 | static void |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 870 | vl_api_application_detach_t_handler (vl_api_application_detach_t * mp) |
| 871 | { |
| 872 | vl_api_application_detach_reply_t *rmp; |
| 873 | int rv = VNET_API_ERROR_INVALID_VALUE_2; |
| 874 | vnet_app_detach_args_t _a, *a = &_a; |
| 875 | application_t *app; |
| 876 | |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 877 | if (session_main_is_enabled () == 0) |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 878 | { |
| 879 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 880 | goto done; |
| 881 | } |
| 882 | |
| 883 | app = application_lookup (mp->client_index); |
| 884 | if (app) |
| 885 | { |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 886 | a->app_index = app->app_index; |
Florin Coras | 053a0e4 | 2018-11-13 15:52:38 -0800 | [diff] [blame] | 887 | a->api_client_index = mp->client_index; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 888 | rv = vnet_application_detach (a); |
| 889 | } |
| 890 | |
| 891 | done: |
| 892 | REPLY_MACRO (VL_API_APPLICATION_DETACH_REPLY); |
| 893 | } |
| 894 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 895 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 896 | static void |
| 897 | vl_api_bind_uri_t_handler (vl_api_bind_uri_t * mp) |
| 898 | { |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 899 | vl_api_bind_uri_reply_t *rmp; |
Florin Coras | 6442401 | 2019-03-02 10:47:47 -0800 | [diff] [blame] | 900 | vnet_listen_args_t _a, *a = &_a; |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 901 | application_t *app = 0; |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 902 | app_worker_t *app_wrk; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 903 | int rv; |
| 904 | |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 905 | if (session_main_is_enabled () == 0) |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 906 | { |
| 907 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 908 | goto done; |
| 909 | } |
| 910 | |
| 911 | app = application_lookup (mp->client_index); |
| 912 | if (app) |
| 913 | { |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 914 | clib_memset (a, 0, sizeof (*a)); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 915 | a->uri = (char *) mp->uri; |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 916 | a->app_index = app->app_index; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 917 | rv = vnet_bind_uri (a); |
| 918 | } |
| 919 | else |
| 920 | { |
| 921 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 922 | } |
| 923 | |
| 924 | done: |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 925 | |
Florin Coras | 6442401 | 2019-03-02 10:47:47 -0800 | [diff] [blame] | 926 | REPLY_MACRO (VL_API_BIND_URI_REPLY); |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 927 | |
Florin Coras | 6442401 | 2019-03-02 10:47:47 -0800 | [diff] [blame] | 928 | if (app) |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 929 | { |
| 930 | app_wrk = application_get_worker (app, 0); |
| 931 | mq_send_session_bound_cb (app_wrk->wrk_index, mp->context, a->handle, |
| 932 | rv); |
| 933 | } |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 934 | } |
| 935 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 936 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 937 | static void |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 938 | vl_api_unbind_uri_t_handler (vl_api_unbind_uri_t * mp) |
| 939 | { |
| 940 | vl_api_unbind_uri_reply_t *rmp; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 941 | application_t *app; |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 942 | vnet_unlisten_args_t _a, *a = &_a; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 943 | int rv; |
| 944 | |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 945 | if (session_main_is_enabled () == 0) |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 946 | { |
| 947 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 948 | goto done; |
| 949 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 950 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 951 | app = application_lookup (mp->client_index); |
| 952 | if (app) |
| 953 | { |
| 954 | a->uri = (char *) mp->uri; |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 955 | a->app_index = app->app_index; |
Nathan Skrzypczak | 2eed1a1 | 2019-07-04 14:26:21 +0200 | [diff] [blame] | 956 | a->wrk_map_index = 0; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 957 | rv = vnet_unbind_uri (a); |
| 958 | } |
| 959 | else |
| 960 | { |
| 961 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 962 | } |
| 963 | |
| 964 | done: |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 965 | REPLY_MACRO (VL_API_UNBIND_URI_REPLY); |
| 966 | } |
| 967 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 968 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 969 | static void |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 970 | vl_api_connect_uri_t_handler (vl_api_connect_uri_t * mp) |
| 971 | { |
Florin Coras | 6442401 | 2019-03-02 10:47:47 -0800 | [diff] [blame] | 972 | vl_api_connect_uri_reply_t *rmp; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 973 | vnet_connect_args_t _a, *a = &_a; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 974 | application_t *app; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 975 | int rv = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 976 | |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 977 | if (session_main_is_enabled () == 0) |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 978 | { |
| 979 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 980 | goto done; |
| 981 | } |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 982 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 983 | app = application_lookup (mp->client_index); |
| 984 | if (app) |
| 985 | { |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 986 | clib_memset (a, 0, sizeof (*a)); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 987 | a->uri = (char *) mp->uri; |
| 988 | a->api_context = mp->context; |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 989 | a->app_index = app->app_index; |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 990 | if ((rv = vnet_connect_uri (a))) |
| 991 | clib_warning ("connect_uri returned: %d", rv); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 992 | } |
| 993 | else |
| 994 | { |
| 995 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 996 | } |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 997 | |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 998 | /* |
| 999 | * Don't reply to stream (tcp) connects. The reply will come once |
| 1000 | * the connection is established. In case of the redirects, the reply |
| 1001 | * will come from the server app. |
| 1002 | */ |
Florin Coras | 8f89dd0 | 2018-03-05 16:53:07 -0800 | [diff] [blame] | 1003 | if (rv == 0) |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 1004 | return; |
| 1005 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1006 | done: |
Florin Coras | 6442401 | 2019-03-02 10:47:47 -0800 | [diff] [blame] | 1007 | REPLY_MACRO (VL_API_CONNECT_URI_REPLY); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1008 | } |
| 1009 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 1010 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1011 | static void |
| 1012 | vl_api_disconnect_session_t_handler (vl_api_disconnect_session_t * mp) |
| 1013 | { |
| 1014 | vl_api_disconnect_session_reply_t *rmp; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1015 | vnet_disconnect_args_t _a, *a = &_a; |
| 1016 | application_t *app; |
| 1017 | int rv = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1018 | |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 1019 | if (session_main_is_enabled () == 0) |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1020 | { |
| 1021 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 1022 | goto done; |
| 1023 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1024 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1025 | app = application_lookup (mp->client_index); |
| 1026 | if (app) |
| 1027 | { |
| 1028 | a->handle = mp->handle; |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1029 | a->app_index = app->app_index; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1030 | rv = vnet_disconnect_session (a); |
| 1031 | } |
| 1032 | else |
| 1033 | { |
| 1034 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 1035 | } |
| 1036 | |
| 1037 | done: |
Dave Wallace | de5fec9 | 2017-11-11 22:41:34 -0500 | [diff] [blame] | 1038 | REPLY_MACRO2 (VL_API_DISCONNECT_SESSION_REPLY, rmp->handle = mp->handle); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1039 | } |
| 1040 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 1041 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1042 | static void |
| 1043 | vl_api_disconnect_session_reply_t_handler (vl_api_disconnect_session_reply_t * |
| 1044 | mp) |
| 1045 | { |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1046 | vnet_disconnect_args_t _a, *a = &_a; |
| 1047 | application_t *app; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1048 | |
| 1049 | /* Client objected to disconnecting the session, log and continue */ |
| 1050 | if (mp->retval) |
| 1051 | { |
| 1052 | clib_warning ("client retval %d", mp->retval); |
| 1053 | return; |
| 1054 | } |
| 1055 | |
| 1056 | /* Disconnect has been confirmed. Confirm close to transport */ |
Florin Coras | f8f516a | 2018-02-08 15:10:09 -0800 | [diff] [blame] | 1057 | app = application_lookup (mp->context); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1058 | if (app) |
| 1059 | { |
| 1060 | a->handle = mp->handle; |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1061 | a->app_index = app->app_index; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1062 | vnet_disconnect_session (a); |
| 1063 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1064 | } |
| 1065 | |
Florin Coras | c4c4cf5 | 2019-08-24 18:17:34 -0700 | [diff] [blame] | 1066 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1067 | static void |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1068 | vl_api_map_another_segment_reply_t_handler (vl_api_map_another_segment_reply_t |
| 1069 | * mp) |
| 1070 | { |
| 1071 | clib_warning ("not implemented"); |
| 1072 | } |
| 1073 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 1074 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1075 | static void |
| 1076 | vl_api_bind_sock_t_handler (vl_api_bind_sock_t * mp) |
| 1077 | { |
Florin Coras | c9940fc | 2019-02-05 20:55:11 -0800 | [diff] [blame] | 1078 | vnet_listen_args_t _a, *a = &_a; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1079 | vl_api_bind_sock_reply_t *rmp; |
Florin Coras | eb2945c | 2017-11-22 10:39:09 -0800 | [diff] [blame] | 1080 | application_t *app = 0; |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 1081 | app_worker_t *app_wrk; |
Florin Coras | c9940fc | 2019-02-05 20:55:11 -0800 | [diff] [blame] | 1082 | int rv = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1083 | |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 1084 | if (session_main_is_enabled () == 0) |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1085 | { |
| 1086 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 1087 | goto done; |
| 1088 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1089 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1090 | app = application_lookup (mp->client_index); |
Florin Coras | dcf55ce | 2017-11-16 15:32:50 -0800 | [diff] [blame] | 1091 | if (!app) |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1092 | { |
Florin Coras | dcf55ce | 2017-11-16 15:32:50 -0800 | [diff] [blame] | 1093 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 1094 | goto done; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1095 | } |
Florin Coras | dcf55ce | 2017-11-16 15:32:50 -0800 | [diff] [blame] | 1096 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 1097 | clib_memset (a, 0, sizeof (*a)); |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1098 | ip_address_decode (&mp->ip, &a->sep.ip); |
| 1099 | a->sep.is_ip4 = ip46_address_is_ip4 (&a->sep.ip); |
Florin Coras | dcf55ce | 2017-11-16 15:32:50 -0800 | [diff] [blame] | 1100 | a->sep.port = mp->port; |
| 1101 | a->sep.fib_index = mp->vrf; |
| 1102 | a->sep.sw_if_index = ENDPOINT_INVALID_INDEX; |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1103 | a->sep.transport_proto = api_session_transport_proto_decode (&mp->proto); |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1104 | a->app_index = app->app_index; |
| 1105 | a->wrk_map_index = mp->wrk_index; |
Florin Coras | dcf55ce | 2017-11-16 15:32:50 -0800 | [diff] [blame] | 1106 | |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 1107 | if ((rv = vnet_listen (a))) |
| 1108 | clib_warning ("listen returned: %d", rv); |
Florin Coras | dcf55ce | 2017-11-16 15:32:50 -0800 | [diff] [blame] | 1109 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1110 | done: |
Florin Coras | 6442401 | 2019-03-02 10:47:47 -0800 | [diff] [blame] | 1111 | /* Actual reply sent only over mq */ |
| 1112 | REPLY_MACRO (VL_API_BIND_SOCK_REPLY); |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 1113 | |
Florin Coras | 6442401 | 2019-03-02 10:47:47 -0800 | [diff] [blame] | 1114 | if (app) |
Florin Coras | 6011699 | 2018-08-27 09:52:18 -0700 | [diff] [blame] | 1115 | { |
| 1116 | app_wrk = application_get_worker (app, mp->wrk_index); |
| 1117 | mq_send_session_bound_cb (app_wrk->wrk_index, mp->context, a->handle, |
| 1118 | rv); |
| 1119 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1120 | } |
| 1121 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 1122 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1123 | static void |
| 1124 | vl_api_unbind_sock_t_handler (vl_api_unbind_sock_t * mp) |
| 1125 | { |
| 1126 | vl_api_unbind_sock_reply_t *rmp; |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 1127 | vnet_unlisten_args_t _a, *a = &_a; |
Florin Coras | dfae9f9 | 2019-02-20 19:48:31 -0800 | [diff] [blame] | 1128 | app_worker_t *app_wrk; |
| 1129 | application_t *app = 0; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1130 | int rv = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1131 | |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 1132 | if (session_main_is_enabled () == 0) |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1133 | { |
| 1134 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 1135 | goto done; |
| 1136 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1137 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1138 | app = application_lookup (mp->client_index); |
| 1139 | if (app) |
| 1140 | { |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1141 | a->app_index = app->app_index; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1142 | a->handle = mp->handle; |
Florin Coras | ab2f6db | 2018-08-31 14:31:41 -0700 | [diff] [blame] | 1143 | a->wrk_map_index = mp->wrk_index; |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 1144 | if ((rv = vnet_unlisten (a))) |
| 1145 | clib_warning ("unlisten returned: %d", rv); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1146 | } |
Florin Coras | eef61bb | 2019-08-27 15:13:35 -0700 | [diff] [blame] | 1147 | else |
| 1148 | { |
| 1149 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 1150 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1151 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1152 | done: |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1153 | REPLY_MACRO (VL_API_UNBIND_SOCK_REPLY); |
Florin Coras | dfae9f9 | 2019-02-20 19:48:31 -0800 | [diff] [blame] | 1154 | |
Florin Coras | eef61bb | 2019-08-27 15:13:35 -0700 | [diff] [blame] | 1155 | if (!app) |
| 1156 | return; |
| 1157 | |
Florin Coras | dfae9f9 | 2019-02-20 19:48:31 -0800 | [diff] [blame] | 1158 | app_wrk = application_get_worker (app, a->wrk_map_index); |
| 1159 | if (!app_wrk) |
| 1160 | return; |
| 1161 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 1162 | mq_send_unlisten_reply (app_wrk, mp->handle, mp->context, rv); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1163 | } |
| 1164 | |
Florin Coras | 458089b | 2019-08-21 16:20:44 -0700 | [diff] [blame] | 1165 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1166 | static void |
| 1167 | vl_api_connect_sock_t_handler (vl_api_connect_sock_t * mp) |
| 1168 | { |
Florin Coras | 6442401 | 2019-03-02 10:47:47 -0800 | [diff] [blame] | 1169 | vl_api_connect_sock_reply_t *rmp; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1170 | vnet_connect_args_t _a, *a = &_a; |
Florin Coras | ab2f6db | 2018-08-31 14:31:41 -0700 | [diff] [blame] | 1171 | application_t *app = 0; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1172 | int rv = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1173 | |
Florin Coras | 31c9955 | 2019-03-01 13:00:58 -0800 | [diff] [blame] | 1174 | if (session_main_is_enabled () == 0) |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1175 | { |
| 1176 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 1177 | goto done; |
| 1178 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1179 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1180 | app = application_lookup (mp->client_index); |
| 1181 | if (app) |
| 1182 | { |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 1183 | svm_queue_t *client_q; |
Dave Wallace | b2d5ff3 | 2017-06-14 12:38:28 -0400 | [diff] [blame] | 1184 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 1185 | clib_memset (a, 0, sizeof (*a)); |
Dave Wallace | b2d5ff3 | 2017-06-14 12:38:28 -0400 | [diff] [blame] | 1186 | client_q = vl_api_client_index_to_input_queue (mp->client_index); |
| 1187 | mp->client_queue_address = pointer_to_uword (client_q); |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1188 | ip_address_decode (&mp->ip, &a->sep.ip); |
| 1189 | a->sep.is_ip4 = ip46_address_is_ip4 (&a->sep.ip); |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1190 | a->sep.port = mp->port; |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1191 | a->sep.transport_proto = |
| 1192 | api_session_transport_proto_decode (&mp->proto); |
Florin Coras | 5665ced | 2018-10-25 18:03:45 -0700 | [diff] [blame] | 1193 | a->sep.peer.fib_index = mp->vrf; |
| 1194 | a->sep.peer.sw_if_index = ENDPOINT_INVALID_INDEX; |
Nathan Skrzypczak | 8ac1d6d | 2019-07-17 11:02:20 +0200 | [diff] [blame] | 1195 | a->sep_ext.parent_handle = mp->parent_handle; |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1196 | a->sep_ext.hostname = |
| 1197 | (u8 *) vl_api_from_api_to_new_c_string (&mp->hostname); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1198 | a->api_context = mp->context; |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1199 | a->app_index = app->app_index; |
| 1200 | a->wrk_map_index = mp->wrk_index; |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 1201 | if ((rv = vnet_connect (a))) |
Nathan Skrzypczak | ba65ca4 | 2019-05-16 16:35:40 +0200 | [diff] [blame] | 1202 | clib_warning ("connect returned: %U", format_vnet_api_errno, rv); |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1203 | vec_free (a->sep_ext.hostname); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1204 | } |
| 1205 | else |
| 1206 | { |
| 1207 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 1208 | } |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 1209 | |
Florin Coras | 8f89dd0 | 2018-03-05 16:53:07 -0800 | [diff] [blame] | 1210 | if (rv == 0) |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 1211 | return; |
| 1212 | |
| 1213 | /* Got some error, relay it */ |
| 1214 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1215 | done: |
Florin Coras | 6442401 | 2019-03-02 10:47:47 -0800 | [diff] [blame] | 1216 | REPLY_MACRO (VL_API_CONNECT_SOCK_REPLY); |
Florin Coras | ab2f6db | 2018-08-31 14:31:41 -0700 | [diff] [blame] | 1217 | |
Florin Coras | 6442401 | 2019-03-02 10:47:47 -0800 | [diff] [blame] | 1218 | if (app) |
Florin Coras | ab2f6db | 2018-08-31 14:31:41 -0700 | [diff] [blame] | 1219 | { |
| 1220 | app_worker_t *app_wrk = application_get_worker (app, mp->wrk_index); |
| 1221 | mq_send_session_connected_cb (app_wrk->wrk_index, mp->context, 0, 1); |
| 1222 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1223 | } |
| 1224 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1225 | static void |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1226 | vl_api_app_worker_add_del_t_handler (vl_api_app_worker_add_del_t * mp) |
| 1227 | { |
| 1228 | int rv = 0, fds[SESSION_N_FD_TYPE], n_fds = 0; |
| 1229 | vl_api_app_worker_add_del_reply_t *rmp; |
| 1230 | vl_api_registration_t *reg; |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1231 | application_t *app; |
| 1232 | u8 fd_flags = 0; |
| 1233 | |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1234 | if (session_main_is_enabled () == 0) |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1235 | { |
| 1236 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 1237 | goto done; |
| 1238 | } |
| 1239 | |
| 1240 | reg = vl_api_client_index_to_registration (mp->client_index); |
| 1241 | if (!reg) |
| 1242 | return; |
| 1243 | |
Florin Coras | c1f5a43 | 2018-11-20 11:31:26 -0800 | [diff] [blame] | 1244 | app = application_get_if_valid (clib_net_to_host_u32 (mp->app_index)); |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1245 | if (!app) |
| 1246 | { |
| 1247 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 1248 | goto done; |
| 1249 | } |
| 1250 | |
| 1251 | vnet_app_worker_add_del_args_t args = { |
| 1252 | .app_index = app->app_index, |
Florin Coras | 349f8ca | 2018-11-20 16:52:49 -0800 | [diff] [blame] | 1253 | .wrk_map_index = clib_net_to_host_u32 (mp->wrk_index), |
Florin Coras | c1f5a43 | 2018-11-20 11:31:26 -0800 | [diff] [blame] | 1254 | .api_client_index = mp->client_index, |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1255 | .is_add = mp->is_add |
| 1256 | }; |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 1257 | rv = vnet_app_worker_add_del (&args); |
| 1258 | if (rv) |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1259 | { |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 1260 | clib_warning ("app worker add/del returned: %d", rv); |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1261 | goto done; |
| 1262 | } |
| 1263 | |
Florin Coras | 1459877 | 2018-09-04 19:47:52 -0700 | [diff] [blame] | 1264 | if (!mp->is_add) |
| 1265 | goto done; |
Florin Coras | c3638fe | 2018-08-24 13:58:49 -0700 | [diff] [blame] | 1266 | |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1267 | /* Send fifo segment fd if needed */ |
| 1268 | if (ssvm_type (args.segment) == SSVM_SEGMENT_MEMFD) |
| 1269 | { |
| 1270 | fd_flags |= SESSION_FD_F_MEMFD_SEGMENT; |
| 1271 | fds[n_fds] = args.segment->fd; |
| 1272 | n_fds += 1; |
| 1273 | } |
| 1274 | if (application_segment_manager_properties (app)->use_mq_eventfd) |
| 1275 | { |
| 1276 | fd_flags |= SESSION_FD_F_MQ_EVENTFD; |
| 1277 | fds[n_fds] = svm_msg_q_get_producer_eventfd (args.evt_q); |
| 1278 | n_fds += 1; |
| 1279 | } |
| 1280 | |
| 1281 | /* *INDENT-OFF* */ |
| 1282 | done: |
| 1283 | REPLY_MACRO2 (VL_API_APP_WORKER_ADD_DEL_REPLY, ({ |
| 1284 | rmp->is_add = mp->is_add; |
Florin Coras | 349f8ca | 2018-11-20 16:52:49 -0800 | [diff] [blame] | 1285 | rmp->wrk_index = clib_host_to_net_u32 (args.wrk_map_index); |
Florin Coras | fa76a76 | 2018-11-29 12:40:10 -0800 | [diff] [blame] | 1286 | rmp->segment_handle = clib_host_to_net_u64 (args.segment_handle); |
Florin Coras | 1459877 | 2018-09-04 19:47:52 -0700 | [diff] [blame] | 1287 | if (!rv && mp->is_add) |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1288 | { |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1289 | if (vec_len (args.segment->name)) |
| 1290 | { |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1291 | vl_api_vec_to_api_string (args.segment->name, &rmp->segment_name); |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1292 | } |
| 1293 | rmp->app_event_queue_address = pointer_to_uword (args.evt_q); |
| 1294 | rmp->n_fds = n_fds; |
| 1295 | rmp->fd_flags = fd_flags; |
| 1296 | } |
| 1297 | })); |
| 1298 | /* *INDENT-ON* */ |
| 1299 | |
| 1300 | if (n_fds) |
| 1301 | session_send_fds (reg, fds, n_fds); |
| 1302 | } |
| 1303 | |
| 1304 | static void |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1305 | vl_api_app_namespace_add_del_t_handler (vl_api_app_namespace_add_del_t * mp) |
| 1306 | { |
| 1307 | vl_api_app_namespace_add_del_reply_t *rmp; |
Florin Coras | 6e8c667 | 2017-11-10 09:03:54 -0800 | [diff] [blame] | 1308 | u32 appns_index = 0; |
| 1309 | u8 *ns_id = 0; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1310 | int rv = 0; |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1311 | if (session_main_is_enabled () == 0) |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1312 | { |
| 1313 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 1314 | goto done; |
| 1315 | } |
| 1316 | |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1317 | ns_id = vl_api_from_api_to_new_vec (&mp->namespace_id); |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1318 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1319 | vnet_app_namespace_add_del_args_t args = { |
| 1320 | .ns_id = ns_id, |
Florin Coras | 9a9adb2 | 2017-10-26 08:16:59 -0700 | [diff] [blame] | 1321 | .secret = clib_net_to_host_u64 (mp->secret), |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1322 | .sw_if_index = clib_net_to_host_u32 (mp->sw_if_index), |
| 1323 | .ip4_fib_id = clib_net_to_host_u32 (mp->ip4_fib_id), |
| 1324 | .ip6_fib_id = clib_net_to_host_u32 (mp->ip6_fib_id), |
| 1325 | .is_add = 1 |
| 1326 | }; |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 1327 | rv = vnet_app_namespace_add_del (&args); |
| 1328 | if (!rv) |
Florin Coras | 6e8c667 | 2017-11-10 09:03:54 -0800 | [diff] [blame] | 1329 | { |
| 1330 | appns_index = app_namespace_index_from_id (ns_id); |
| 1331 | if (appns_index == APP_NAMESPACE_INVALID_INDEX) |
| 1332 | { |
| 1333 | clib_warning ("app ns lookup failed"); |
| 1334 | rv = VNET_API_ERROR_UNSPECIFIED; |
| 1335 | } |
| 1336 | } |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1337 | vec_free (ns_id); |
Florin Coras | 6e8c667 | 2017-11-10 09:03:54 -0800 | [diff] [blame] | 1338 | |
| 1339 | /* *INDENT-OFF* */ |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1340 | done: |
Florin Coras | 6e8c667 | 2017-11-10 09:03:54 -0800 | [diff] [blame] | 1341 | REPLY_MACRO2 (VL_API_APP_NAMESPACE_ADD_DEL_REPLY, ({ |
| 1342 | if (!rv) |
| 1343 | rmp->appns_index = clib_host_to_net_u32 (appns_index); |
| 1344 | })); |
| 1345 | /* *INDENT-ON* */ |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 1346 | } |
| 1347 | |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 1348 | static void |
| 1349 | vl_api_session_rule_add_del_t_handler (vl_api_session_rule_add_del_t * mp) |
| 1350 | { |
| 1351 | vl_api_session_rule_add_del_reply_t *rmp; |
| 1352 | session_rule_add_del_args_t args; |
| 1353 | session_rule_table_add_del_args_t *table_args = &args.table_args; |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 1354 | int rv = 0; |
| 1355 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 1356 | clib_memset (&args, 0, sizeof (args)); |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 1357 | |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1358 | ip_prefix_decode (&mp->lcl, &table_args->lcl); |
| 1359 | ip_prefix_decode (&mp->rmt, &table_args->rmt); |
| 1360 | |
Milan Lenco | 8b9a5d1 | 2017-11-24 17:12:33 +0100 | [diff] [blame] | 1361 | table_args->lcl_port = mp->lcl_port; |
| 1362 | table_args->rmt_port = mp->rmt_port; |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 1363 | table_args->action_index = clib_net_to_host_u32 (mp->action_index); |
| 1364 | table_args->is_add = mp->is_add; |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1365 | mp->tag[sizeof (mp->tag) - 1] = 0; |
| 1366 | table_args->tag = format (0, "%s", mp->tag); |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 1367 | args.appns_index = clib_net_to_host_u32 (mp->appns_index); |
| 1368 | args.scope = mp->scope; |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1369 | args.transport_proto = |
| 1370 | api_session_transport_proto_decode (&mp->transport_proto) == |
| 1371 | TRANSPORT_PROTO_UDP ? 1 : 0; |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 1372 | |
Florin Coras | c1a4265 | 2019-02-08 18:27:29 -0800 | [diff] [blame] | 1373 | rv = vnet_session_rule_add_del (&args); |
| 1374 | if (rv) |
| 1375 | clib_warning ("rule add del returned: %d", rv); |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1376 | vec_free (table_args->tag); |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 1377 | REPLY_MACRO (VL_API_SESSION_RULE_ADD_DEL_REPLY); |
| 1378 | } |
| 1379 | |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1380 | static void |
| 1381 | send_session_rule_details4 (mma_rule_16_t * rule, u8 is_local, |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1382 | u8 transport_proto, u32 appns_index, u8 * tag, |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1383 | vl_api_registration_t * reg, u32 context) |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1384 | { |
| 1385 | vl_api_session_rules_details_t *rmp = 0; |
| 1386 | session_mask_or_match_4_t *match = |
| 1387 | (session_mask_or_match_4_t *) & rule->match; |
| 1388 | session_mask_or_match_4_t *mask = |
| 1389 | (session_mask_or_match_4_t *) & rule->mask; |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1390 | fib_prefix_t lcl, rmt; |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1391 | |
| 1392 | rmp = vl_msg_api_alloc (sizeof (*rmp)); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 1393 | clib_memset (rmp, 0, sizeof (*rmp)); |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1394 | rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS); |
| 1395 | rmp->context = context; |
| 1396 | |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1397 | clib_memset (&lcl, 0, sizeof (lcl)); |
| 1398 | clib_memset (&rmt, 0, sizeof (rmt)); |
| 1399 | ip_set (&lcl.fp_addr, &match->lcl_ip, 1); |
| 1400 | ip_set (&rmt.fp_addr, &match->rmt_ip, 1); |
| 1401 | lcl.fp_len = ip4_mask_to_preflen (&mask->lcl_ip); |
| 1402 | rmt.fp_len = ip4_mask_to_preflen (&mask->rmt_ip); |
| 1403 | |
| 1404 | ip_prefix_encode (&lcl, &rmp->lcl); |
| 1405 | ip_prefix_encode (&rmt, &rmp->rmt); |
Milan Lenco | 8b9a5d1 | 2017-11-24 17:12:33 +0100 | [diff] [blame] | 1406 | rmp->lcl_port = match->lcl_port; |
| 1407 | rmp->rmt_port = match->rmt_port; |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1408 | rmp->action_index = clib_host_to_net_u32 (rule->action_index); |
| 1409 | rmp->scope = |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1410 | is_local ? SESSION_RULE_SCOPE_API_LOCAL : SESSION_RULE_SCOPE_API_GLOBAL; |
| 1411 | rmp->transport_proto = api_session_transport_proto_encode (transport_proto); |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1412 | rmp->appns_index = clib_host_to_net_u32 (appns_index); |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1413 | if (tag) |
| 1414 | { |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 1415 | clib_memcpy_fast (rmp->tag, tag, vec_len (tag)); |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1416 | rmp->tag[vec_len (tag)] = 0; |
| 1417 | } |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1418 | |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1419 | vl_api_send_msg (reg, (u8 *) rmp); |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1420 | } |
| 1421 | |
| 1422 | static void |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1423 | send_session_rule_details6 (mma_rule_40_t * rule, u8 is_local, |
| 1424 | u8 transport_proto, u32 appns_index, u8 * tag, |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1425 | vl_api_registration_t * reg, u32 context) |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1426 | { |
| 1427 | vl_api_session_rules_details_t *rmp = 0; |
| 1428 | session_mask_or_match_6_t *match = |
| 1429 | (session_mask_or_match_6_t *) & rule->match; |
| 1430 | session_mask_or_match_6_t *mask = |
| 1431 | (session_mask_or_match_6_t *) & rule->mask; |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1432 | fib_prefix_t lcl, rmt; |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1433 | |
| 1434 | rmp = vl_msg_api_alloc (sizeof (*rmp)); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 1435 | clib_memset (rmp, 0, sizeof (*rmp)); |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1436 | rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS); |
| 1437 | rmp->context = context; |
| 1438 | |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1439 | clib_memset (&lcl, 0, sizeof (lcl)); |
| 1440 | clib_memset (&rmt, 0, sizeof (rmt)); |
| 1441 | ip_set (&lcl.fp_addr, &match->lcl_ip, 0); |
| 1442 | ip_set (&rmt.fp_addr, &match->rmt_ip, 0); |
| 1443 | lcl.fp_len = ip6_mask_to_preflen (&mask->lcl_ip); |
| 1444 | rmt.fp_len = ip6_mask_to_preflen (&mask->rmt_ip); |
| 1445 | |
| 1446 | ip_prefix_encode (&lcl, &rmp->lcl); |
| 1447 | ip_prefix_encode (&rmt, &rmp->rmt); |
Milan Lenco | 8b9a5d1 | 2017-11-24 17:12:33 +0100 | [diff] [blame] | 1448 | rmp->lcl_port = match->lcl_port; |
| 1449 | rmp->rmt_port = match->rmt_port; |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1450 | rmp->action_index = clib_host_to_net_u32 (rule->action_index); |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1451 | rmp->scope = |
Jakub Grajciar | b4e5e50 | 2020-01-31 09:35:29 +0100 | [diff] [blame] | 1452 | is_local ? SESSION_RULE_SCOPE_API_LOCAL : SESSION_RULE_SCOPE_API_GLOBAL; |
| 1453 | rmp->transport_proto = api_session_transport_proto_encode (transport_proto); |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1454 | rmp->appns_index = clib_host_to_net_u32 (appns_index); |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1455 | if (tag) |
| 1456 | { |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 1457 | clib_memcpy_fast (rmp->tag, tag, vec_len (tag)); |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1458 | rmp->tag[vec_len (tag)] = 0; |
| 1459 | } |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1460 | |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1461 | vl_api_send_msg (reg, (u8 *) rmp); |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1462 | } |
| 1463 | |
| 1464 | static void |
| 1465 | send_session_rules_table_details (session_rules_table_t * srt, u8 fib_proto, |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1466 | u8 tp, u8 is_local, u32 appns_index, |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1467 | vl_api_registration_t * reg, u32 context) |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1468 | { |
| 1469 | mma_rule_16_t *rule16; |
| 1470 | mma_rule_40_t *rule40; |
| 1471 | mma_rules_table_16_t *srt16; |
| 1472 | mma_rules_table_40_t *srt40; |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1473 | u32 ri; |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1474 | |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1475 | if (is_local || fib_proto == FIB_PROTOCOL_IP4) |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1476 | { |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1477 | u8 *tag = 0; |
| 1478 | /* *INDENT-OFF* */ |
| 1479 | srt16 = &srt->session_rules_tables_16; |
| 1480 | pool_foreach (rule16, srt16->rules, ({ |
| 1481 | ri = mma_rules_table_rule_index_16 (srt16, rule16); |
| 1482 | tag = session_rules_table_rule_tag (srt, ri, 1); |
| 1483 | send_session_rule_details4 (rule16, is_local, tp, appns_index, tag, |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1484 | reg, context); |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1485 | })); |
| 1486 | /* *INDENT-ON* */ |
| 1487 | } |
| 1488 | if (is_local || fib_proto == FIB_PROTOCOL_IP6) |
| 1489 | { |
| 1490 | u8 *tag = 0; |
| 1491 | /* *INDENT-OFF* */ |
| 1492 | srt40 = &srt->session_rules_tables_40; |
| 1493 | pool_foreach (rule40, srt40->rules, ({ |
| 1494 | ri = mma_rules_table_rule_index_40 (srt40, rule40); |
| 1495 | tag = session_rules_table_rule_tag (srt, ri, 1); |
| 1496 | send_session_rule_details6 (rule40, is_local, tp, appns_index, tag, |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1497 | reg, context); |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1498 | })); |
| 1499 | /* *INDENT-ON* */ |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1500 | } |
| 1501 | } |
| 1502 | |
| 1503 | static void |
| 1504 | vl_api_session_rules_dump_t_handler (vl_api_one_map_server_dump_t * mp) |
| 1505 | { |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1506 | vl_api_registration_t *reg; |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1507 | session_table_t *st; |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1508 | u8 tp; |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1509 | |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1510 | reg = vl_api_client_index_to_registration (mp->client_index); |
| 1511 | if (!reg) |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1512 | return; |
| 1513 | |
| 1514 | /* *INDENT-OFF* */ |
| 1515 | session_table_foreach (st, ({ |
Florin Coras | 07063b8 | 2020-03-13 04:44:51 +0000 | [diff] [blame] | 1516 | for (tp = 0; tp < TRANSPORT_N_PROTOS; tp++) |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1517 | { |
| 1518 | send_session_rules_table_details (&st->session_rules[tp], |
| 1519 | st->active_fib_proto, tp, |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1520 | st->is_local, st->appns_index, reg, |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 1521 | mp->context); |
| 1522 | } |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 1523 | })); |
| 1524 | /* *INDENT-ON* */ |
| 1525 | } |
| 1526 | |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1527 | static void |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1528 | vl_api_app_add_cert_key_pair_t_handler (vl_api_app_add_cert_key_pair_t * mp) |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1529 | { |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1530 | vl_api_app_add_cert_key_pair_reply_t *rmp; |
| 1531 | vnet_app_add_cert_key_pair_args_t _a, *a = &_a; |
| 1532 | u32 certkey_len, key_len, cert_len; |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1533 | int rv = 0; |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1534 | if (session_main_is_enabled () == 0) |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1535 | { |
| 1536 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 1537 | goto done; |
| 1538 | } |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1539 | |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1540 | cert_len = clib_net_to_host_u16 (mp->cert_len); |
Florin Coras | 5090c57 | 2018-03-18 08:22:17 -0700 | [diff] [blame] | 1541 | if (cert_len > 10000) |
| 1542 | { |
| 1543 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 1544 | goto done; |
| 1545 | } |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1546 | |
| 1547 | certkey_len = clib_net_to_host_u16 (mp->certkey_len); |
| 1548 | if (certkey_len < cert_len) |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1549 | { |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1550 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 1551 | goto done; |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1552 | } |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1553 | |
| 1554 | key_len = certkey_len - cert_len; |
| 1555 | if (key_len > 10000) |
| 1556 | { |
| 1557 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 1558 | goto done; |
| 1559 | } |
| 1560 | |
| 1561 | clib_memset (a, 0, sizeof (*a)); |
| 1562 | vec_validate (a->cert, cert_len); |
| 1563 | vec_validate (a->key, key_len); |
| 1564 | clib_memcpy_fast (a->cert, mp->certkey, cert_len); |
| 1565 | clib_memcpy_fast (a->key, mp->certkey + cert_len, key_len); |
| 1566 | rv = vnet_app_add_cert_key_pair (a); |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1567 | vec_free (a->cert); |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1568 | vec_free (a->key); |
| 1569 | |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1570 | done: |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1571 | /* *INDENT-OFF* */ |
| 1572 | REPLY_MACRO2 (VL_API_APP_ADD_CERT_KEY_PAIR_REPLY, ({ |
| 1573 | if (!rv) |
Nathan Skrzypczak | 45ec9f4 | 2019-11-06 14:47:40 +0100 | [diff] [blame] | 1574 | rmp->index = clib_host_to_net_u32 (a->index); |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1575 | })); |
| 1576 | /* *INDENT-ON* */ |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1577 | } |
| 1578 | |
| 1579 | static void |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1580 | vl_api_app_del_cert_key_pair_t_handler (vl_api_app_del_cert_key_pair_t * mp) |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1581 | { |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1582 | vl_api_app_del_cert_key_pair_reply_t *rmp; |
Nathan Skrzypczak | 45ec9f4 | 2019-11-06 14:47:40 +0100 | [diff] [blame] | 1583 | u32 ckpair_index; |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1584 | int rv = 0; |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1585 | if (session_main_is_enabled () == 0) |
| 1586 | { |
| 1587 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 1588 | goto done; |
| 1589 | } |
Nathan Skrzypczak | 45ec9f4 | 2019-11-06 14:47:40 +0100 | [diff] [blame] | 1590 | ckpair_index = clib_net_to_host_u32 (mp->index); |
| 1591 | rv = vnet_app_del_cert_key_pair (ckpair_index); |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1592 | |
| 1593 | done: |
Nathan Skrzypczak | 45ec9f4 | 2019-11-06 14:47:40 +0100 | [diff] [blame] | 1594 | REPLY_MACRO (VL_API_APP_DEL_CERT_KEY_PAIR_REPLY); |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1595 | } |
| 1596 | |
| 1597 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
| 1598 | static void |
| 1599 | vl_api_application_tls_cert_add_t_handler (vl_api_application_tls_cert_add_t * |
| 1600 | mp) |
| 1601 | { |
| 1602 | vl_api_application_tls_cert_add_reply_t *rmp; |
| 1603 | app_cert_key_pair_t *ckpair; |
| 1604 | application_t *app; |
| 1605 | u32 cert_len; |
| 1606 | int rv = 0; |
| 1607 | if (session_main_is_enabled () == 0) |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1608 | { |
| 1609 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 1610 | goto done; |
| 1611 | } |
Florin Coras | e3e2f07 | 2018-03-04 07:24:30 -0800 | [diff] [blame] | 1612 | if (!(app = application_lookup (mp->client_index))) |
| 1613 | { |
| 1614 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 1615 | goto done; |
| 1616 | } |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1617 | cert_len = clib_net_to_host_u16 (mp->cert_len); |
| 1618 | if (cert_len > 10000) |
| 1619 | { |
| 1620 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 1621 | goto done; |
| 1622 | } |
| 1623 | ckpair = app_cert_key_pair_get_default (); |
| 1624 | vec_validate (ckpair->cert, cert_len); |
| 1625 | clib_memcpy_fast (ckpair->cert, mp->cert, cert_len); |
| 1626 | |
| 1627 | done: |
| 1628 | REPLY_MACRO (VL_API_APPLICATION_TLS_CERT_ADD_REPLY); |
| 1629 | } |
| 1630 | |
| 1631 | /* ### WILL BE DEPRECATED POST 20.01 ### */ |
| 1632 | static void |
| 1633 | vl_api_application_tls_key_add_t_handler (vl_api_application_tls_key_add_t * |
| 1634 | mp) |
| 1635 | { |
| 1636 | vl_api_application_tls_key_add_reply_t *rmp; |
| 1637 | app_cert_key_pair_t *ckpair; |
| 1638 | application_t *app; |
| 1639 | u32 key_len; |
| 1640 | int rv = 0; |
| 1641 | if (session_main_is_enabled () == 0) |
| 1642 | { |
| 1643 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 1644 | goto done; |
| 1645 | } |
| 1646 | if (!(app = application_lookup (mp->client_index))) |
| 1647 | { |
| 1648 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 1649 | goto done; |
| 1650 | } |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1651 | key_len = clib_net_to_host_u16 (mp->key_len); |
Florin Coras | 5090c57 | 2018-03-18 08:22:17 -0700 | [diff] [blame] | 1652 | if (key_len > 10000) |
| 1653 | { |
| 1654 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 1655 | goto done; |
| 1656 | } |
Nathan Skrzypczak | 79f8953 | 2019-09-13 11:08:13 +0200 | [diff] [blame] | 1657 | ckpair = app_cert_key_pair_get_default (); |
| 1658 | vec_validate (ckpair->key, key_len); |
| 1659 | clib_memcpy_fast (ckpair->key, mp->key, key_len); |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 1660 | done: |
| 1661 | REPLY_MACRO (VL_API_APPLICATION_TLS_KEY_ADD_REPLY); |
| 1662 | } |
| 1663 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1664 | static clib_error_t * |
| 1665 | application_reaper_cb (u32 client_index) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1666 | { |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1667 | application_t *app = application_lookup (client_index); |
| 1668 | vnet_app_detach_args_t _a, *a = &_a; |
| 1669 | if (app) |
| 1670 | { |
Florin Coras | 1553197 | 2018-08-12 23:50:53 -0700 | [diff] [blame] | 1671 | a->app_index = app->app_index; |
Florin Coras | 053a0e4 | 2018-11-13 15:52:38 -0800 | [diff] [blame] | 1672 | a->api_client_index = client_index; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1673 | vnet_application_detach (a); |
| 1674 | } |
| 1675 | return 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1676 | } |
| 1677 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1678 | VL_MSG_API_REAPER_FUNCTION (application_reaper_cb); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1679 | |
| 1680 | #define vl_msg_name_crc_list |
| 1681 | #include <vnet/vnet_all_api_h.h> |
| 1682 | #undef vl_msg_name_crc_list |
| 1683 | |
| 1684 | static void |
| 1685 | setup_message_id_table (api_main_t * am) |
| 1686 | { |
| 1687 | #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); |
| 1688 | foreach_vl_msg_name_crc_session; |
| 1689 | #undef _ |
| 1690 | } |
| 1691 | |
| 1692 | /* |
| 1693 | * session_api_hookup |
| 1694 | * Add uri's API message handlers to the table. |
Jim Thompson | f324dec | 2019-04-08 03:22:21 -0500 | [diff] [blame] | 1695 | * vlib has already mapped shared memory and |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1696 | * added the client registration handlers. |
| 1697 | * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process() |
| 1698 | */ |
| 1699 | static clib_error_t * |
| 1700 | session_api_hookup (vlib_main_t * vm) |
| 1701 | { |
Dave Barach | 39d6911 | 2019-11-27 11:42:13 -0500 | [diff] [blame] | 1702 | api_main_t *am = vlibapi_get_main (); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1703 | |
| 1704 | #define _(N,n) \ |
| 1705 | vl_msg_api_set_handlers(VL_API_##N, #n, \ |
| 1706 | vl_api_##n##_t_handler, \ |
| 1707 | vl_noop_handler, \ |
| 1708 | vl_api_##n##_t_endian, \ |
| 1709 | vl_api_##n##_t_print, \ |
| 1710 | sizeof(vl_api_##n##_t), 1); |
| 1711 | foreach_session_api_msg; |
| 1712 | #undef _ |
| 1713 | |
| 1714 | /* |
| 1715 | * Messages which bounce off the data-plane to |
| 1716 | * an API client. Simply tells the message handling infra not |
| 1717 | * to free the message. |
| 1718 | * |
| 1719 | * Bounced message handlers MUST NOT block the data plane |
| 1720 | */ |
| 1721 | am->message_bounce[VL_API_CONNECT_URI] = 1; |
| 1722 | am->message_bounce[VL_API_CONNECT_SOCK] = 1; |
| 1723 | |
| 1724 | /* |
| 1725 | * Set up the (msg_name, crc, message-id) table |
| 1726 | */ |
| 1727 | setup_message_id_table (am); |
| 1728 | |
| 1729 | return 0; |
| 1730 | } |
| 1731 | |
| 1732 | VLIB_API_INIT_FUNCTION (session_api_hookup); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1733 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1734 | /* |
| 1735 | * fd.io coding-style-patch-verification: ON |
| 1736 | * |
| 1737 | * Local Variables: |
| 1738 | * eval: (c-set-style "gnu") |
| 1739 | * End: |
| 1740 | */ |