Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * builtin_client.c - vpp built-in tcp client/connect code |
| 3 | * |
| 4 | * Copyright (c) 2017 by Cisco and/or its affiliates. |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include <vnet/vnet.h> |
| 19 | #include <vnet/plugin/plugin.h> |
| 20 | #include <vnet/tcp/builtin_client.h> |
| 21 | |
| 22 | #include <vlibapi/api.h> |
| 23 | #include <vlibmemory/api.h> |
| 24 | #include <vlibsocket/api.h> |
| 25 | #include <vpp/app/version.h> |
| 26 | |
| 27 | /* define message IDs */ |
| 28 | #include <vpp/api/vpe_msg_enum.h> |
| 29 | |
| 30 | /* define message structures */ |
| 31 | #define vl_typedefs |
| 32 | #include <vpp/api/vpe_all_api_h.h> |
| 33 | #undef vl_typedefs |
| 34 | |
| 35 | /* define generated endian-swappers */ |
| 36 | #define vl_endianfun |
| 37 | #include <vpp/api/vpe_all_api_h.h> |
| 38 | #undef vl_endianfun |
| 39 | |
| 40 | /* instantiate all the print functions we know about */ |
| 41 | #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) |
| 42 | #define vl_printfun |
| 43 | #include <vpp/api/vpe_all_api_h.h> |
| 44 | #undef vl_printfun |
| 45 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 46 | #define TCP_BUILTIN_CLIENT_DBG (0) |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 47 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 48 | static void |
| 49 | send_test_chunk (tclient_main_t * tm, session_t * s) |
| 50 | { |
| 51 | u8 *test_data = tm->connect_test_data; |
Dave Barach | 45ce3fb | 2017-03-28 12:31:33 -0400 | [diff] [blame] | 52 | int test_buf_offset; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 53 | u32 bytes_this_chunk; |
| 54 | session_fifo_event_t evt; |
| 55 | static int serial_number = 0; |
| 56 | int rv; |
Florin Coras | 82b13a8 | 2017-04-25 11:58:06 -0700 | [diff] [blame] | 57 | |
| 58 | ASSERT (vec_len (test_data) > 0); |
| 59 | |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 60 | test_buf_offset = s->bytes_sent % vec_len (test_data); |
| 61 | bytes_this_chunk = vec_len (test_data) - test_buf_offset; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 62 | |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 63 | bytes_this_chunk = bytes_this_chunk < s->bytes_to_send |
| 64 | ? bytes_this_chunk : s->bytes_to_send; |
| 65 | |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 66 | rv = svm_fifo_enqueue_nowait (s->server_tx_fifo, bytes_this_chunk, |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 67 | test_data + test_buf_offset); |
| 68 | |
| 69 | /* If we managed to enqueue data... */ |
| 70 | if (rv > 0) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 71 | { |
Dave Barach | 0194f1a | 2017-05-15 10:11:39 -0400 | [diff] [blame] | 72 | /* Account for it... */ |
| 73 | s->bytes_to_send -= rv; |
| 74 | s->bytes_sent += rv; |
| 75 | |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 76 | if (TCP_BUILTIN_CLIENT_DBG) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 77 | { |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 78 | /* *INDENT-OFF* */ |
| 79 | ELOG_TYPE_DECLARE (e) = |
| 80 | { |
Dave Barach | 0194f1a | 2017-05-15 10:11:39 -0400 | [diff] [blame] | 81 | .format = "tx-enq: xfer %d bytes, sent %u remain %u", |
| 82 | .format_args = "i4i4i4", |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 83 | }; |
| 84 | /* *INDENT-ON* */ |
| 85 | struct |
| 86 | { |
Dave Barach | 0194f1a | 2017-05-15 10:11:39 -0400 | [diff] [blame] | 87 | u32 data[3]; |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 88 | } *ed; |
| 89 | ed = ELOG_DATA (&vlib_global_main.elog_main, e); |
| 90 | ed->data[0] = rv; |
Dave Barach | 0194f1a | 2017-05-15 10:11:39 -0400 | [diff] [blame] | 91 | ed->data[1] = s->bytes_sent; |
| 92 | ed->data[2] = s->bytes_to_send; |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 93 | } |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 94 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 95 | /* Poke the session layer */ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 96 | if (svm_fifo_set_event (s->server_tx_fifo)) |
| 97 | { |
| 98 | /* Fabricate TX event, send to vpp */ |
| 99 | evt.fifo = s->server_tx_fifo; |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 100 | evt.event_type = FIFO_EVENT_APP_TX; |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 101 | evt.event_id = serial_number++; |
| 102 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 103 | if (unix_shared_memory_queue_add (tm->vpp_event_queue, (u8 *) & evt, |
| 104 | 0 /* do wait for mutex */ )) |
| 105 | clib_warning ("could not enqueue event"); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | static void |
| 111 | receive_test_chunk (tclient_main_t * tm, session_t * s) |
| 112 | { |
| 113 | svm_fifo_t *rx_fifo = s->server_rx_fifo; |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 114 | int n_read, test_bytes = 0; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 115 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 116 | /* Allow enqueuing of new event */ |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 117 | // svm_fifo_unset_event (rx_fifo); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 118 | |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 119 | if (test_bytes) |
| 120 | { |
| 121 | n_read = svm_fifo_dequeue_nowait (rx_fifo, vec_len (tm->rx_buf), |
| 122 | tm->rx_buf); |
| 123 | } |
| 124 | else |
| 125 | { |
| 126 | n_read = svm_fifo_max_dequeue (rx_fifo); |
| 127 | svm_fifo_dequeue_drop (rx_fifo, n_read); |
| 128 | } |
| 129 | |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 130 | if (n_read > 0) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 131 | { |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 132 | if (TCP_BUILTIN_CLIENT_DBG) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 133 | { |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 134 | /* *INDENT-OFF* */ |
| 135 | ELOG_TYPE_DECLARE (e) = |
| 136 | { |
| 137 | .format = "rx-deq: %d bytes", |
| 138 | .format_args = "i4", |
| 139 | }; |
| 140 | /* *INDENT-ON* */ |
| 141 | struct |
| 142 | { |
| 143 | u32 data[1]; |
| 144 | } *ed; |
| 145 | ed = ELOG_DATA (&vlib_global_main.elog_main, e); |
| 146 | ed->data[0] = n_read; |
| 147 | } |
| 148 | |
| 149 | if (test_bytes) |
| 150 | { |
| 151 | int i; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 152 | for (i = 0; i < n_read; i++) |
| 153 | { |
| 154 | if (tm->rx_buf[i] != ((s->bytes_received + i) & 0xff)) |
| 155 | { |
| 156 | clib_warning ("read %d error at byte %lld, 0x%x not 0x%x", |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 157 | n_read, s->bytes_received + i, tm->rx_buf[i], |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 158 | ((s->bytes_received + i) & 0xff)); |
| 159 | } |
| 160 | } |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 161 | } |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 162 | s->bytes_to_receive -= n_read; |
| 163 | s->bytes_received += n_read; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 164 | } |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 167 | static uword |
| 168 | builtin_client_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 169 | vlib_frame_t * frame) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 170 | { |
| 171 | tclient_main_t *tm = &tclient_main; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 172 | int my_thread_index = vlib_get_thread_index (); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 173 | vl_api_disconnect_session_t *dmp; |
| 174 | session_t *sp; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 175 | int i; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 176 | int delete_session; |
| 177 | u32 *connection_indices; |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 178 | u32 tx_quota = 0; |
| 179 | u32 delta, prev_bytes_received_this_session; |
Dave Barach | 0194f1a | 2017-05-15 10:11:39 -0400 | [diff] [blame] | 180 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 181 | connection_indices = tm->connection_index_by_thread[my_thread_index]; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 182 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 183 | if (tm->run_test == 0 || vec_len (connection_indices) == 0) |
| 184 | return 0; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 185 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 186 | for (i = 0; i < vec_len (connection_indices); i++) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 187 | { |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 188 | delete_session = 1; |
| 189 | |
| 190 | sp = pool_elt_at_index (tm->sessions, connection_indices[i]); |
| 191 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 192 | if ((tm->no_return || tx_quota < 60) && sp->bytes_to_send > 0) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 193 | { |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 194 | send_test_chunk (tm, sp); |
| 195 | delete_session = 0; |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 196 | tx_quota++; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 197 | } |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 198 | if (!tm->no_return && sp->bytes_to_receive > 0) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 199 | { |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 200 | prev_bytes_received_this_session = sp->bytes_received; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 201 | receive_test_chunk (tm, sp); |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 202 | delta = sp->bytes_received - prev_bytes_received_this_session; |
| 203 | if (delta > 0) |
| 204 | tx_quota--; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 205 | delete_session = 0; |
| 206 | } |
| 207 | if (PREDICT_FALSE (delete_session == 1)) |
| 208 | { |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 209 | __sync_fetch_and_add (&tm->tx_total, tm->bytes_to_send); |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 210 | __sync_fetch_and_add (&tm->rx_total, sp->bytes_received); |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 211 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 212 | dmp = vl_msg_api_alloc_as_if_client (sizeof (*dmp)); |
| 213 | memset (dmp, 0, sizeof (*dmp)); |
| 214 | dmp->_vl_msg_id = ntohs (VL_API_DISCONNECT_SESSION); |
| 215 | dmp->client_index = tm->my_client_index; |
| 216 | dmp->handle = sp->vpp_session_handle; |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 217 | if (!unix_shared_memory_queue_add (tm->vl_input_queue, (u8 *) & dmp, |
| 218 | 1)) |
| 219 | { |
| 220 | vec_delete (connection_indices, 1, i); |
| 221 | tm->connection_index_by_thread[my_thread_index] = |
| 222 | connection_indices; |
| 223 | __sync_fetch_and_add (&tm->ready_connections, -1); |
| 224 | } |
| 225 | else |
| 226 | { |
| 227 | vl_msg_api_free (dmp); |
| 228 | } |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 229 | |
| 230 | /* Kick the debug CLI process */ |
| 231 | if (tm->ready_connections == 0) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 232 | { |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 233 | tm->test_end_time = vlib_time_now (vm); |
| 234 | vlib_process_signal_event (vm, tm->cli_node_index, |
| 235 | 2, 0 /* data */ ); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 236 | } |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 237 | } |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 238 | } |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 239 | return 0; |
| 240 | } |
| 241 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 242 | /* *INDENT-OFF* */ |
| 243 | VLIB_REGISTER_NODE (builtin_client_node) = |
| 244 | { |
| 245 | .function = builtin_client_node_fn, |
| 246 | .name = "builtin-tcp-client", |
| 247 | .type = VLIB_NODE_TYPE_INPUT, |
| 248 | .state = VLIB_NODE_STATE_DISABLED, |
| 249 | }; |
| 250 | /* *INDENT-ON* */ |
| 251 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 252 | /* So we don't get "no handler for... " msgs */ |
| 253 | static void |
| 254 | vl_api_memclnt_create_reply_t_handler (vl_api_memclnt_create_reply_t * mp) |
| 255 | { |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 256 | vlib_main_t *vm = vlib_get_main (); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 257 | tclient_main_t *tm = &tclient_main; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 258 | tm->my_client_index = mp->index; |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 259 | vlib_process_signal_event (vm, tm->cli_node_index, 1 /* evt */ , |
Dave Barach | 0194f1a | 2017-05-15 10:11:39 -0400 | [diff] [blame] | 260 | 0 /* data */ ); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 261 | } |
| 262 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 263 | static int |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 264 | create_api_loopback (tclient_main_t * tm) |
| 265 | { |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 266 | vlib_main_t *vm = vlib_get_main (); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 267 | vl_api_memclnt_create_t _m, *mp = &_m; |
| 268 | extern void vl_api_memclnt_create_t_handler (vl_api_memclnt_create_t *); |
| 269 | api_main_t *am = &api_main; |
| 270 | vl_shmem_hdr_t *shmem_hdr; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 271 | uword *event_data = 0, event_type; |
| 272 | int resolved = 0; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 273 | |
| 274 | /* |
| 275 | * Create a "loopback" API client connection |
| 276 | * Don't do things like this unless you know what you're doing... |
| 277 | */ |
| 278 | |
| 279 | shmem_hdr = am->shmem_hdr; |
| 280 | tm->vl_input_queue = shmem_hdr->vl_input_queue; |
| 281 | memset (mp, 0, sizeof (*mp)); |
| 282 | mp->_vl_msg_id = VL_API_MEMCLNT_CREATE; |
| 283 | mp->context = 0xFEEDFACE; |
Damjan Marion | 7bee80c | 2017-04-26 15:32:12 +0200 | [diff] [blame] | 284 | mp->input_queue = pointer_to_uword (tm->vl_input_queue); |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 285 | strncpy ((char *) mp->name, "tcp_clients_tester", sizeof (mp->name) - 1); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 286 | |
| 287 | vl_api_memclnt_create_t_handler (mp); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 288 | |
| 289 | /* Wait for reply */ |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 290 | vlib_process_wait_for_event_or_clock (vm, 1.0); |
| 291 | event_type = vlib_process_get_events (vm, &event_data); |
| 292 | switch (event_type) |
| 293 | { |
| 294 | case 1: |
| 295 | resolved = 1; |
| 296 | break; |
| 297 | case ~0: |
| 298 | /* timed out */ |
| 299 | break; |
| 300 | default: |
| 301 | clib_warning ("unknown event_type %d", event_type); |
| 302 | } |
| 303 | if (!resolved) |
| 304 | return -1; |
| 305 | return 0; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | #define foreach_tclient_static_api_msg \ |
| 309 | _(MEMCLNT_CREATE_REPLY, memclnt_create_reply) \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 310 | |
| 311 | static clib_error_t * |
| 312 | tclient_api_hookup (vlib_main_t * vm) |
| 313 | { |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 314 | vl_msg_api_msg_config_t _c, *c = &_c; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 315 | |
| 316 | /* Hook up client-side static APIs to our handlers */ |
| 317 | #define _(N,n) do { \ |
| 318 | c->id = VL_API_##N; \ |
| 319 | c->name = #n; \ |
| 320 | c->handler = vl_api_##n##_t_handler; \ |
| 321 | c->cleanup = vl_noop_handler; \ |
| 322 | c->endian = vl_api_##n##_t_endian; \ |
| 323 | c->print = vl_api_##n##_t_print; \ |
| 324 | c->size = sizeof(vl_api_##n##_t); \ |
| 325 | c->traced = 1; /* trace, so these msgs print */ \ |
| 326 | c->replay = 0; /* don't replay client create/delete msgs */ \ |
| 327 | c->message_bounce = 0; /* don't bounce this message */ \ |
| 328 | vl_msg_api_config(c);} while (0); |
| 329 | |
| 330 | foreach_tclient_static_api_msg; |
| 331 | #undef _ |
| 332 | |
| 333 | return 0; |
| 334 | } |
| 335 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 336 | static int |
| 337 | tcp_test_clients_init (vlib_main_t * vm) |
| 338 | { |
| 339 | tclient_main_t *tm = &tclient_main; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 340 | vlib_thread_main_t *thread_main = vlib_get_thread_main (); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 341 | int i; |
| 342 | |
| 343 | tclient_api_hookup (vm); |
| 344 | if (create_api_loopback (tm)) |
| 345 | return -1; |
| 346 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 347 | /* Init test data. Big buffer */ |
| 348 | vec_validate (tm->connect_test_data, 1024 * 1024 - 1); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 349 | for (i = 0; i < vec_len (tm->connect_test_data); i++) |
| 350 | tm->connect_test_data[i] = i & 0xff; |
| 351 | |
| 352 | tm->session_index_by_vpp_handles = hash_create (0, sizeof (uword)); |
| 353 | vec_validate (tm->rx_buf, vec_len (tm->connect_test_data) - 1); |
| 354 | |
| 355 | tm->is_init = 1; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 356 | tm->vlib_main = vm; |
| 357 | |
| 358 | vec_validate (tm->connection_index_by_thread, thread_main->n_vlib_mains); |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | static int |
| 363 | builtin_session_connected_callback (u32 app_index, u32 api_context, |
| 364 | stream_session_t * s, u8 is_fail) |
| 365 | { |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 366 | tclient_main_t *tm = &tclient_main; |
| 367 | session_t *session; |
| 368 | u32 session_index; |
| 369 | int i; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 370 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 371 | if (is_fail) |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 372 | { |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 373 | clib_warning ("connection %d failed!", api_context); |
| 374 | vlib_process_signal_event (tm->vlib_main, tm->cli_node_index, -1, |
| 375 | 0 /* data */ ); |
| 376 | return -1; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 377 | } |
| 378 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 379 | /* Mark vpp session as connected */ |
| 380 | s->session_state = SESSION_STATE_READY; |
| 381 | |
| 382 | tm->our_event_queue = session_manager_get_vpp_event_queue (s->thread_index); |
| 383 | tm->vpp_event_queue = session_manager_get_vpp_event_queue (s->thread_index); |
| 384 | |
| 385 | /* |
| 386 | * Setup session |
| 387 | */ |
| 388 | pool_get (tm->sessions, session); |
| 389 | memset (session, 0, sizeof (*session)); |
| 390 | session_index = session - tm->sessions; |
| 391 | session->bytes_to_receive = session->bytes_to_send = tm->bytes_to_send; |
| 392 | session->server_rx_fifo = s->server_rx_fifo; |
| 393 | session->server_rx_fifo->client_session_index = session_index; |
| 394 | session->server_tx_fifo = s->server_tx_fifo; |
| 395 | session->server_tx_fifo->client_session_index = session_index; |
| 396 | session->vpp_session_handle = stream_session_handle (s); |
| 397 | |
| 398 | /* Add it to the session lookup table */ |
| 399 | hash_set (tm->session_index_by_vpp_handles, session->vpp_session_handle, |
| 400 | session_index); |
| 401 | |
| 402 | if (tm->ready_connections == tm->expected_connections - 1) |
| 403 | { |
| 404 | vlib_thread_main_t *thread_main = vlib_get_thread_main (); |
| 405 | int thread_index; |
| 406 | |
| 407 | thread_index = 0; |
| 408 | for (i = 0; i < pool_elts (tm->sessions); i++) |
| 409 | { |
| 410 | vec_add1 (tm->connection_index_by_thread[thread_index], i); |
| 411 | thread_index++; |
| 412 | if (thread_index == thread_main->n_vlib_mains) |
| 413 | thread_index = 0; |
| 414 | } |
| 415 | } |
| 416 | __sync_fetch_and_add (&tm->ready_connections, 1); |
| 417 | if (tm->ready_connections == tm->expected_connections) |
| 418 | { |
| 419 | tm->run_test = 1; |
| 420 | tm->test_start_time = vlib_time_now (tm->vlib_main); |
| 421 | /* Signal the CLI process that the action is starting... */ |
| 422 | vlib_process_signal_event (tm->vlib_main, tm->cli_node_index, 1, |
| 423 | 0 /* data */ ); |
| 424 | } |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 425 | |
| 426 | return 0; |
| 427 | } |
| 428 | |
| 429 | static void |
| 430 | builtin_session_reset_callback (stream_session_t * s) |
| 431 | { |
| 432 | return; |
| 433 | } |
| 434 | |
| 435 | static int |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 436 | builtin_session_create_callback (stream_session_t * s) |
| 437 | { |
| 438 | return 0; |
| 439 | } |
| 440 | |
| 441 | static void |
| 442 | builtin_session_disconnect_callback (stream_session_t * s) |
| 443 | { |
| 444 | return; |
| 445 | } |
| 446 | |
| 447 | static int |
| 448 | builtin_server_rx_callback (stream_session_t * s) |
| 449 | { |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | /* *INDENT-OFF* */ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 454 | static session_cb_vft_t builtin_clients = { |
| 455 | .session_reset_callback = builtin_session_reset_callback, |
| 456 | .session_connected_callback = builtin_session_connected_callback, |
| 457 | .session_accept_callback = builtin_session_create_callback, |
| 458 | .session_disconnect_callback = builtin_session_disconnect_callback, |
| 459 | .builtin_server_rx_callback = builtin_server_rx_callback |
| 460 | }; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 461 | /* *INDENT-ON* */ |
| 462 | |
| 463 | static int |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 464 | attach_builtin_test_clients_app (void) |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 465 | { |
Dave Barach | 0194f1a | 2017-05-15 10:11:39 -0400 | [diff] [blame] | 466 | tclient_main_t *tm = &tclient_main; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 467 | vnet_app_attach_args_t _a, *a = &_a; |
| 468 | u8 segment_name[128]; |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 469 | u32 segment_name_length, prealloc_fifos; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 470 | u64 options[16]; |
| 471 | |
| 472 | segment_name_length = ARRAY_LEN (segment_name); |
| 473 | |
| 474 | memset (a, 0, sizeof (*a)); |
| 475 | memset (options, 0, sizeof (options)); |
| 476 | |
Dave Barach | 0194f1a | 2017-05-15 10:11:39 -0400 | [diff] [blame] | 477 | a->api_client_index = tm->my_client_index; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 478 | a->segment_name = segment_name; |
| 479 | a->segment_name_length = segment_name_length; |
| 480 | a->session_cb_vft = &builtin_clients; |
| 481 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 482 | prealloc_fifos = tm->prealloc_fifos ? tm->expected_connections : 1; |
| 483 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 484 | options[SESSION_OPTIONS_ACCEPT_COOKIE] = 0x12345678; |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 485 | options[SESSION_OPTIONS_SEGMENT_SIZE] = (2ULL << 32); |
| 486 | options[SESSION_OPTIONS_RX_FIFO_SIZE] = tm->fifo_size; |
| 487 | options[SESSION_OPTIONS_TX_FIFO_SIZE] = tm->fifo_size / 2; |
| 488 | options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = prealloc_fifos; |
| 489 | |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 490 | options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_BUILTIN_APP; |
| 491 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 492 | a->options = options; |
| 493 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 494 | if (vnet_application_attach (a)) |
| 495 | return -1; |
| 496 | |
| 497 | tm->app_index = a->app_index; |
| 498 | return 0; |
| 499 | } |
| 500 | |
| 501 | static void * |
| 502 | tclient_thread_fn (void *arg) |
| 503 | { |
| 504 | return 0; |
| 505 | } |
| 506 | |
| 507 | /** Start a transmit thread */ |
| 508 | int |
| 509 | start_tx_pthread (tclient_main_t * tm) |
| 510 | { |
| 511 | if (tm->client_thread_handle == 0) |
| 512 | { |
| 513 | int rv = pthread_create (&tm->client_thread_handle, |
| 514 | NULL /*attr */ , |
| 515 | tclient_thread_fn, 0); |
| 516 | if (rv) |
| 517 | { |
| 518 | tm->client_thread_handle = 0; |
| 519 | return -1; |
| 520 | } |
| 521 | } |
| 522 | return 0; |
| 523 | } |
| 524 | |
| 525 | void |
| 526 | clients_connect (vlib_main_t * vm, u8 * uri, u32 n_clients) |
| 527 | { |
| 528 | tclient_main_t *tm = &tclient_main; |
| 529 | vnet_connect_args_t _a, *a = &_a; |
| 530 | int i; |
| 531 | for (i = 0; i < n_clients; i++) |
| 532 | { |
| 533 | memset (a, 0, sizeof (*a)); |
| 534 | |
| 535 | a->uri = (char *) uri; |
| 536 | a->api_context = i; |
| 537 | a->app_index = tm->app_index; |
| 538 | a->mp = 0; |
| 539 | vnet_connect_uri (a); |
| 540 | |
| 541 | /* Crude pacing for call setups, 100k/sec */ |
| 542 | vlib_process_suspend (vm, 10e-6); |
| 543 | } |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 544 | } |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 545 | |
| 546 | static clib_error_t * |
| 547 | test_tcp_clients_command_fn (vlib_main_t * vm, |
| 548 | unformat_input_t * input, |
| 549 | vlib_cli_command_t * cmd) |
| 550 | { |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 551 | tclient_main_t *tm = &tclient_main; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 552 | vlib_thread_main_t *thread_main = vlib_get_thread_main (); |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 553 | uword *event_data = 0, event_type; |
| 554 | u8 *default_connect_uri = (u8 *) "tcp://6.0.1.1/1234", *uri; |
| 555 | u64 tmp, total_bytes; |
| 556 | f64 cli_timeout = 20.0, delta; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 557 | u32 n_clients = 1; |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 558 | char *transfer_type; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 559 | int i; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 560 | |
| 561 | tm->bytes_to_send = 8192; |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 562 | tm->no_return = 0; |
| 563 | tm->fifo_size = 64 << 10; |
| 564 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 565 | vec_free (tm->connect_uri); |
| 566 | |
| 567 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 568 | { |
| 569 | if (unformat (input, "nclients %d", &n_clients)) |
| 570 | ; |
Dave Barach | 0194f1a | 2017-05-15 10:11:39 -0400 | [diff] [blame] | 571 | else if (unformat (input, "mbytes %lld", &tmp)) |
| 572 | tm->bytes_to_send = tmp << 20; |
| 573 | else if (unformat (input, "gbytes %lld", &tmp)) |
| 574 | tm->bytes_to_send = tmp << 30; |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 575 | else if (unformat (input, "bytes %lld", &tm->bytes_to_send)) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 576 | ; |
| 577 | else if (unformat (input, "uri %s", &tm->connect_uri)) |
| 578 | ; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 579 | else if (unformat (input, "cli-timeout %f", &cli_timeout)) |
| 580 | ; |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 581 | else if (unformat (input, "no-return")) |
| 582 | tm->no_return = 1; |
| 583 | else if (unformat (input, "fifo-size %d", &tm->fifo_size)) |
| 584 | tm->fifo_size <<= 10; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 585 | else |
| 586 | return clib_error_return (0, "unknown input `%U'", |
| 587 | format_unformat_error, input); |
| 588 | } |
| 589 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 590 | /* Store cli process node index for signalling */ |
| 591 | tm->cli_node_index = vlib_get_current_process (vm)->node_runtime.node_index; |
| 592 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 593 | if (tm->is_init == 0) |
| 594 | { |
| 595 | if (tcp_test_clients_init (vm)) |
| 596 | return clib_error_return (0, "failed init"); |
| 597 | } |
| 598 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 599 | tm->ready_connections = 0; |
| 600 | tm->expected_connections = n_clients; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 601 | tm->rx_total = 0; |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 602 | tm->tx_total = 0; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 603 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 604 | uri = default_connect_uri; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 605 | if (tm->connect_uri) |
| 606 | uri = tm->connect_uri; |
| 607 | |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 608 | #if TCP_BUILTIN_CLIENT_PTHREAD |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 609 | start_tx_pthread (); |
| 610 | #endif |
| 611 | |
| 612 | vnet_session_enable_disable (vm, 1 /* turn on TCP, etc. */ ); |
| 613 | |
| 614 | if (tm->test_client_attached == 0) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 615 | { |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 616 | if (attach_builtin_test_clients_app ()) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 617 | { |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 618 | return clib_error_return (0, "app attach failed"); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 619 | } |
| 620 | } |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 621 | tm->test_client_attached = 1; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 622 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 623 | /* Turn on the builtin client input nodes */ |
| 624 | for (i = 0; i < thread_main->n_vlib_mains; i++) |
| 625 | vlib_node_set_state (vlib_mains[i], builtin_client_node.index, |
| 626 | VLIB_NODE_STATE_POLLING); |
| 627 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 628 | /* Fire off connect requests */ |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 629 | clients_connect (vm, uri, n_clients); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 630 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 631 | /* Park until the sessions come up, or ten seconds elapse... */ |
| 632 | vlib_process_wait_for_event_or_clock (vm, 10.0 /* timeout, seconds */ ); |
| 633 | event_type = vlib_process_get_events (vm, &event_data); |
| 634 | |
| 635 | switch (event_type) |
| 636 | { |
| 637 | case ~0: |
| 638 | vlib_cli_output (vm, "Timeout with only %d sessions active...", |
| 639 | tm->ready_connections); |
| 640 | goto cleanup; |
| 641 | |
| 642 | case 1: |
| 643 | vlib_cli_output (vm, "Test started at %.6f", tm->test_start_time); |
| 644 | break; |
| 645 | |
| 646 | default: |
| 647 | vlib_cli_output (vm, "unexpected event(1): %d", event_type); |
| 648 | goto cleanup; |
| 649 | } |
| 650 | |
| 651 | /* Now wait for the sessions to finish... */ |
| 652 | vlib_process_wait_for_event_or_clock (vm, cli_timeout); |
| 653 | event_type = vlib_process_get_events (vm, &event_data); |
| 654 | |
| 655 | switch (event_type) |
| 656 | { |
| 657 | case ~0: |
| 658 | vlib_cli_output (vm, "Timeout with %d sessions still active...", |
| 659 | tm->ready_connections); |
| 660 | goto cleanup; |
| 661 | |
| 662 | case 2: |
| 663 | vlib_cli_output (vm, "Test finished at %.6f", tm->test_end_time); |
| 664 | break; |
| 665 | |
| 666 | default: |
| 667 | vlib_cli_output (vm, "unexpected event(2): %d", event_type); |
| 668 | goto cleanup; |
| 669 | } |
| 670 | |
| 671 | delta = tm->test_end_time - tm->test_start_time; |
| 672 | |
| 673 | if (delta != 0.0) |
| 674 | { |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 675 | total_bytes = (tm->no_return ? tm->tx_total : tm->rx_total); |
| 676 | transfer_type = tm->no_return ? "half-duplex" : "full-duplex"; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 677 | vlib_cli_output (vm, |
| 678 | "%lld bytes (%lld mbytes, %lld gbytes) in %.2f seconds", |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame^] | 679 | total_bytes, total_bytes / (1ULL << 20), |
| 680 | total_bytes / (1ULL << 30), delta); |
| 681 | vlib_cli_output (vm, "%.2f bytes/second %s", |
| 682 | ((f64) total_bytes) / (delta), transfer_type); |
| 683 | vlib_cli_output (vm, "%.4f gbit/second %s", |
| 684 | (((f64) total_bytes * 8.0) / delta / 1e9), |
| 685 | transfer_type); |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 686 | } |
| 687 | else |
| 688 | vlib_cli_output (vm, "zero delta-t?"); |
| 689 | |
| 690 | cleanup: |
| 691 | pool_free (tm->sessions); |
| 692 | for (i = 0; i < vec_len (tm->connection_index_by_thread); i++) |
| 693 | vec_reset_length (tm->connection_index_by_thread[i]); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 694 | |
| 695 | return 0; |
| 696 | } |
| 697 | |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 698 | /* *INDENT-OFF* */ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 699 | VLIB_CLI_COMMAND (test_clients_command, static) = |
| 700 | { |
| 701 | .path = "test tcp clients", |
Dave Barach | 0194f1a | 2017-05-15 10:11:39 -0400 | [diff] [blame] | 702 | .short_help = "test tcp clients [nclients %d]" |
| 703 | "[iterations %d] [bytes %d] [uri tcp://6.0.1.1/1234]", |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 704 | .function = test_tcp_clients_command_fn, |
| 705 | }; |
| 706 | /* *INDENT-ON* */ |
| 707 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 708 | clib_error_t * |
| 709 | tcp_test_clients_main_init (vlib_main_t * vm) |
| 710 | { |
| 711 | tclient_main_t *tm = &tclient_main; |
| 712 | tm->is_init = 0; |
| 713 | return 0; |
| 714 | } |
| 715 | |
| 716 | VLIB_INIT_FUNCTION (tcp_test_clients_main_init); |
| 717 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 718 | /* |
| 719 | * fd.io coding-style-patch-verification: ON |
| 720 | * |
| 721 | * Local Variables: |
| 722 | * eval: (c-set-style "gnu") |
| 723 | * End: |
| 724 | */ |