FD.io VPP  v19.08.1-401-g8e4ed521a
Vector Packet Processing
session_cli.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  */
16 #include <vnet/session/session.h>
17 
18 u8 *
19 format_session_fifos (u8 * s, va_list * args)
20 {
21  session_t *ss = va_arg (*args, session_t *);
22  int verbose = va_arg (*args, int);
23  session_event_t _e, *e = &_e;
24  u8 found;
25 
26  if (!ss->rx_fifo || !ss->tx_fifo)
27  return s;
28 
29  s = format (s, " Rx fifo: %U", format_svm_fifo, ss->rx_fifo, verbose);
30  if (verbose > 2 && ss->rx_fifo->has_event)
31  {
32  found = session_node_lookup_fifo_event (ss->rx_fifo, e);
33  s = format (s, " session node event: %s\n",
34  found ? "found" : "not found");
35  }
36  s = format (s, " Tx fifo: %U", format_svm_fifo, ss->tx_fifo, verbose);
37  if (verbose > 2 && ss->tx_fifo->has_event)
38  {
39  found = session_node_lookup_fifo_event (ss->tx_fifo, e);
40  s = format (s, " session node event: %s\n",
41  found ? "found" : "not found");
42  }
43  return s;
44 }
45 
46 /**
47  * Format stream session as per the following format
48  *
49  * verbose:
50  * "Connection", "Rx fifo", "Tx fifo", "Session Index"
51  * non-verbose:
52  * "Connection"
53  */
54 u8 *
55 format_session (u8 * s, va_list * args)
56 {
57  session_t *ss = va_arg (*args, session_t *);
58  int verbose = va_arg (*args, int);
60  u8 *str = 0;
61 
62  if (ss->session_state >= SESSION_STATE_TRANSPORT_DELETED)
63  {
64  s = format (s, "[%u:%u] CLOSED", ss->thread_index, ss->session_index);
65  return s;
66  }
67 
68  if (verbose == 1)
69  {
70  u8 post_accept = ss->session_state >= SESSION_STATE_ACCEPTING;
71  u8 hasf = post_accept
73  u32 rxf, txf;
74 
75  rxf = hasf ? svm_fifo_max_dequeue (ss->rx_fifo) : 0;
76  txf = hasf ? svm_fifo_max_dequeue (ss->tx_fifo) : 0;
77  str = format (0, "%-10u%-10u", rxf, txf);
78  }
79 
80  if (ss->session_state >= SESSION_STATE_ACCEPTING
81  || ss->session_state == SESSION_STATE_CREATED)
82  {
83  s = format (s, "%U", format_transport_connection, tp,
84  ss->connection_index, ss->thread_index, verbose);
85  if (verbose == 1)
86  s = format (s, "%v", str);
87  if (verbose > 1)
88  s = format (s, "%U", format_session_fifos, ss, verbose);
89  }
90  else if (ss->session_state == SESSION_STATE_LISTENING)
91  {
93  tp, ss->connection_index, ss->thread_index, verbose, str);
94  if (verbose > 1)
95  s = format (s, "\n%U", format_session_fifos, ss, verbose);
96  }
97  else if (ss->session_state == SESSION_STATE_CONNECTING)
98  {
100  tp, ss->connection_index, ss->thread_index, str);
101  }
102  else
103  {
104  clib_warning ("Session in state: %d!", ss->session_state);
105  }
106  vec_free (str);
107 
108  return s;
109 }
110 
111 uword
113 {
114  u8 *proto = va_arg (*args, u8 *);
115  u32 *fib_index = va_arg (*args, u32 *);
116  ip46_address_t *lcl = va_arg (*args, ip46_address_t *);
117  ip46_address_t *rmt = va_arg (*args, ip46_address_t *);
118  u16 *lcl_port = va_arg (*args, u16 *);
119  u16 *rmt_port = va_arg (*args, u16 *);
120  u8 *is_ip4 = va_arg (*args, u8 *);
121  u8 tuple_is_set = 0;
122  u32 vrf = ~0;
123 
124  clib_memset (lcl, 0, sizeof (*lcl));
125  clib_memset (rmt, 0, sizeof (*rmt));
126 
127  if (unformat (input, "tcp"))
128  {
129  *proto = TRANSPORT_PROTO_TCP;
130  }
131  else if (unformat (input, "udp"))
132  {
133  *proto = TRANSPORT_PROTO_UDP;
134  }
135  else
136  return 0;
137 
138  if (unformat (input, "vrf %u", &vrf))
139  ;
140 
141  if (unformat (input, "%U:%d->%U:%d", unformat_ip4_address, &lcl->ip4,
142  lcl_port, unformat_ip4_address, &rmt->ip4, rmt_port))
143  {
144  *is_ip4 = 1;
145  tuple_is_set = 1;
146  }
147  else if (unformat (input, "%U:%d->%U:%d", unformat_ip6_address, &lcl->ip6,
148  lcl_port, unformat_ip6_address, &rmt->ip6, rmt_port))
149  {
150  *is_ip4 = 0;
151  tuple_is_set = 1;
152  }
153 
154  if (vrf != ~0)
155  {
156  fib_protocol_t fib_proto;
157  fib_proto = *is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
158  *fib_index = fib_table_find (fib_proto, vrf);
159  }
160 
161  return tuple_is_set;
162 }
163 
164 uword
165 unformat_session_state (unformat_input_t * input, va_list * args)
166 {
167  session_state_t *state = va_arg (*args, session_state_t *);
168  u8 *state_vec = 0;
169  int rv = 0;
170 
171 #define _(sym, str) \
172  if (unformat (input, str)) \
173  { \
174  *state = SESSION_STATE_ ## sym; \
175  rv = 1; \
176  goto done; \
177  }
179 #undef _
180 done:
181  vec_free (state_vec);
182  return rv;
183 }
184 
185 uword
186 unformat_session (unformat_input_t * input, va_list * args)
187 {
188  session_t **result = va_arg (*args, session_t **);
189  u32 lcl_port = 0, rmt_port = 0, fib_index = 0;
190  ip46_address_t lcl, rmt;
191  session_t *s;
192  u8 proto = ~0;
193  u8 is_ip4 = 0;
194 
195  if (!unformat (input, "%U", unformat_stream_session_id, &proto, &fib_index,
196  &lcl, &rmt, &lcl_port, &rmt_port, &is_ip4))
197  return 0;
198 
199  if (is_ip4)
200  s = session_lookup_safe4 (fib_index, &lcl.ip4, &rmt.ip4,
201  clib_host_to_net_u16 (lcl_port),
202  clib_host_to_net_u16 (rmt_port), proto);
203  else
204  s = session_lookup_safe6 (fib_index, &lcl.ip6, &rmt.ip6,
205  clib_host_to_net_u16 (lcl_port),
206  clib_host_to_net_u16 (rmt_port), proto);
207  if (s)
208  {
209  *result = s;
211  return 1;
212  }
213  return 0;
214 }
215 
216 uword
218 {
219  transport_connection_t **result = va_arg (*args, transport_connection_t **);
220  u32 suggested_proto = va_arg (*args, u32);
222  u8 proto = ~0;
223  ip46_address_t lcl, rmt;
224  u32 lcl_port = 0, rmt_port = 0, fib_index = 0;
225  u8 is_ip4 = 0;
226 
227  if (!unformat (input, "%U", unformat_stream_session_id, &fib_index, &proto,
228  &lcl, &rmt, &lcl_port, &rmt_port, &is_ip4))
229  return 0;
230 
231  proto = (proto == (u8) ~ 0) ? suggested_proto : proto;
232  if (proto == (u8) ~ 0)
233  return 0;
234  if (is_ip4)
235  tc = session_lookup_connection4 (fib_index, &lcl.ip4, &rmt.ip4,
236  clib_host_to_net_u16 (lcl_port),
237  clib_host_to_net_u16 (rmt_port), proto);
238  else
239  tc = session_lookup_connection6 (fib_index, &lcl.ip6, &rmt.ip6,
240  clib_host_to_net_u16 (lcl_port),
241  clib_host_to_net_u16 (rmt_port), proto);
242 
243  if (tc)
244  {
245  *result = tc;
246  return 1;
247  }
248  return 0;
249 }
250 
251 static void
253 {
255  u32 n_closed, thread_index;
256  session_t *pool, *s;
257 
258  for (thread_index = 0; thread_index < vec_len (smm->wrk); thread_index++)
259  {
260  pool = smm->wrk[thread_index].sessions;
261 
262  if (!pool_elts (pool))
263  {
264  vlib_cli_output (vm, "Thread %d: no sessions", thread_index);
265  continue;
266  }
267 
268  if (!verbose)
269  {
270  vlib_cli_output (vm, "Thread %d: %d sessions", thread_index,
271  pool_elts (pool));
272  continue;
273  }
274 
275  if (pool_elts (pool) > 50)
276  {
277  vlib_cli_output (vm, "Thread %u: %d sessions. Verbose output "
278  "suppressed. For more details use filters.",
279  thread_index, pool_elts (pool));
280  continue;
281  }
282 
283  if (verbose == 1)
284  vlib_cli_output (vm, "%s%-50s%-15s%-10s%-10s",
285  thread_index ? "\n" : "",
286  "Connection", "State", "Rx-f", "Tx-f");
287 
288  n_closed = 0;
289 
290  /* *INDENT-OFF* */
291  pool_foreach(s, pool, ({
292  if (s->session_state >= SESSION_STATE_TRANSPORT_DELETED)
293  {
294  n_closed += 1;
295  continue;
296  }
297  vlib_cli_output (vm, "%U", format_session, s, verbose);
298  }));
299  /* *INDENT-ON* */
300 
301  if (!n_closed)
302  vlib_cli_output (vm, "Thread %d: active sessions %u", thread_index,
303  pool_elts (pool) - n_closed);
304  else
305  vlib_cli_output (vm, "Thread %d: active sessions %u closed %u",
306  thread_index, pool_elts (pool) - n_closed, n_closed);
307  }
308 }
309 
310 static int
313 {
314  if (states)
315  {
317  vec_foreach (state, states) if (s->session_state == *state)
318  goto check_transport;
319  return 0;
320  }
321 
322 check_transport:
323 
324  if (tp != TRANSPORT_N_PROTO && session_get_transport_proto (s) != tp)
325  return 0;
326 
327  return 1;
328 }
329 
330 static void
332  u32 start, u32 end, session_state_t * states,
333  transport_proto_t tp, int verbose)
334 {
335  u8 output_suppressed = 0;
336  session_worker_t *wrk;
337  session_t *pool, *s;
338  u32 count = 0, max_index;
339  int i;
340 
341  wrk = session_main_get_worker_if_valid (thread_index);
342  if (!wrk)
343  {
344  vlib_cli_output (vm, "invalid thread index %u", thread_index);
345  return;
346  }
347 
348  pool = wrk->sessions;
349 
350  if (tp == TRANSPORT_N_PROTO && states == 0 && !verbose
351  && (start == 0 && end == ~0))
352  {
353  vlib_cli_output (vm, "Thread %d: %u sessions", thread_index,
354  pool_elts (pool));
355  return;
356  }
357 
358  max_index = pool_len (pool) ? pool_len (pool) - 1 : 0;
359  for (i = start; i <= clib_min (end, max_index); i++)
360  {
361  if (pool_is_free_index (pool, i))
362  continue;
363 
364  s = pool_elt_at_index (pool, i);
365 
366  if (session_cli_filter_check (s, states, tp))
367  {
368  count += 1;
369  if (verbose)
370  {
371  if (count > 50 || (verbose > 1 && count > 10))
372  {
373  output_suppressed = 1;
374  continue;
375  }
376  if (s->session_state < SESSION_STATE_TRANSPORT_DELETED)
377  vlib_cli_output (vm, "%U", format_session, s, verbose);
378  }
379  }
380  }
381 
382  if (!output_suppressed)
383  vlib_cli_output (vm, "Thread %d: %u sessions matched filter",
384  thread_index, count);
385  else
386  vlib_cli_output (vm, "Thread %d: %u sessions matched filter. Not all"
387  " shown. Use finer grained filter.", thread_index,
388  count);
389 }
390 
391 static void
393 {
394 #define _(sym, str, sstr) vlib_cli_output (vm, str);
396 #undef _
397 }
398 
399 static void
401 {
402 #define _(sym, str) vlib_cli_output (vm, str);
404 #undef _
405 }
406 
407 static clib_error_t *
409  vlib_cli_command_t * cmd)
410 {
411  u8 one_session = 0, do_listeners = 0, sst, do_elog = 0, do_filter = 0;
412  u32 track_index, thread_index = 0, start = 0, end = ~0, session_index;
413  unformat_input_t _line_input, *line_input = &_line_input;
414  transport_proto_t transport_proto = TRANSPORT_N_PROTO;
415  session_state_t state = SESSION_N_STATES, *states = 0;
417  clib_error_t *error = 0;
418  app_worker_t *app_wrk;
419  u32 transport_index;
420  const u8 *app_name;
421  int verbose = 0;
422  session_t *s;
423 
425 
426  if (!unformat_user (input, unformat_line_input, line_input))
427  {
429  return 0;
430  }
431 
432  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
433  {
434  if (unformat (line_input, "verbose %d", &verbose))
435  ;
436  else if (unformat (line_input, "verbose"))
437  verbose = 1;
438  else if (unformat (line_input, "listeners %U", unformat_transport_proto,
439  &transport_proto))
440  do_listeners = 1;
441  else if (unformat (line_input, "%U", unformat_session, &s))
442  {
443  one_session = 1;
444  }
445  else if (unformat (line_input, "thread %u index %u", &thread_index,
446  &session_index))
447  {
448  s = session_get_if_valid (session_index, thread_index);
449  if (!s)
450  {
451  vlib_cli_output (vm, "session is not allocated");
452  goto done;
453  }
454  one_session = 1;
455  }
456  else if (unformat (line_input, "thread %u", &thread_index))
457  {
458  do_filter = 1;
459  }
460  else
461  if (unformat (line_input, "state %U", unformat_session_state, &state))
462  {
463  vec_add1 (states, state);
464  do_filter = 1;
465  }
466  else if (unformat (line_input, "proto %U index %u",
467  unformat_transport_proto, &transport_proto,
468  &transport_index))
469  {
471  tc = transport_get_connection (transport_proto, transport_index,
472  thread_index);
473  if (!tc)
474  {
475  vlib_cli_output (vm, "transport connection %u thread %u is not"
476  " allocated", transport_index, thread_index);
477  goto done;
478  }
479  s = session_get_if_valid (tc->s_index, thread_index);
480  if (!s)
481  {
482  vlib_cli_output (vm, "session for transport connection %u "
483  "thread %u does not exist", transport_index,
484  thread_index);
485  goto done;
486  }
487  one_session = 1;
488  }
489  else if (unformat (line_input, "proto %U", unformat_transport_proto,
490  &transport_proto))
491  do_filter = 1;
492  else if (unformat (line_input, "range %u %u", &start, &end))
493  do_filter = 1;
494  else if (unformat (line_input, "range %u", &start))
495  {
496  end = start + 50;
497  do_filter = 1;
498  }
499  else if (unformat (line_input, "elog"))
500  do_elog = 1;
501  else if (unformat (line_input, "protos"))
502  {
504  goto done;
505  }
506  else if (unformat (line_input, "states"))
507  {
509  goto done;
510  }
511  else
512  {
513  error = clib_error_return (0, "unknown input `%U'",
514  format_unformat_error, line_input);
515  goto done;
516  }
517  }
518 
519  if (one_session)
520  {
521  u8 *str = format (0, "%U", format_session, s, 3);
522  if (do_elog && s->session_state != SESSION_STATE_LISTENING)
523  {
524  elog_main_t *em = &vm->elog_main;
526  f64 dt;
527 
528  tc = session_get_transport (s);
529  track_index = transport_elog_track_index (tc);
530  dt = (em->init_time.cpu - vm->clib_time.init_cpu_time)
532  if (track_index != ~0)
533  str = format (str, " session elog:\n%U", format_elog_track, em,
534  dt, track_index);
535  }
536  vlib_cli_output (vm, "%v", str);
537  vec_free (str);
538  goto done;
539  }
540 
541  if (do_listeners)
542  {
543  sst = session_type_from_proto_and_ip (transport_proto, 1);
544  vlib_cli_output (vm, "%-50s%-24s", "Listener", "App");
545  /* *INDENT-OFF* */
546  pool_foreach (s, smm->wrk[0].sessions, ({
547  if (s->session_state != SESSION_STATE_LISTENING
548  || s->session_type != sst)
549  continue;
550  app_wrk = app_worker_get (s->app_wrk_index);
551  app_name = application_name_from_index (app_wrk->app_index);
552  vlib_cli_output (vm, "%U%-25v%", format_session, s, 0,
553  app_name);
554  }));
555  /* *INDENT-ON* */
556  goto done;
557  }
558 
559  if (do_filter)
560  {
561  if (end < start)
562  {
563  error = clib_error_return (0, "invalid range start: %u end: %u",
564  start, end);
565  goto done;
566  }
567  session_cli_show_session_filter (vm, thread_index, start, end, states,
568  transport_proto, verbose);
569  goto done;
570  }
571 
572  session_cli_show_all_sessions (vm, verbose);
573 
574 done:
575  unformat_free (line_input);
576  vec_free (states);
577  return error;
578 }
579 
580 /* *INDENT-OFF* */
581 VLIB_CLI_COMMAND (vlib_cli_show_session_command) =
582 {
583  .path = "show session",
584  .short_help = "show session [verbose [n]] [listeners <proto>] "
585  "[<session-id> [elog]] [thread <n> [index <n>] "
586  "[proto <proto>] [state <state>] [range <min> [<max>]] "
587  "[protos] [states] ",
588  .function = show_session_command_fn,
589 };
590 /* *INDENT-ON* */
591 
592 static int
594 {
595  app_worker_t *server_wrk = app_worker_get (s->app_wrk_index);
596  app_worker_close_notify (server_wrk, s);
597  return 0;
598 }
599 
600 static clib_error_t *
602  vlib_cli_command_t * cmd)
603 {
605  u32 thread_index = 0, clear_all = 0;
606  session_worker_t *wrk;
607  u32 session_index = ~0;
608  session_t *session;
609 
610  if (!smm->is_enabled)
611  {
612  return clib_error_return (0, "session layer is not enabled");
613  }
614 
616  {
617  if (unformat (input, "thread %d", &thread_index))
618  ;
619  else if (unformat (input, "session %d", &session_index))
620  ;
621  else if (unformat (input, "all"))
622  clear_all = 1;
623  else
624  return clib_error_return (0, "unknown input `%U'",
625  format_unformat_error, input);
626  }
627 
628  if (!clear_all && session_index == ~0)
629  return clib_error_return (0, "session <nn> required, but not set.");
630 
631  if (session_index != ~0)
632  {
633  session = session_get_if_valid (session_index, thread_index);
634  if (!session)
635  return clib_error_return (0, "no session %d on thread %d",
636  session_index, thread_index);
637  clear_session (session);
638  }
639 
640  if (clear_all)
641  {
642  /* *INDENT-OFF* */
643  vec_foreach (wrk, smm->wrk)
644  {
645  pool_foreach(session, wrk->sessions, ({
646  clear_session (session);
647  }));
648  };
649  /* *INDENT-ON* */
650  }
651 
652  return 0;
653 }
654 
655 /* *INDENT-OFF* */
656 VLIB_CLI_COMMAND (clear_session_command, static) =
657 {
658  .path = "clear session",
659  .short_help = "clear session thread <thread> session <index>",
660  .function = clear_session_command_fn,
661 };
662 /* *INDENT-ON* */
663 
664 static clib_error_t *
666  unformat_input_t * input,
667  vlib_cli_command_t * cmd)
668 {
669  session_t *s = 0;
670  u8 is_rx = 0, *str = 0;
671 
673  {
674  if (unformat (input, "%U", unformat_session, &s))
675  ;
676  else if (unformat (input, "rx"))
677  is_rx = 1;
678  else if (unformat (input, "tx"))
679  is_rx = 0;
680  else
681  return clib_error_return (0, "unknown input `%U'",
682  format_unformat_error, input);
683  }
684 
685  if (!SVM_FIFO_TRACE)
686  {
687  vlib_cli_output (vm, "fifo tracing not enabled");
688  return 0;
689  }
690 
691  if (!s)
692  {
693  vlib_cli_output (vm, "could not find session");
694  return 0;
695  }
696 
697  str = is_rx ?
698  svm_fifo_dump_trace (str, s->rx_fifo) :
699  svm_fifo_dump_trace (str, s->tx_fifo);
700 
701  vlib_cli_output (vm, "%v", str);
702  return 0;
703 }
704 
705 /* *INDENT-OFF* */
706 VLIB_CLI_COMMAND (show_session_fifo_trace_command, static) =
707 {
708  .path = "show session fifo trace",
709  .short_help = "show session fifo trace <session>",
711 };
712 /* *INDENT-ON* */
713 
714 static clib_error_t *
716  vlib_cli_command_t * cmd)
717 {
718  session_t *s = 0;
719  u8 is_rx = 0, *str = 0;
720 
722  {
723  if (unformat (input, "%U", unformat_session, &s))
724  ;
725  else if (unformat (input, "rx"))
726  is_rx = 1;
727  else
728  return clib_error_return (0, "unknown input `%U'",
729  format_unformat_error, input);
730  }
731 
732  if (!SVM_FIFO_TRACE)
733  {
734  vlib_cli_output (vm, "fifo tracing not enabled");
735  return 0;
736  }
737 
738  if (!s)
739  {
740  vlib_cli_output (vm, "could not find session");
741  return 0;
742  }
743 
744  str = is_rx ?
745  svm_fifo_replay (str, s->rx_fifo, 0, 1) :
746  svm_fifo_replay (str, s->tx_fifo, 0, 1);
747 
748  vlib_cli_output (vm, "%v", str);
749  return 0;
750 }
751 
752 /* *INDENT-OFF* */
753 VLIB_CLI_COMMAND (session_replay_fifo_trace_command, static) =
754 {
755  .path = "session replay fifo",
756  .short_help = "session replay fifo <session>",
757  .function = session_replay_fifo_command_fn,
758 };
759 /* *INDENT-ON* */
760 
761 static clib_error_t *
763  vlib_cli_command_t * cmd)
764 {
765  unformat_input_t _line_input, *line_input = &_line_input;
766  u8 is_en = 1;
767  clib_error_t *error;
768 
769  if (!unformat_user (input, unformat_line_input, line_input))
770  return clib_error_return (0, "expected enable | disable");
771 
772  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
773  {
774  if (unformat (line_input, "enable"))
775  is_en = 1;
776  else if (unformat (line_input, "disable"))
777  is_en = 0;
778  else
779  {
780  error = clib_error_return (0, "unknown input `%U'",
781  format_unformat_error, line_input);
782  unformat_free (line_input);
783  return error;
784  }
785  }
786 
787  unformat_free (line_input);
788  return vnet_session_enable_disable (vm, is_en);
789 }
790 
791 /* *INDENT-OFF* */
792 VLIB_CLI_COMMAND (session_enable_disable_command, static) =
793 {
794  .path = "session",
795  .short_help = "session [enable|disable]",
796  .function = session_enable_disable_fn,
797 };
798 /* *INDENT-ON* */
799 
800 /*
801  * fd.io coding-style-patch-verification: ON
802  *
803  * Local Variables:
804  * eval: (c-set-style "gnu")
805  * End:
806  */
u32 connection_index
Index of the transport connection associated to the session.
u8 * format_transport_connection(u8 *s, va_list *args)
Definition: transport.c:84
u8 * format_session_fifos(u8 *s, va_list *args)
Definition: session_cli.c:19
#define clib_min(x, y)
Definition: clib.h:295
svm_fifo_t * tx_fifo
session_main_t session_main
Definition: session.c:26
format_function_t format_svm_fifo
Definition: svm_fifo.h:489
u32 session_index
Index in thread pool where session was allocated.
#define session_cli_return_if_not_enabled()
Definition: session.h:616
elog_time_stamp_t init_time
Timestamps.
Definition: elog.h:172
session_t * session_lookup_safe4(u32 fib_index, ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
Lookup session with ip4 and transport layer information.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
transport_connection_t * session_get_transport(session_t *s)
Definition: session.c:1459
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
session_worker_t * wrk
Worker contexts.
Definition: session.h:147
static session_t * session_get_if_valid(u64 si, u32 thread_index)
Definition: session.h:300
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
static transport_proto_t session_get_transport_proto(session_t *s)
int i
static int clear_session(session_t *s)
Definition: session_cli.c:593
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
static clib_error_t * clear_session_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: session_cli.c:601
static void session_pool_remove_peeker(u32 thread_index)
Definition: session.h:351
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
clib_time_t clib_time
Definition: main.h:87
session_t * session_lookup_safe6(u32 fib_index, ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
Lookup session with ip6 and transport layer information.
unsigned char u8
Definition: types.h:56
#define pool_len(p)
Number of elements in pool vector.
Definition: pool.h:140
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
session_t * sessions
Worker session pool.
Definition: session.h:81
double f64
Definition: types.h:142
transport_connection_t * session_lookup_connection6(u32 fib_index, ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
Lookup connection with ip6 and transport layer information.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
unformat_function_t unformat_ip4_address
Definition: format.h:70
#define foreach_transport_proto
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Fifo max bytes to dequeue.
Definition: svm_fifo.h:527
#define clib_error_return(e, args...)
Definition: error.h:99
static clib_error_t * show_session_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: session_cli.c:408
vhost_vring_state_t state
Definition: vhost_user.h:146
unsigned int u32
Definition: types.h:88
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1080
session_state_t
transport_connection_t * session_lookup_connection4(u32 fib_index, ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto)
Lookup connection with ip4 and transport layer information.
uword unformat_session_state(unformat_input_t *input, va_list *args)
Definition: session_cli.c:165
unformat_function_t unformat_line_input
Definition: format.h:283
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:514
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
u8 is_enabled
Session manager is enabled.
Definition: session.h:168
uword unformat_transport_connection(unformat_input_t *input, va_list *args)
Definition: session_cli.c:217
f64 seconds_per_clock
Definition: time.h:58
uword unformat_session(unformat_input_t *input, va_list *args)
Definition: session_cli.c:186
u8 * svm_fifo_replay(u8 *s, svm_fifo_t *f, u8 no_read, u8 verbose)
Definition: svm_fifo.c:1292
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1604
uword unformat_stream_session_id(unformat_input_t *input, va_list *args)
Definition: session_cli.c:112
unformat_function_t unformat_ip6_address
Definition: format.h:91
#define UNFORMAT_END_OF_INPUT
Definition: format.h:145
vlib_main_t * vm
Definition: buffer.c:323
static transport_connection_t * transport_get_connection(transport_proto_t tp, u32 conn_index, u8 thread_index)
Definition: transport.h:117
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
static void session_cli_print_session_states(vlib_main_t *vm)
Definition: session_cli.c:400
#define clib_warning(format, args...)
Definition: error.h:59
elog_main_t elog_main
Definition: main.h:193
struct _transport_connection transport_connection_t
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:283
static u32 transport_elog_track_index(transport_connection_t *tc)
Definition: transport.h:166
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:161
#define SVM_FIFO_TRACE
Definition: svm_fifo.h:37
static void session_cli_show_session_filter(vlib_main_t *vm, u32 thread_index, u32 start, u32 end, session_state_t *states, transport_proto_t tp, int verbose)
Definition: session_cli.c:331
uword unformat_transport_proto(unformat_input_t *input, va_list *args)
Definition: transport.c:140
static void session_cli_print_transport_protos(vlib_main_t *vm)
Definition: session_cli.c:392
u64 cpu
CPU cycle counter.
Definition: elog.h:126
static int session_cli_filter_check(session_t *s, session_state_t *states, transport_proto_t tp)
Definition: session_cli.c:311
#define foreach_session_state
u8 * format_transport_half_open_connection(u8 *s, va_list *args)
Definition: transport.c:125
enum _transport_proto transport_proto_t
size_t count
Definition: vapi.c:47
u8 thread_index
Index of the thread that allocated the session.
u8 * format_session(u8 *s, va_list *args)
Format stream session as per the following format.
Definition: session_cli.c:55
u8 * svm_fifo_dump_trace(u8 *s, svm_fifo_t *f)
Definition: svm_fifo.c:1268
app_worker_t * app_worker_get(u32 wrk_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u8 * format_elog_track(u8 *s, va_list *args)
Definition: elog.c:408
volatile u8 session_state
State in session layer state machine.
u64 uword
Definition: types.h:112
static void unformat_free(unformat_input_t *i)
Definition: format.h:163
connectionless service
u8 * format_transport_listen_connection(u8 *s, va_list *args)
Definition: transport.c:111
static clib_error_t * session_replay_fifo_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: session_cli.c:715
static clib_error_t * show_session_fifo_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: session_cli.c:665
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
u64 init_cpu_time
Definition: time.h:61
#define vec_foreach(var, vec)
Vector iterator.
u32 app_wrk_index
Index of the app worker that owns the session.
u8 session_node_lookup_fifo_event(svm_fifo_t *f, session_event_t *e)
static void session_cli_show_all_sessions(vlib_main_t *vm, int verbose)
Definition: session_cli.c:252
static clib_error_t * session_enable_disable_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: session_cli.c:762
int app_worker_close_notify(app_worker_t *app_wrk, session_t *s)
static transport_service_type_t session_transport_service_type(session_t *s)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:772
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
vl_api_fib_path_nh_proto_t proto
Definition: fib_types.api:125
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171
static session_worker_t * session_main_get_worker_if_valid(u32 thread_index)
Definition: session.h:597
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128