FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
sock_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 <hs_apps/vcl/sock_test.h>
25 #include <sys/stat.h>
26 #include <fcntl.h>
27 #include <sys/ioctl.h>
28 #include <sys/epoll.h>
29 #include <sys/un.h>
30 
31 #define SOCK_SERVER_MAX_TEST_CONN 10
32 #define SOCK_SERVER_MAX_EPOLL_EVENTS 10
33 
34 typedef struct
35 {
36  uint8_t is_alloc;
37  int fd;
38  uint8_t *buf;
39  uint32_t buf_size;
43 
44 typedef struct
45 {
46  uint32_t port;
47  uint32_t address_ip6;
48  uint32_t transport_udp;
50 
51 typedef struct
52 {
53  int listen_fd;
55  int epfd;
56  struct epoll_event listen_ev;
57  struct epoll_event wait_events[SOCK_SERVER_MAX_EPOLL_EVENTS];
60  struct epoll_event af_unix_listen_ev;
61  struct sockaddr_un serveraddr;
62  uint32_t af_unix_xacts;
63  size_t num_conn;
66  int nfds;
67  fd_set rd_fdset;
68  fd_set wr_fdset;
69  struct timeval timeout;
71 
73 
74 static inline void
75 conn_pool_expand (size_t expand_size)
76 {
78  sock_server_conn_t *conn_pool;
79  size_t new_size = ssm->conn_pool_size + expand_size;
80  int i;
81 
82  conn_pool = realloc (ssm->conn_pool, new_size * sizeof (*ssm->conn_pool));
83  if (!conn_pool)
84  stfail ("conn_pool_expand()");
85 
86  for (i = ssm->conn_pool_size; i < new_size; i++)
87  {
88  sock_server_conn_t *conn = &conn_pool[i];
89  memset (conn, 0, sizeof (*conn));
90  vcl_test_cfg_init (&conn->cfg);
91  vcl_test_buf_alloc (&conn->cfg, 1 /* is_rxbuf */ , &conn->buf,
92  &conn->buf_size);
93  conn->cfg.txbuf_size = conn->cfg.rxbuf_size;
94  }
95 
96  ssm->conn_pool = conn_pool;
97  ssm->conn_pool_size = new_size;
98 }
99 
100 static inline sock_server_conn_t *
102 {
104  int i;
105 
106  for (i = 0; i < ssm->conn_pool_size; i++)
107  {
108  if (!ssm->conn_pool[i].is_alloc)
109  {
110  ssm->conn_pool[i].is_alloc = 1;
111  return (&ssm->conn_pool[i]);
112  }
113  }
114 
115  return 0;
116 }
117 
118 static inline void
120 {
121  conn->fd = 0;
122  conn->is_alloc = 0;
123 }
124 
125 static inline void
127 {
128  conn->cfg = *rx_cfg;
129  vcl_test_buf_alloc (&conn->cfg, 1 /* is_rxbuf */ ,
130  &conn->buf, &conn->buf_size);
131  conn->cfg.txbuf_size = conn->cfg.rxbuf_size;
132 
133  if (conn->cfg.verbose)
134  {
135  stinf ("(fd %d): Replying to cfg message!\n", conn->fd);
136  vcl_test_cfg_dump (&conn->cfg, 0 /* is_client */ );
137  }
138  (void) sock_test_write (conn->fd, (uint8_t *) & conn->cfg,
139  sizeof (conn->cfg), NULL, conn->cfg.verbose);
140 }
141 
142 static void
144  vcl_test_cfg_t * rx_cfg)
145 {
147  int client_fd = conn->fd;
148  vcl_test_t test = rx_cfg->test;
149 
150  if (rx_cfg->ctrl_handle == conn->fd)
151  {
152  int i;
153  clock_gettime (CLOCK_REALTIME, &conn->stats.stop);
154 
155  for (i = 0; i < ssm->conn_pool_size; i++)
156  {
157  sock_server_conn_t *tc = &ssm->conn_pool[i];
158 
159  if (tc->cfg.ctrl_handle == conn->fd)
160  {
161  vcl_test_stats_accumulate (&conn->stats, &tc->stats);
162 
163  if (conn->cfg.verbose)
164  {
165  static char buf[64];
166 
167  snprintf (buf, sizeof (buf), "SERVER (fd %d) RESULTS",
168  tc->fd);
169  vcl_test_stats_dump (buf, &tc->stats, 1 /* show_rx */ ,
170  test == VCL_TEST_TYPE_BI
171  /* show tx */ ,
172  conn->cfg.verbose);
173  }
174  }
175  }
176 
177  vcl_test_stats_dump ("SERVER RESULTS", &conn->stats, 1 /* show_rx */ ,
178  (test == VCL_TEST_TYPE_BI) /* show_tx */ ,
179  conn->cfg.verbose);
180  vcl_test_cfg_dump (&conn->cfg, 0 /* is_client */ );
181  if (conn->cfg.verbose)
182  {
183  stinf (" sock server main\n"
185  " buf: %p\n"
186  " buf size: %u (0x%08x)\n"
188  conn->buf, conn->buf_size, conn->buf_size);
189  }
190 
191  sync_config_and_reply (conn, rx_cfg);
192  stinf ("SERVER (fd %d): %s-directional Stream Test Complete!\n"
193  SOCK_TEST_BANNER_STRING "\n", conn->fd,
194  test == VCL_TEST_TYPE_BI ? "Bi" : "Uni");
195  }
196  else
197  {
199  "SERVER (fd %d): %s-directional Stream Test!\n"
200  " Sending client the test cfg to start streaming data...\n",
201  client_fd, test == VCL_TEST_TYPE_BI ? "Bi" : "Uni");
202 
203  rx_cfg->ctrl_handle = (rx_cfg->ctrl_handle == ~0) ? conn->fd :
204  rx_cfg->ctrl_handle;
205 
206  sync_config_and_reply (conn, rx_cfg);
207 
208  /* read the 1st chunk, record start time */
209  memset (&conn->stats, 0, sizeof (conn->stats));
210  clock_gettime (CLOCK_REALTIME, &conn->stats.start);
211  }
212 }
213 
214 
215 static inline void
217 {
218  int client_fd = conn->fd;
219  vcl_test_t test = conn->cfg.test;
220 
221  if (test == VCL_TEST_TYPE_BI)
222  (void) sock_test_write (client_fd, conn->buf, rx_bytes, &conn->stats,
223  conn->cfg.verbose);
224 
225  if (conn->stats.rx_bytes >= conn->cfg.total_bytes)
226  {
227  clock_gettime (CLOCK_REALTIME, &conn->stats.stop);
228  }
229 }
230 
231 static inline void
233 {
235  int af_unix_client_fd, rv;
236  uint8_t buffer[256];
237  size_t nbytes = strlen (SOCK_TEST_MIXED_EPOLL_DATA) + 1;
238 
239  af_unix_client_fd = accept (ssm->af_unix_listen_fd,
240  (struct sockaddr *) NULL, NULL);
241  if (af_unix_client_fd < 0)
242  stfail ("af_unix_echo accept()");
243 
244  stinf ("Got an AF_UNIX connection -- fd = %d (0x%08x)!",
245  af_unix_client_fd, af_unix_client_fd);
246 
247  memset (buffer, 0, sizeof (buffer));
248 
249  rv = read (af_unix_client_fd, buffer, nbytes);
250  if (rv < 0)
251  stfail ("af_unix_echo read()");
252 
253  /* Make the buffer is NULL-terminated. */
254  buffer[sizeof (buffer) - 1] = 0;
255  stinf ("(AF_UNIX): RX (%d bytes) - '%s'", rv, buffer);
256 
257  if (!strncmp (SOCK_TEST_MIXED_EPOLL_DATA, (const char *) buffer, nbytes))
258  {
259  rv = write (af_unix_client_fd, buffer, nbytes);
260  if (rv < 0)
261  stfail ("af_unix_echo write()");
262  stinf ("(AF_UNIX): TX (%d bytes) - '%s'\n", rv, buffer);
263  ssm->af_unix_xacts++;
264  }
265  close (af_unix_client_fd);
266 }
267 
268 static inline void
270 {
272  int client_fd;
273  sock_server_conn_t *conn;
274 
275  if (ssm->conn_pool_size < (ssm->num_conn + SOCK_SERVER_MAX_TEST_CONN + 1))
277 
278  conn = conn_pool_alloc ();
279  if (!conn)
280  stfail ("No free connections!");
281 
282  client_fd = accept (ssm->listen_fd, (struct sockaddr *) NULL, NULL);
283  if (client_fd < 0)
284  stfail ("new_client accept()");
285 
286  stinf ("Got a connection -- fd = %d (0x%08x)!\n", client_fd, client_fd);
287  if (fcntl (client_fd, F_SETFL, O_NONBLOCK) < 0)
288  stfail ("fcntl()");
289 
290  conn->fd = client_fd;
291 
292  struct epoll_event ev;
293  int rv;
294 
295  ev.events = EPOLLIN;
296  ev.data.u64 = conn - ssm->conn_pool;
297  rv = epoll_ctl (ssm->epfd, EPOLL_CTL_ADD, client_fd, &ev);
298 
299  if (rv < 0)
300  stfail ("new_client epoll_ctl()");
301 
302  ssm->nfds++;
303 }
304 
305 static int
307 {
308  int rv;
309 
310  if (ssm->af_unix_listen_fd > 0)
311  return 0;
312 
313  unlink ((const char *) SOCK_TEST_AF_UNIX_FILENAME);
314  ssm->af_unix_listen_fd = socket (AF_UNIX, SOCK_STREAM, 0);
315  if (ssm->af_unix_listen_fd < 0)
316  stfail ("echo_af_unix_init socket()");
317 
318  memset (&ssm->serveraddr, 0, sizeof (ssm->serveraddr));
319  ssm->serveraddr.sun_family = AF_UNIX;
320  strncpy (ssm->serveraddr.sun_path, SOCK_TEST_AF_UNIX_FILENAME,
321  sizeof (ssm->serveraddr.sun_path));
322 
323  rv = bind (ssm->af_unix_listen_fd, (struct sockaddr *) &ssm->serveraddr,
324  SUN_LEN (&ssm->serveraddr));
325  if (rv < 0)
326  stfail ("echo_af_unix_init bind()");
327 
328  rv = listen (ssm->af_unix_listen_fd, 10);
329  if (rv < 0)
330  stfail ("echo_af_unix_init listen()");
331 
332  ssm->af_unix_listen_ev.events = EPOLLIN;
334  rv = epoll_ctl (ssm->epfd, EPOLL_CTL_ADD, ssm->af_unix_listen_fd,
335  &ssm->af_unix_listen_ev);
336  if (rv < 0)
337  stfail ("echo_af_unix_init epoll_ctl()");
338 
339  return 0;
340 }
341 
342 void
344 {
345  fprintf (stderr,
346  "sock_test_server [OPTIONS] <port>\n"
347  " OPTIONS\n"
348  " -h Print this message and exit.\n"
349  " -6 Use IPv6\n"
350  " -u Use UDP transport layer\n");
351  exit (1);
352 }
353 
354 
355 static void
356 sts_server_echo (sock_server_conn_t * conn, int rx_bytes)
357 {
358  int tx_bytes, nbytes, pos;
359 
360  /* If it looks vaguely like a string make sure it's terminated */
361  pos = rx_bytes < conn->buf_size ? rx_bytes : conn->buf_size - 1;
362  ((char *) conn->buf)[pos] = 0;
363 
364  if (conn->cfg.verbose)
365  stinf ("(fd %d): Echoing back\n", conn->fd);
366 
367  nbytes = strlen ((const char *) conn->buf) + 1;
368 
369  tx_bytes = sock_test_write (conn->fd, conn->buf, nbytes, &conn->stats,
370  conn->cfg.verbose);
371  if (tx_bytes >= 0)
372  stinf ("(fd %d): TX (%d bytes) - '%s'\n", conn->fd, tx_bytes, conn->buf);
373 }
374 
375 static int
377  int rx_bytes)
378 {
380 
381  if (rx_cfg->verbose)
382  {
383  stinf ("(fd %d): Received a cfg message!\n", conn->fd);
384  vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ );
385  }
386 
387  if (rx_bytes != sizeof (*rx_cfg))
388  {
389  stinf ("(fd %d): Invalid cfg message size (%d) expected %lu!", conn->fd,
390  rx_bytes, sizeof (*rx_cfg));
391  conn->cfg.rxbuf_size = 0;
392  conn->cfg.num_writes = 0;
393  if (conn->cfg.verbose)
394  {
395  stinf ("(fd %d): Replying to cfg message!\n", conn->fd);
396  vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ );
397  }
398  sock_test_write (conn->fd, (uint8_t *) & conn->cfg, sizeof (conn->cfg),
399  NULL, conn->cfg.verbose);
400  return -1;
401  }
402 
403  switch (rx_cfg->test)
404  {
405  case VCL_TEST_TYPE_NONE:
406  sync_config_and_reply (conn, rx_cfg);
407  break;
408 
409  case VCL_TEST_TYPE_ECHO:
411  goto done;
412 
413  sync_config_and_reply (conn, rx_cfg);
414  break;
415 
416  case VCL_TEST_TYPE_BI:
417  case VCL_TEST_TYPE_UNI:
418  stream_test_server_start_stop (conn, rx_cfg);
419  break;
420 
421  case VCL_TEST_TYPE_EXIT:
422  stinf ("Have a great day connection %d!", conn->fd);
423  close (conn->fd);
424  conn_pool_free (conn);
425  stinf ("Closed client fd %d", conn->fd);
426  ssm->nfds--;
427  break;
428 
429  default:
430  stinf ("ERROR: Unknown test type!\n");
431  vcl_test_cfg_dump (rx_cfg, 0 /* is_client */ );
432  break;
433  }
434 
435 done:
436  return 0;
437 }
438 
439 static int
441 {
442  if (conn->cfg.test == VCL_TEST_TYPE_ECHO)
443  return 1;
444 
445  return (conn->stats.rx_bytes < 128
446  || conn->stats.rx_bytes > conn->cfg.total_bytes);
447 }
448 
449 int
450 main (int argc, char **argv)
451 {
452  int client_fd, rv, main_rv = 0, rx_bytes, c, v, i;
454  sock_server_conn_t *conn;
455  vcl_test_cfg_t *rx_cfg;
456  struct sockaddr_storage servaddr;
457  uint16_t port = VCL_TEST_SERVER_PORT;
458  uint32_t servaddr_size;
459 
460  opterr = 0;
461  while ((c = getopt (argc, argv, "6D")) != -1)
462  switch (c)
463  {
464  case '6':
465  ssm->cfg.address_ip6 = 1;
466  break;
467 
468  case 'D':
469  ssm->cfg.transport_udp = 1;
470  break;
471 
472  case '?':
473  switch (optopt)
474  {
475  default:
476  if (isprint (optopt))
477  stinf ("ERROR: Unknown option `-%c'", optopt);
478  else
479  stinf ("ERROR: Unknown option character `\\x%x'.\n", optopt);
480  }
481  /* fall thru */
482  case 'h':
483  default:
485  }
486 
487  if (argc < (optind + 1))
488  {
489  stinf ("ERROR: Insufficient number of arguments!\n");
491  }
492 
493  if (sscanf (argv[optind], "%d", &v) == 1)
494  port = (uint16_t) v;
495  else
496  {
497  stinf ("ERROR: Invalid port (%s)!\n", argv[optind]);
499  }
500 
502 
503  ssm->listen_fd = socket (ssm->cfg.address_ip6 ? AF_INET6 : AF_INET,
504  ssm->cfg.transport_udp ? SOCK_DGRAM : SOCK_STREAM,
505  0);
506 
507  if (ssm->listen_fd < 0)
508  stfail ("main listen()");
509 
510  memset (&servaddr, 0, sizeof (servaddr));
511 
512  if (ssm->cfg.address_ip6)
513  {
514  struct sockaddr_in6 *server_addr = (struct sockaddr_in6 *) &servaddr;
515  servaddr_size = sizeof (*server_addr);
516  server_addr->sin6_family = AF_INET6;
517  server_addr->sin6_addr = in6addr_any;
518  server_addr->sin6_port = htons (port);
519  }
520  else
521  {
522  struct sockaddr_in *server_addr = (struct sockaddr_in *) &servaddr;
523  servaddr_size = sizeof (*server_addr);
524  server_addr->sin_family = AF_INET;
525  server_addr->sin_addr.s_addr = htonl (INADDR_ANY);
526  server_addr->sin_port = htons (port);
527  }
528 
529  rv = bind (ssm->listen_fd, (struct sockaddr *) &servaddr, servaddr_size);
530  if (rv < 0)
531  stfail ("main bind()");
532 
533  rv = fcntl (ssm->listen_fd, F_SETFL, O_NONBLOCK);
534  if (rv < 0)
535  stfail ("main fcntl()");
536 
537  rv = listen (ssm->listen_fd, 10);
538  if (rv < 0)
539  stfail ("main listen()");
540 
541  ssm->epfd = epoll_create (1);
542  if (ssm->epfd < 0)
543  stfail ("main epoll_create()");
544 
545  ssm->listen_ev.events = EPOLLIN;
546  ssm->listen_ev.data.u32 = ~0;
547 
548  rv = epoll_ctl (ssm->epfd, EPOLL_CTL_ADD, ssm->listen_fd, &ssm->listen_ev);
549  if (rv < 0)
550  stfail ("main epoll_ctl()");
551 
552  stinf ("Waiting for a client to connect on port %d...\n", port);
553 
554  while (1)
555  {
556  int num_ev;
557  num_ev = epoll_wait (ssm->epfd, ssm->wait_events,
559  if (num_ev < 0)
560  stfail ("main epoll_wait()");
561 
562  if (num_ev == 0)
563  {
564  stinf ("epoll_wait() timeout!\n");
565  continue;
566  }
567  for (i = 0; i < num_ev; i++)
568  {
569  conn = &ssm->conn_pool[ssm->wait_events[i].data.u32];
570  if (ssm->wait_events[i].events & (EPOLLHUP | EPOLLRDHUP))
571  {
572  close (conn->fd);
573  continue;
574  }
575  if (ssm->wait_events[i].data.u32 == ~0)
576  {
577  new_client ();
578  continue;
579  }
580  else if (ssm->wait_events[i].data.u32 ==
582  {
583  af_unix_echo ();
584  continue;
585  }
586  client_fd = conn->fd;
587 
588  if (EPOLLIN & ssm->wait_events[i].events)
589  {
590  read_again:
591  rx_bytes = sock_test_read (client_fd, conn->buf,
592  conn->buf_size, &conn->stats);
593 
594  if (rx_bytes <= 0)
595  {
596  if (errno == ECONNRESET)
597  {
598  stinf ("Connection reset by peer\n");
599  main_rv = -1;
600  goto done;
601  }
602  else
603  continue;
604  }
605 
606  if (sts_conn_expect_config (conn))
607  {
608  rx_cfg = (vcl_test_cfg_t *) conn->buf;
609  if (rx_cfg->magic == VCL_TEST_CFG_CTRL_MAGIC)
610  {
611  sts_handle_cfg (rx_cfg, conn, rx_bytes);
612  if (!ssm->nfds)
613  {
614  stinf ("All client connections closed.\n\nSERVER: "
615  "May the force be with you!\n\n");
616  goto done;
617  }
618  continue;
619  }
620  }
621 
622  if ((conn->cfg.test == VCL_TEST_TYPE_UNI)
623  || (conn->cfg.test == VCL_TEST_TYPE_BI))
624  {
625  stream_test_server (conn, rx_bytes);
626  if (ioctl (conn->fd, FIONREAD))
627  goto read_again;
628  continue;
629  }
630  else if (isascii (conn->buf[0]))
631  {
632  sts_server_echo (conn, rx_bytes);
633  }
634  else
635  {
636  stwrn ("FIFO not drained! extra bytes %d", rx_bytes);
637  }
638  }
639  }
640  }
641 
642 done:
643  close (ssm->listen_fd);
644  close (ssm->af_unix_listen_fd);
645  unlink ((const char *) SOCK_TEST_AF_UNIX_FILENAME);
646 
647  if (ssm->conn_pool)
648  free (ssm->conn_pool);
649 
650  return main_rv;
651 }
652 
653 /*
654  * fd.io coding-style-patch-verification: ON
655  *
656  * Local Variables:
657  * eval: (c-set-style "gnu")
658  * End:
659  */
vcl_test_cfg_t::magic
uint32_t magic
Definition: vcl_test.h:94
sock_server_main_t::serveraddr
struct sockaddr_un serveraddr
Definition: sock_test_server.c:61
sts_server_echo
static void sts_server_echo(sock_server_conn_t *conn, int rx_bytes)
Definition: sock_test_server.c:356
buffer
char * buffer
Definition: cJSON.h:163
realloc
void * realloc(void *p, size_t size)
Definition: mem.c:67
VCL_TEST_TYPE_EXIT
@ VCL_TEST_TYPE_EXIT
Definition: vcl_test.h:82
sock_server_main_t
Definition: sock_test_server.c:51
conn_pool_alloc
static sock_server_conn_t * conn_pool_alloc(void)
Definition: sock_test_server.c:101
sock_server_main
sock_server_main_t sock_server_main
Definition: sock_test_server.c:72
sock_server_main_t::af_unix_xacts
uint32_t af_unix_xacts
Definition: sock_test_server.c:62
VCL_TEST_TYPE_NONE
@ VCL_TEST_TYPE_NONE
Definition: vcl_test.h:78
sock_server_cfg_t::transport_udp
uint32_t transport_udp
Definition: sock_test_server.c:48
stream_test_server
static void stream_test_server(sock_server_conn_t *conn, int rx_bytes)
Definition: sock_test_server.c:216
SOCK_TEST_MIXED_EPOLL_DATA
#define SOCK_TEST_MIXED_EPOLL_DATA
Definition: sock_test.h:26
string.h
sock_server_conn_t::is_alloc
uint8_t is_alloc
Definition: sock_test_server.c:36
sock_server_main_t::listen_fd
int listen_fd
Definition: sock_test_server.c:53
stinf
#define stinf(_fmt, _args...)
Definition: sock_test.h:32
main
int main(int argc, char **argv)
Definition: sock_test_server.c:450
new_client
static void new_client(void)
Definition: sock_test_server.c:269
SOCK_TEST_AF_UNIX_FILENAME
#define SOCK_TEST_AF_UNIX_FILENAME
Definition: sock_test.h:25
vcl_test_cfg_t::rxbuf_size
uint64_t rxbuf_size
Definition: vcl_test.h:105
sts_handle_cfg
static int sts_handle_cfg(vcl_test_cfg_t *rx_cfg, sock_server_conn_t *conn, int rx_bytes)
Definition: sock_test_server.c:376
SOCK_SERVER_MAX_TEST_CONN
#define SOCK_SERVER_MAX_TEST_CONN
Definition: sock_test_server.c:31
vcl_test_cfg_t::test
uint32_t test
Definition: vcl_test.h:96
stream_test_server_start_stop
static void stream_test_server_start_stop(sock_server_conn_t *conn, vcl_test_cfg_t *rx_cfg)
Definition: sock_test_server.c:143
port
u16 port
Definition: lb_types.api:73
sts_conn_expect_config
static int sts_conn_expect_config(sock_server_conn_t *conn)
Definition: sock_test_server.c:440
vcl_test_cfg_dump
static void vcl_test_cfg_dump(vcl_test_cfg_t *cfg, uint8_t is_client)
Definition: vcl_test.h:298
sock_server_conn_t
Definition: sock_test_server.c:34
print_usage_and_exit
void print_usage_and_exit(void)
Definition: sock_test_server.c:343
vcl_test_cfg_t::ctrl_handle
uint32_t ctrl_handle
Definition: vcl_test.h:98
SOCK_TEST_BANNER_STRING
#define SOCK_TEST_BANNER_STRING
Definition: sock_test.h:29
VCL_TEST_SERVER_PORT
#define VCL_TEST_SERVER_PORT
Definition: vcl_test.h:60
stfail
#define stfail(_fn)
Definition: sock_test.h:46
sock_test_read
static int sock_test_read(int fd, uint8_t *buf, uint32_t nbytes, vcl_test_stats_t *stats)
Definition: sock_test.h:54
sock_server_main_t::num_conn
size_t num_conn
Definition: sock_test_server.c:63
sock_server_main_t::conn_pool_size
size_t conn_pool_size
Definition: sock_test_server.c:64
VCL_TEST_TYPE_ECHO
@ VCL_TEST_TYPE_ECHO
Definition: vcl_test.h:79
sock_server_main_t::nfds
int nfds
Definition: sock_test_server.c:66
vcl_test_stats_t::start
struct timespec start
Definition: vcl_test.h:121
sock_server_main_t::rd_fdset
fd_set rd_fdset
Definition: sock_test_server.c:67
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
vcl_test_buf_alloc
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:230
vcl_test_stats_t::stop
struct timespec stop
Definition: vcl_test.h:122
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
vcl_test_t
vcl_test_t
Definition: vcl_test.h:76
socket_server_echo_af_unix_init
static int socket_server_echo_af_unix_init(sock_server_main_t *ssm)
Definition: sock_test_server.c:306
time.h
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
vcl_test_stats_dump
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:336
sock_server_conn_t::fd
int fd
Definition: sock_test_server.c:37
sock_server_main_t::epfd
int epfd
Definition: sock_test_server.c:55
vcl_test_cfg_t::txbuf_size
uint64_t txbuf_size
Definition: vcl_test.h:106
VCL_TEST_TYPE_BI
@ VCL_TEST_TYPE_BI
Definition: vcl_test.h:81
vcl_test_cfg_t::total_bytes
uint64_t total_bytes
Definition: vcl_test.h:108
sock_server_conn_t::stats
vcl_test_stats_t stats
Definition: sock_test_server.c:41
vcl_test_cfg_t::verbose
uint32_t verbose
Definition: vcl_test.h:102
sync_config_and_reply
static void sync_config_and_reply(sock_server_conn_t *conn, vcl_test_cfg_t *rx_cfg)
Definition: sock_test_server.c:126
VCL_TEST_SEPARATOR_STRING
#define VCL_TEST_SEPARATOR_STRING
Definition: vcl_test.h:74
sock_server_main_t::listen_ev
struct epoll_event listen_ev
Definition: sock_test_server.c:56
sock_server_conn_t::buf_size
uint32_t buf_size
Definition: sock_test_server.c:39
sock_server_conn_t::buf
uint8_t * buf
Definition: sock_test_server.c:38
sock_server_main_t::af_unix_fd
int af_unix_fd
Definition: sock_test_server.c:59
SOCK_SERVER_MAX_EPOLL_EVENTS
#define SOCK_SERVER_MAX_EPOLL_EVENTS
Definition: sock_test_server.c:32
vcl_test_stats_t::rx_bytes
uint64_t rx_bytes
Definition: vcl_test.h:114
sock_server_cfg_t::port
uint32_t port
Definition: sock_test_server.c:46
buf
u64 buf
Definition: application.c:493
sock_server_main_t::af_unix_listen_ev
struct epoll_event af_unix_listen_ev
Definition: sock_test_server.c:60
sock_server_conn_t::cfg
vcl_test_cfg_t cfg
Definition: sock_test_server.c:40
vcl_test_stats_accumulate
static void vcl_test_stats_accumulate(vcl_test_stats_t *accum, vcl_test_stats_t *incr)
Definition: vcl_test.h:188
sock_server_main_t::af_unix_listen_fd
int af_unix_listen_fd
Definition: sock_test_server.c:58
SOCK_TEST_AF_UNIX_ACCEPT_DATA
#define SOCK_TEST_AF_UNIX_ACCEPT_DATA
Definition: sock_test.h:27
sock_server_main_t::wr_fdset
fd_set wr_fdset
Definition: sock_test_server.c:68
conn_pool_free
static void conn_pool_free(sock_server_conn_t *conn)
Definition: sock_test_server.c:119
sock_server_cfg_t
Definition: sock_test_server.c:44
sock_test.h
sock_server_main_t::cfg
sock_server_cfg_t cfg
Definition: sock_test_server.c:54
free
void free(void *p)
Definition: mem.c:42
VCL_TEST_CFG_CTRL_MAGIC
#define VCL_TEST_CFG_CTRL_MAGIC
Definition: vcl_test.h:63
vcl_test_cfg_init
static void vcl_test_cfg_init(vcl_test_cfg_t *cfg)
Definition: vcl_test.h:201
sock_server_main_t::wait_events
struct epoll_event wait_events[SOCK_SERVER_MAX_EPOLL_EVENTS]
Definition: sock_test_server.c:57
rv
int __clib_unused rv
Definition: application.c:491
sock_server_main_t::conn_pool
sock_server_conn_t * conn_pool
Definition: sock_test_server.c:65
stwrn
#define stwrn(_fmt, _args...)
Definition: sock_test.h:34
sock_test_write
static int sock_test_write(int fd, uint8_t *buf, uint32_t nbytes, vcl_test_stats_t *stats, uint32_t verbose)
Definition: sock_test.h:87
conn_pool_expand
static void conn_pool_expand(size_t expand_size)
Definition: sock_test_server.c:75
vcl_test_cfg_t
Definition: vcl_test.h:92
vcl_test_stats_t
Definition: vcl_test.h:111
vcl_test_cfg_t::num_writes
uint64_t num_writes
Definition: vcl_test.h:107
sock_server_cfg_t::address_ip6
uint32_t address_ip6
Definition: sock_test_server.c:47
af_unix_echo
static void af_unix_echo(void)
Definition: sock_test_server.c:232
VCL_TEST_TYPE_UNI
@ VCL_TEST_TYPE_UNI
Definition: vcl_test.h:80