FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
vcl_test_server.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019 Cisco and/or its affiliates.
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 <unistd.h>
17 #include <errno.h>
18 #include <sys/types.h>
19 #include <sys/socket.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include <time.h>
23 #include <ctype.h>
24 #include <sys/stat.h>
25 #include <fcntl.h>
26 #include <hs_apps/vcl/vcl_test.h>
27 #include <sys/epoll.h>
28 #include <vppinfra/mem.h>
29 #include <pthread.h>
30 
31 typedef struct
32 {
33  uint8_t is_alloc;
34  int fd;
35  uint8_t *buf;
36  uint32_t buf_size;
39  vppcom_endpt_t endpt;
40  uint8_t ip[16];
41  vppcom_data_segments_t ds;
43 
44 typedef struct
45 {
46  uint16_t port;
47  uint32_t address_ip6;
50  vppcom_endpt_t endpt;
52 
53 typedef struct
54 {
55  uint32_t wrk_index;
56  int listen_fd;
57  int epfd;
58  struct epoll_event wait_events[VCL_TEST_CFG_MAX_EPOLL_EVENTS];
61  int nfds;
62  pthread_t thread_handle;
64 
65 typedef struct
66 {
69 
70  struct sockaddr_storage servaddr;
71  volatile int worker_fails;
72  volatile int active_workers;
75 
76 static __thread int __wrk_index = 0;
77 
79 
80 static inline void
81 conn_pool_expand (vcl_test_server_worker_t * wrk, size_t expand_size)
82 {
83  vcl_test_server_conn_t *conn_pool;
84  size_t new_size = wrk->conn_pool_size + expand_size;
85  int i;
86 
87  conn_pool = realloc (wrk->conn_pool, new_size * sizeof (*wrk->conn_pool));
88  if (conn_pool)
89  {
90  for (i = wrk->conn_pool_size; i < new_size; i++)
91  {
92  vcl_test_server_conn_t *conn = &conn_pool[i];
93  memset (conn, 0, sizeof (*conn));
94  vcl_test_cfg_init (&conn->cfg);
95  vcl_test_buf_alloc (&conn->cfg, 1 /* is_rxbuf */ ,
96  &conn->buf, &conn->buf_size);
97  conn->cfg.txbuf_size = conn->cfg.rxbuf_size;
98  }
99 
100  wrk->conn_pool = conn_pool;
101  wrk->conn_pool_size = new_size;
102  }
103  else
104  {
105  vterr ("conn_pool_expand()", -errno);
106  }
107 }
108 
109 static inline vcl_test_server_conn_t *
111 {
112  int i, expand = 0;
113 
114 again:
115  for (i = 0; i < wrk->conn_pool_size; i++)
116  {
117  if (!wrk->conn_pool[i].is_alloc)
118  {
119  wrk->conn_pool[i].endpt.ip = wrk->conn_pool[i].ip;
120  wrk->conn_pool[i].is_alloc = 1;
121  return (&wrk->conn_pool[i]);
122  }
123  }
124 
125  if (expand == 0)
126  {
127  conn_pool_expand (wrk, 2 * wrk->conn_pool_size);
128  expand = 1;
129  goto again;
130  }
131  vtwrn ("Failed to allocate connection even after expand");
132  return 0;
133 }
134 
135 static inline void
137 {
138  conn->fd = 0;
139  conn->is_alloc = 0;
140 }
141 
142 static inline void
144 {
145  conn->cfg = *rx_cfg;
146  vcl_test_buf_alloc (&conn->cfg, 1 /* is_rxbuf */ ,
147  &conn->buf, &conn->buf_size);
148  conn->cfg.txbuf_size = conn->cfg.rxbuf_size;
149 
150  if (conn->cfg.verbose)
151  {
152  vtinf ("(fd %d): Replying to cfg message!\n", conn->fd);
153  vcl_test_cfg_dump (&conn->cfg, 0 /* is_client */ );
154  }
155  (void) vcl_test_write (conn->fd, (uint8_t *) & conn->cfg,
156  sizeof (conn->cfg), NULL, conn->cfg.verbose);
157 }
158 
159 static void
161  vcl_test_server_conn_t * conn, vcl_test_cfg_t * rx_cfg)
162 {
163  u8 is_bi = rx_cfg->test == VCL_TEST_TYPE_BI;
165  char buf[64];
166  int i;
167 
168  if (rx_cfg->ctrl_handle == conn->fd)
169  {
170  for (i = 0; i < wrk->conn_pool_size; i++)
171  {
172  tc = &wrk->conn_pool[i];
173  if (tc->cfg.ctrl_handle != conn->fd)
174  continue;
175 
176  vcl_test_stats_accumulate (&conn->stats, &tc->stats);
177  if (vcl_comp_tspec (&conn->stats.stop, &tc->stats.stop) < 0)
178  conn->stats.stop = tc->stats.stop;
179  /* Client delays sending of disconnect */
180  conn->stats.stop.tv_sec -= VCL_TEST_DELAY_DISCONNECT;
181  if (conn->cfg.verbose)
182  {
183  snprintf (buf, sizeof (buf), "SERVER (fd %d) RESULTS", tc->fd);
184  vcl_test_stats_dump (buf, &tc->stats, 1 /* show_rx */ ,
185  is_bi /* show tx */ , conn->cfg.verbose);
186  }
187  }
188 
189  vcl_test_stats_dump ("SERVER RESULTS", &conn->stats, 1 /* show_rx */ ,
190  is_bi /* show_tx */ , conn->cfg.verbose);
191  vcl_test_cfg_dump (&conn->cfg, 0 /* is_client */ );
192  if (conn->cfg.verbose)
193  {
194  vtinf (" vcl server main\n"
196  " buf: %p\n"
197  " buf size: %u (0x%08x)\n"
199  conn->buf, conn->buf_size, conn->buf_size);
200  }
201 
202  sync_config_and_reply (conn, rx_cfg);
203  memset (&conn->stats, 0, sizeof (conn->stats));
204  }
205  else
206  {
207  if (rx_cfg->ctrl_handle == ~0)
208  {
209  rx_cfg->ctrl_handle = conn->fd;
210  vtinf ("Set control fd %d for test!", conn->fd);
211  }
212  else
213  {
214  vtinf ("Starting %s-directional Stream Test (fd %d)!",
215  is_bi ? "Bi" : "Uni", conn->fd);
216  }
217 
218  sync_config_and_reply (conn, rx_cfg);
219 
220  /* read the 1st chunk, record start time */
221  memset (&conn->stats, 0, sizeof (conn->stats));
222  clock_gettime (CLOCK_REALTIME, &conn->stats.start);
223  }
224 }
225 
226 static inline void
227 vts_server_rx (vcl_test_server_conn_t * conn, int rx_bytes)
228 {
230  int client_fd = conn->fd;
231 
232  if (conn->cfg.test == VCL_TEST_TYPE_BI)
233  {
234  if (vsm->use_ds)
235  {
236  (void) vcl_test_write (client_fd, conn->ds[0].data, conn->ds[0].len,
237  &conn->stats, conn->cfg.verbose);
238  if (conn->ds[1].len)
239  (void) vcl_test_write (client_fd, conn->ds[1].data,
240  conn->ds[1].len, &conn->stats,
241  conn->cfg.verbose);
242  }
243  else
244  (void) vcl_test_write (client_fd, conn->buf, rx_bytes, &conn->stats,
245  conn->cfg.verbose);
246  }
247 
248  if (vsm->use_ds)
249  vppcom_session_free_segments (conn->fd, conn->ds);
250 
251  if (conn->stats.rx_bytes >= conn->cfg.total_bytes)
252  clock_gettime (CLOCK_REALTIME, &conn->stats.stop);
253 }
254 
255 static void
257 {
259  int tx_bytes, nbytes, pos;
260 
261  if (vsm->use_ds)
262  vppcom_data_segment_copy (conn->buf, conn->ds, rx_bytes);
263 
264  /* If it looks vaguely like a string, make sure it's terminated */
265  pos = rx_bytes < conn->buf_size ? rx_bytes : conn->buf_size - 1;
266  ((char *) conn->buf)[pos] = 0;
267  vtinf ("(fd %d): RX (%d bytes) - '%s'", conn->fd, rx_bytes, conn->buf);
268 
269  if (conn->cfg.verbose)
270  vtinf ("(fd %d): Echoing back", conn->fd);
271 
272  nbytes = strlen ((const char *) conn->buf) + 1;
273  tx_bytes = vcl_test_write (conn->fd, conn->buf, nbytes, &conn->stats,
274  conn->cfg.verbose);
275  if (tx_bytes >= 0)
276  vtinf ("(fd %d): TX (%d bytes) - '%s'", conn->fd, tx_bytes, conn->buf);
277 }
278 
279 static void
281 {
283  struct epoll_event ev;
284  int rv, client_fd;
285 
286  conn = conn_pool_alloc (wrk);
287  if (!conn)
288  {
289  vtwrn ("No free connections!");
290  return;
291  }
292 
293  client_fd = vppcom_session_accept (listen_fd, &conn->endpt, 0);
294  if (client_fd < 0)
295  {
296  vterr ("vppcom_session_accept()", client_fd);
297  return;
298  }
299  conn->fd = client_fd;
300 
301  vtinf ("Got a connection -- fd = %d (0x%08x) on listener fd = %d (0x%08x)",
302  client_fd, client_fd, listen_fd, listen_fd);
303 
304  ev.events = EPOLLIN;
305  ev.data.u64 = conn - wrk->conn_pool;
306  rv = vppcom_epoll_ctl (wrk->epfd, EPOLL_CTL_ADD, client_fd, &ev);
307  if (rv < 0)
308  {
309  vterr ("vppcom_epoll_ctl()", rv);
310  return;
311  }
312  wrk->nfds++;
313 }
314 
315 static void
317 {
318  fprintf (stderr,
319  "vcl_test_server [OPTIONS] <port>\n"
320  " OPTIONS\n"
321  " -h Print this message and exit.\n"
322  " -6 Use IPv6\n"
323  " -w <num> Number of workers\n"
324  " -p <PROTO> Use <PROTO> transport layer\n"
325  " -D Use UDP transport layer\n"
326  " -L Use TLS transport layer\n");
327  exit (1);
328 }
329 
330 static void
332 {
333  struct sockaddr_storage *servaddr = &vsm->servaddr;
334  memset (servaddr, 0, sizeof (*servaddr));
335 
336  if (vsm->cfg.address_ip6)
337  {
338  struct sockaddr_in6 *server_addr = (struct sockaddr_in6 *) servaddr;
339  server_addr->sin6_family = AF_INET6;
340  server_addr->sin6_addr = in6addr_any;
341  server_addr->sin6_port = htons (vsm->cfg.port);
342  }
343  else
344  {
345  struct sockaddr_in *server_addr = (struct sockaddr_in *) servaddr;
346  server_addr->sin_family = AF_INET;
347  server_addr->sin_addr.s_addr = htonl (INADDR_ANY);
348  server_addr->sin_port = htons (vsm->cfg.port);
349  }
350 
351  if (vsm->cfg.address_ip6)
352  {
353  struct sockaddr_in6 *server_addr = (struct sockaddr_in6 *) servaddr;
354  vsm->cfg.endpt.is_ip4 = 0;
355  vsm->cfg.endpt.ip = (uint8_t *) & server_addr->sin6_addr;
356  vsm->cfg.endpt.port = (uint16_t) server_addr->sin6_port;
357  }
358  else
359  {
360  struct sockaddr_in *server_addr = (struct sockaddr_in *) servaddr;
361  vsm->cfg.endpt.is_ip4 = 1;
362  vsm->cfg.endpt.ip = (uint8_t *) & server_addr->sin_addr;
363  vsm->cfg.endpt.port = (uint16_t) server_addr->sin_port;
364  }
365 }
366 
367 static void
369  char **argv)
370 {
371  int v, c;
372 
373  vsm->cfg.proto = VPPCOM_PROTO_TCP;
374 
375  opterr = 0;
376  while ((c = getopt (argc, argv, "6DLsw:p:")) != -1)
377  switch (c)
378  {
379  case '6':
380  vsm->cfg.address_ip6 = 1;
381  break;
382 
383  case 'p':
384  if (vppcom_unformat_proto (&vsm->cfg.proto, optarg))
385  vtwrn ("Invalid vppcom protocol %s, defaulting to TCP", optarg);
386  break;
387 
388  case 'D':
389  vsm->cfg.proto = VPPCOM_PROTO_UDP;
390  break;
391 
392  case 'L':
393  vsm->cfg.proto = VPPCOM_PROTO_TLS;
394  break;
395 
396  case 'w':
397  v = atoi (optarg);
398  if (v > 1)
399  vsm->cfg.workers = v;
400  else
401  vtwrn ("Invalid number of workers %d", v);
402  break;
403  case 's':
404  vsm->use_ds = 1;
405  break;
406  case '?':
407  switch (optopt)
408  {
409  case 'w':
410  case 'p':
411  vtwrn ("Option `-%c' requires an argument.", optopt);
412  break;
413  default:
414  if (isprint (optopt))
415  vtwrn ("Unknown option `-%c'.", optopt);
416  else
417  vtwrn ("Unknown option character `\\x%x'.", optopt);
418  }
419  /* fall thru */
420  case 'h':
421  default:
423  }
424 
425  if (argc < (optind + 1))
426  {
427  fprintf (stderr, "SERVER: ERROR: Insufficient number of arguments!\n");
429  }
430 
431  if (sscanf (argv[optind], "%d", &v) == 1)
432  vsm->cfg.port = (uint16_t) v;
433  else
434  {
435  fprintf (stderr, "SERVER: ERROR: Invalid port (%s)!\n", argv[optind]);
437  }
438 
440 }
441 
442 static void
444  int listener_fd)
445 {
446  if ((vppcom_session_n_accepted (listener_fd) == 0) &
447  vppcom_session_is_connectable_listener (listener_fd))
448  {
449  vtinf ("Connected Listener fd %x has no more sessions", listener_fd);
450  vppcom_session_close (listener_fd);
451  wrk->nfds--;
452  }
453 }
454 
455 int
457  vcl_test_server_conn_t * conn, int rx_bytes)
458 {
459  int listener_fd;
460  if (rx_cfg->verbose)
461  {
462  vtinf ("(fd %d): Received a cfg msg!", conn->fd);
463  vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ );
464  }
465 
466  if (rx_bytes != sizeof (*rx_cfg))
467  {
468  vtinf ("(fd %d): Invalid cfg msg size %d expected %lu!", conn->fd,
469  rx_bytes, sizeof (*rx_cfg));
470  conn->cfg.rxbuf_size = 0;
471  conn->cfg.num_writes = 0;
472  if (conn->cfg.verbose)
473  {
474  vtinf ("(fd %d): Replying to cfg msg", conn->fd);
475  vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ );
476  }
477  vcl_test_write (conn->fd, (uint8_t *) & conn->cfg,
478  sizeof (conn->cfg), NULL, conn->cfg.verbose);
479  return -1;
480  }
481 
482  switch (rx_cfg->test)
483  {
484  case VCL_TEST_TYPE_NONE:
485  case VCL_TEST_TYPE_ECHO:
486  sync_config_and_reply (conn, rx_cfg);
487  break;
488 
489  case VCL_TEST_TYPE_BI:
490  case VCL_TEST_TYPE_UNI:
491  vts_server_start_stop (wrk, conn, rx_cfg);
492  break;
493 
494  case VCL_TEST_TYPE_EXIT:
495  vtinf ("Session fd %d closing!", conn->fd);
496  clock_gettime (CLOCK_REALTIME, &conn->stats.stop);
497  listener_fd = vppcom_session_listener (conn->fd);
498  vppcom_session_close (conn->fd);
499  conn_pool_free (conn);
500  wrk->nfds--;
501  vts_clean_connected_listeners (wrk, listener_fd);
502  break;
503 
504  default:
505  vtwrn ("Unknown test type %d", rx_cfg->test);
506  vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ );
507  break;
508  }
509 
510  return 0;
511 }
512 
513 static void
515 {
517  struct epoll_event listen_ev;
518  int rv;
519 
520  __wrk_index = wrk->wrk_index;
521 
522  vtinf ("Initializing worker ...");
523 
525  if (wrk->wrk_index)
526  if (vppcom_worker_register ())
527  vtfail ("vppcom_worker_register()", 1);
528 
529  wrk->listen_fd = vppcom_session_create (vsm->cfg.proto,
530  0 /* is_nonblocking */ );
531  if (wrk->listen_fd < 0)
532  vtfail ("vppcom_session_create()", wrk->listen_fd);
533 
534  if (vsm->cfg.proto == VPPCOM_PROTO_UDP)
535  {
536  vppcom_session_attr (wrk->listen_fd, VPPCOM_ATTR_SET_CONNECTED, 0, 0);
537  }
538 
539  if (vsm->cfg.proto == VPPCOM_PROTO_TLS
540  || vsm->cfg.proto == VPPCOM_PROTO_QUIC)
541  {
542  vppcom_session_tls_add_cert (wrk->listen_fd, vcl_test_crt_rsa,
544  vppcom_session_tls_add_key (wrk->listen_fd, vcl_test_key_rsa,
546  }
547 
548  rv = vppcom_session_bind (wrk->listen_fd, &vsm->cfg.endpt);
549  if (rv < 0)
550  vtfail ("vppcom_session_bind()", rv);
551 
552  if (!(vsm->cfg.proto == VPPCOM_PROTO_UDP))
553  {
554  rv = vppcom_session_listen (wrk->listen_fd, 10);
555  if (rv < 0)
556  vtfail ("vppcom_session_listen()", rv);
557  }
558 
559  wrk->epfd = vppcom_epoll_create ();
560  if (wrk->epfd < 0)
561  vtfail ("vppcom_epoll_create()", wrk->epfd);
562 
563  listen_ev.events = EPOLLIN;
564  listen_ev.data.u32 = ~0;
565  rv = vppcom_epoll_ctl (wrk->epfd, EPOLL_CTL_ADD, wrk->listen_fd,
566  &listen_ev);
567  if (rv < 0)
568  vtfail ("vppcom_epoll_ctl", rv);
569 
570  vsm->active_workers += 1;
571  vtinf ("Waiting for a client to connect on port %d ...", vsm->cfg.port);
572 }
573 
574 static int
576 {
577  if (conn->cfg.test == VCL_TEST_TYPE_ECHO)
578  return 1;
579 
580  return (conn->stats.rx_bytes < 128
581  || conn->stats.rx_bytes > conn->cfg.total_bytes);
582 }
583 
584 static vcl_test_cfg_t *
586 {
588 
589  if (vsm->use_ds)
590  {
591  /* We could avoid the copy if the first segment is big enough but this
592  * just simplifies things */
593  vppcom_data_segment_copy (conn->buf, conn->ds, sizeof (vcl_test_cfg_t));
594  }
595  return (vcl_test_cfg_t *) conn->buf;
596 }
597 
598 static inline int
600 {
602  if (vsm->use_ds)
603  return vcl_test_read_ds (conn->fd, conn->ds, &conn->stats);
604  else
605  return vcl_test_read (conn->fd, conn->buf, conn->buf_size, &conn->stats);
606 }
607 
608 static inline int
610 {
612 
613  if (vsm->use_ds)
614  return isascii (conn->ds[0].data[0]);
615  else
616  return isascii (conn->buf[0]);
617 }
618 
619 static void *
620 vts_worker_loop (void *arg)
621 {
623  vcl_test_server_worker_t *wrk = arg;
625  int i, rx_bytes, num_ev, listener_fd;
626  vcl_test_cfg_t *rx_cfg;
627 
628  if (wrk->wrk_index)
629  vts_worker_init (wrk);
630 
631  while (1)
632  {
633  num_ev = vppcom_epoll_wait (wrk->epfd, wrk->wait_events,
635  if (num_ev < 0)
636  {
637  vterr ("vppcom_epoll_wait()", num_ev);
638  goto fail;
639  }
640  else if (num_ev == 0)
641  {
642  vtinf ("vppcom_epoll_wait() timeout!");
643  continue;
644  }
645  for (i = 0; i < num_ev; i++)
646  {
647  conn = &wrk->conn_pool[wrk->wait_events[i].data.u32];
648  if (wrk->wait_events[i].events & (EPOLLHUP | EPOLLRDHUP))
649  {
650  vtinf ("Closing session %d on HUP", conn->fd);
651  listener_fd = vppcom_session_listener (conn->fd);
652  vppcom_session_close (conn->fd);
653  wrk->nfds--;
654  vts_clean_connected_listeners (wrk, listener_fd);
655  if (!wrk->nfds)
656  {
657  vtinf ("All client connections closed\n");
658  goto done;
659  }
660  continue;
661  }
662  if (wrk->wait_events[i].data.u32 == ~0)
663  {
664  vts_new_client (wrk, wrk->listen_fd);
665  continue;
666  }
667  else if (vppcom_session_is_connectable_listener (conn->fd))
668  {
669  vts_new_client (wrk, conn->fd);
670  continue;
671  }
672 
673  if (EPOLLIN & wrk->wait_events[i].events)
674  {
675  read_again:
676  rx_bytes = vts_conn_read (conn);
677 
678  if (rx_bytes <= 0)
679  {
680  if (errno == ECONNRESET)
681  {
682  vtinf ("Connection reset by remote peer.\n");
683  goto fail;
684  }
685  else
686  continue;
687  }
688 
689  if (vts_conn_expect_config (conn))
690  {
691  rx_cfg = vts_conn_read_config (conn);
692  if (rx_cfg->magic == VCL_TEST_CFG_CTRL_MAGIC)
693  {
694  if (vsm->use_ds)
695  vppcom_session_free_segments (conn->fd, conn->ds);
696  vts_handle_cfg (wrk, rx_cfg, conn, rx_bytes);
697  if (!wrk->nfds)
698  {
699  vtinf ("All client connections closed\n");
700  goto done;
701  }
702  continue;
703  }
704  }
705  if ((conn->cfg.test == VCL_TEST_TYPE_UNI)
706  || (conn->cfg.test == VCL_TEST_TYPE_BI))
707  {
708  vts_server_rx (conn, rx_bytes);
709  if (vppcom_session_attr (conn->fd, VPPCOM_ATTR_GET_NREAD, 0,
710  0) > 0)
711  goto read_again;
712  continue;
713  }
714  if (vts_conn_has_ascii (conn))
715  {
716  vts_server_echo (conn, rx_bytes);
717  }
718  else
719  {
720  vtwrn ("FIFO not drained! extra bytes %d", rx_bytes);
721  }
722  }
723  else
724  {
725  vtwrn ("Unhandled event");
726  goto fail;
727  }
728  }
729  }
730 
731 fail:
732  vsm->worker_fails -= 1;
733 
734 done:
735  vppcom_session_close (wrk->listen_fd);
736  if (wrk->conn_pool)
737  free (wrk->conn_pool);
738  vsm->active_workers -= 1;
739  return 0;
740 }
741 
742 int
743 main (int argc, char **argv)
744 {
746  int rv, i;
747 
748  clib_mem_init_thread_safe (0, 64 << 20);
750  vsm->cfg.workers = 1;
751  vsm->active_workers = 0;
752  vcl_test_server_process_opts (vsm, argc, argv);
753 
754  rv = vppcom_app_create ("vcl_test_server");
755  if (rv)
756  vtfail ("vppcom_app_create()", rv);
757 
758  vsm->workers = calloc (vsm->cfg.workers, sizeof (*vsm->workers));
759  vts_worker_init (&vsm->workers[0]);
760  for (i = 1; i < vsm->cfg.workers; i++)
761  {
762  vsm->workers[i].wrk_index = i;
763  rv = pthread_create (&vsm->workers[i].thread_handle, NULL,
764  vts_worker_loop, (void *) &vsm->workers[i]);
765  }
766  vts_worker_loop (&vsm->workers[0]);
767 
768  while (vsm->active_workers > 0)
769  ;
770 
771  vppcom_app_destroy ();
772  free (vsm->workers);
773 
774  return vsm->worker_fails;
775 }
776 
777 /*
778  * fd.io coding-style-patch-verification: ON
779  *
780  * Local Variables:
781  * eval: (c-set-style "gnu")
782  * End:
783  */
int vts_handle_cfg(vcl_test_server_worker_t *wrk, vcl_test_cfg_t *rx_cfg, vcl_test_server_conn_t *conn, int rx_bytes)
static void conn_pool_free(vcl_test_server_conn_t *conn)
static int vts_conn_has_ascii(vcl_test_server_conn_t *conn)
struct sockaddr_storage servaddr
uint32_t vcl_test_crt_rsa_len
Definition: vcl_test.h:154
struct timespec stop
Definition: vcl_test.h:111
Optimized string handling code, including c11-compliant "safe C library" variants.
static void sync_config_and_reply(vcl_test_server_conn_t *conn, vcl_test_cfg_t *rx_cfg)
vppcom_endpt_t endpt
static void vcl_test_server_process_opts(vcl_test_server_main_t *vsm, int argc, char **argv)
struct epoll_event wait_events[VCL_TEST_CFG_MAX_EPOLL_EVENTS]
static int vts_conn_read(vcl_test_server_conn_t *conn)
static void conn_pool_expand(vcl_test_server_worker_t *wrk, size_t expand_size)
#define VCL_TEST_DELAY_DISCONNECT
Definition: vcl_test.h:70
unsigned char u8
Definition: types.h:56
#define VCL_TEST_SERVER_PORT
Definition: vcl_test.h:59
struct timespec start
Definition: vcl_test.h:110
uint64_t num_writes
Definition: vcl_test.h:96
static void print_usage_and_exit(void)
static void vts_server_echo(vcl_test_server_conn_t *conn, int rx_bytes)
uint64_t txbuf_size
Definition: vcl_test.h:95
static void vcl_test_stats_dump(char *header, vcl_test_stats_t *stats, uint8_t show_rx, uint8_t show_tx, uint8_t verbose)
Definition: vcl_test.h:326
#define vterr(_fn, _rv)
Definition: vcl_test.h:33
static vcl_test_server_main_t vcl_server_main
static void * vts_worker_loop(void *arg)
char vcl_test_key_rsa[]
Definition: vcl_test.h:156
#define VCL_TEST_CFG_MAX_EPOLL_EVENTS
Definition: vcl_test.h:68
static int vcl_test_read_ds(int fd, vppcom_data_segments_t ds, vcl_test_stats_t *stats)
Definition: vcl_test.h:447
uint32_t verbose
Definition: vcl_test.h:91
#define VCL_TEST_SEPARATOR_STRING
Definition: vcl_test.h:71
static void vcl_test_cfg_dump(vcl_test_cfg_t *cfg, uint8_t is_client)
Definition: vcl_test.h:288
static void vts_server_rx(vcl_test_server_conn_t *conn, int rx_bytes)
#define VCL_TEST_CFG_CTRL_MAGIC
Definition: vcl_test.h:62
static void vts_new_client(vcl_test_server_worker_t *wrk, int listen_fd)
static void vts_server_start_stop(vcl_test_server_worker_t *wrk, vcl_test_server_conn_t *conn, vcl_test_cfg_t *rx_cfg)
static void vts_worker_init(vcl_test_server_worker_t *wrk)
svmdb_client_t * c
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
vcl_test_server_cfg_t cfg
uint64_t rxbuf_size
Definition: vcl_test.h:94
static void vcl_test_cfg_init(vcl_test_cfg_t *cfg)
Definition: vcl_test.h:200
vcl_test_stats_t stats
char vcl_test_crt_rsa[]
Definition: vcl_test.h:130
vcl_test_server_conn_t * conn_pool
uint32_t magic
Definition: vcl_test.h:84
#define vtinf(_fmt, _args...)
Definition: vcl_test.h:42
static void vcl_test_buf_alloc(vcl_test_cfg_t *cfg, uint8_t is_rxbuf, uint8_t **buf, uint32_t *bufsize)
Definition: vcl_test.h:229
static vcl_test_cfg_t * vts_conn_read_config(vcl_test_server_conn_t *conn)
static int vcl_test_read(int fd, uint8_t *buf, uint32_t nbytes, vcl_test_stats_t *stats)
Definition: vcl_test.h:407
uint32_t ctrl_handle
Definition: vcl_test.h:87
int main(int argc, char **argv)
static int vcl_test_write(int fd, uint8_t *buf, uint32_t nbytes, vcl_test_stats_t *stats, uint32_t verbose)
Definition: vcl_test.h:484
uint32_t vcl_test_key_rsa_len
Definition: vcl_test.h:184
vl_api_address_t ip
Definition: l2.api:501
vppcom_data_segments_t ds
static vcl_test_server_conn_t * conn_pool_alloc(vcl_test_server_worker_t *wrk)
static void vts_clean_connected_listeners(vcl_test_server_worker_t *wrk, int listener_fd)
uint32_t test
Definition: vcl_test.h:86
static int vcl_comp_tspec(struct timespec *a, struct timespec *b)
Definition: vcl_test.h:392
static void vcl_test_stats_accumulate(vcl_test_stats_t *accum, vcl_test_stats_t *incr)
Definition: vcl_test.h:187
vcl_test_server_worker_t * workers
#define vtfail(_fn, _rv)
Definition: vcl_test.h:25
static void vcl_test_init_endpoint_addr(vcl_test_server_main_t *vsm)
void * clib_mem_init_thread_safe(void *memory, uword memory_size)
Definition: mem_dlmalloc.c:234
volatile int active_workers
uint64_t rx_bytes
Definition: vcl_test.h:103
uint64_t total_bytes
Definition: vcl_test.h:97
#define VCL_TEST_CFG_MAX_TEST_SESS
Definition: vcl_test.h:67
#define vtwrn(_fmt, _args...)
Definition: vcl_test.h:39
static int vts_conn_expect_config(vcl_test_server_conn_t *conn)