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