FD.io VPP  v19.08.3-2-gbabecb413
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  u32 rxf, txf;
71 
72  rxf = ss->rx_fifo ? svm_fifo_max_dequeue (ss->rx_fifo) : 0;
73  txf = ss->tx_fifo ? svm_fifo_max_dequeue (ss->tx_fifo) : 0;
74  str = format (0, "%-10u%-10u", rxf, txf);
75  }
76 
77  if (ss->session_state >= SESSION_STATE_ACCEPTING
78  || ss->session_state == SESSION_STATE_CREATED)
79  {
80  s = format (s, "%U", format_transport_connection, tp,
81  ss->connection_index, ss->thread_index, verbose);
82  if (verbose == 1)
83  s = format (s, "%v", str);
84  if (verbose > 1)
85  s = format (s, "%U", format_session_fifos, ss, verbose);
86  }
87  else if (ss->session_state == SESSION_STATE_LISTENING)
88  {
90  tp, ss->connection_index, ss->thread_index, verbose, str);
91  if (verbose > 1)
92  s = format (s, "\n%U", format_session_fifos, ss, verbose);
93  }
94  else if (ss->session_state == SESSION_STATE_CONNECTING)
95  {
97  tp, ss->connection_index, ss->thread_index, str);
98  }
99  else
100  {
101  clib_warning ("Session in state: %d!", ss->session_state);
102  }
103  vec_free (str);
104 
105  return s;
106 }
107 
108 uword
110 {
111  u8 *proto = va_arg (*args, u8 *);
112  u32 *fib_index = va_arg (*args, u32 *);
113  ip46_address_t *lcl = va_arg (*args, ip46_address_t *);
114  ip46_address_t *rmt = va_arg (*args, ip46_address_t *);
115  u16 *lcl_port = va_arg (*args, u16 *);
116  u16 *rmt_port = va_arg (*args, u16 *);
117  u8 *is_ip4 = va_arg (*args, u8 *);
118  u8 tuple_is_set = 0;
119  u32 vrf = ~0;
120 
121  clib_memset (lcl, 0, sizeof (*lcl));
122  clib_memset (rmt, 0, sizeof (*rmt));
123 
124  if (unformat (input, "tcp"))
125  {
126  *proto = TRANSPORT_PROTO_TCP;
127  }
128  else if (unformat (input, "udp"))
129  {
130  *proto = TRANSPORT_PROTO_UDP;
131  }
132  else
133  return 0;
134 
135  if (unformat (input, "vrf %u", &vrf))
136  ;
137 
138  if (unformat (input, "%U:%d->%U:%d", unformat_ip4_address, &lcl->ip4,
139  lcl_port, unformat_ip4_address, &rmt->ip4, rmt_port))
140  {
141  *is_ip4 = 1;
142  tuple_is_set = 1;
143  }
144  else if (unformat (input, "%U:%d->%U:%d", unformat_ip6_address, &lcl->ip6,
145  lcl_port, unformat_ip6_address, &rmt->ip6, rmt_port))
146  {
147  *is_ip4 = 0;
148  tuple_is_set = 1;
149  }
150 
151  if (vrf != ~0)
152  {
153  fib_protocol_t fib_proto;
154  fib_proto = *is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
155  *fib_index = fib_table_find (fib_proto, vrf);
156  }
157 
158  return tuple_is_set;
159 }
160 
161 uword
162 unformat_session_state (unformat_input_t * input, va_list * args)
163 {
164  session_state_t *state = va_arg (*args, session_state_t *);
165  u8 *state_vec = 0;
166  int rv = 0;
167 
168 #define _(sym, str) \
169  if (unformat (input, str)) \
170  { \
171  *state = SESSION_STATE_ ## sym; \
172  rv = 1; \
173  goto done; \
174  }
176 #undef _
177 done:
178  vec_free (state_vec);
179  return rv;
180 }
181 
182 uword
183 unformat_session (unformat_input_t * input, va_list * args)
184 {
185  session_t **result = va_arg (*args, session_t **);
186  u32 lcl_port = 0, rmt_port = 0, fib_index = 0;
187  ip46_address_t lcl, rmt;
188  session_t *s;
189  u8 proto = ~0;
190  u8 is_ip4 = 0;
191 
192  if (!unformat (input, "%U", unformat_stream_session_id, &proto, &fib_index,
193  &lcl, &rmt, &lcl_port, &rmt_port, &is_ip4))
194  return 0;
195 
196  if (is_ip4)
197  s = session_lookup_safe4 (fib_index, &lcl.ip4, &rmt.ip4,
198  clib_host_to_net_u16 (lcl_port),
199  clib_host_to_net_u16 (rmt_port), proto);
200  else
201  s = session_lookup_safe6 (fib_index, &lcl.ip6, &rmt.ip6,
202  clib_host_to_net_u16 (lcl_port),
203  clib_host_to_net_u16 (rmt_port), proto);
204  if (s)
205  {
206  *result = s;
208  return 1;
209  }
210  return 0;
211 }
212 
213 uword
215 {
216  transport_connection_t **result = va_arg (*args, transport_connection_t **);
217  u32 suggested_proto = va_arg (*args, u32);
219  u8 proto = ~0;
220  ip46_address_t lcl, rmt;
221  u32 lcl_port = 0, rmt_port = 0, fib_index = 0;
222  u8 is_ip4 = 0;
223 
224  if (!unformat (input, "%U", unformat_stream_session_id, &fib_index, &proto,
225  &lcl, &rmt, &lcl_port, &rmt_port, &is_ip4))
226  return 0;
227 
228  proto = (proto == (u8) ~ 0) ? suggested_proto : proto;
229  if (proto == (u8) ~ 0)
230  return 0;
231  if (is_ip4)
232  tc = session_lookup_connection4 (fib_index, &lcl.ip4, &rmt.ip4,
233  clib_host_to_net_u16 (lcl_port),
234  clib_host_to_net_u16 (rmt_port), proto);
235  else
236  tc = session_lookup_connection6 (fib_index, &lcl.ip6, &rmt.ip6,
237  clib_host_to_net_u16 (lcl_port),
238  clib_host_to_net_u16 (rmt_port), proto);
239 
240  if (tc)
241  {
242  *result = tc;
243  return 1;
244  }
245  return 0;
246 }
247 
248 static void
250 {
252  u32 n_closed, thread_index;
253  session_t *pool, *s;
254 
255  for (thread_index = 0; thread_index < vec_len (smm->wrk); thread_index++)
256  {
257  pool = smm->wrk[thread_index].sessions;
258 
259  if (!pool_elts (pool))
260  {
261  vlib_cli_output (vm, "Thread %d: no sessions", thread_index);
262  continue;
263  }
264 
265  if (!verbose)
266  {
267  vlib_cli_output (vm, "Thread %d: %d sessions", thread_index,
268  pool_elts (pool));
269  continue;
270  }
271 
272  if (pool_elts (pool) > 50)
273  {
274  vlib_cli_output (vm, "Thread %u: %d sessions. Verbose output "
275  "suppressed. For more details use filters.",
276  thread_index, pool_elts (pool));
277  continue;
278  }
279 
280  if (verbose == 1)
281  vlib_cli_output (vm, "%s%-50s%-15s%-10s%-10s",
282  thread_index ? "\n" : "",
283  "Connection", "State", "Rx-f", "Tx-f");
284 
285  n_closed = 0;
286 
287  /* *INDENT-OFF* */
288  pool_foreach(s, pool, ({
289  if (s->session_state >= SESSION_STATE_TRANSPORT_DELETED)
290  {
291  n_closed += 1;
292  continue;
293  }
294  vlib_cli_output (vm, "%U", format_session, s, verbose);
295  }));
296  /* *INDENT-ON* */
297 
298  if (!n_closed)
299  vlib_cli_output (vm, "Thread %d: active sessions %u", thread_index,
300  pool_elts (pool) - n_closed);
301  else
302  vlib_cli_output (vm, "Thread %d: active sessions %u closed %u",
303  thread_index, pool_elts (pool) - n_closed, n_closed);
304  }
305 }
306 
307 static int
310 {
311  if (states)
312  {
314  vec_foreach (state, states) if (s->session_state == *state)
315  goto check_transport;
316  return 0;
317  }
318 
319 check_transport:
320 
321  if (tp != TRANSPORT_N_PROTO && session_get_transport_proto (s) != tp)
322  return 0;
323 
324  return 1;
325 }
326 
327 static void
329  u32 start, u32 end, session_state_t * states,
330  transport_proto_t tp, int verbose)
331 {
332  u8 output_suppressed = 0;
333  session_worker_t *wrk;
334  session_t *pool, *s;
335  u32 count = 0, max_index;
336  int i;
337 
338  wrk = session_main_get_worker_if_valid (thread_index);
339  if (!wrk)
340  {
341  vlib_cli_output (vm, "invalid thread index %u", thread_index);
342  return;
343  }
344 
345  pool = wrk->sessions;
346 
347  if (tp == TRANSPORT_N_PROTO && states == 0 && !verbose
348  && (start == 0 && end == ~0))
349  {
350  vlib_cli_output (vm, "Thread %d: %u sessions", thread_index,
351  pool_elts (pool));
352  return;
353  }
354 
355  max_index = pool_len (pool) ? pool_len (pool) - 1 : 0;
356  for (i = start; i <= clib_min (end, max_index); i++)
357  {
358  if (pool_is_free_index (pool, i))
359  continue;
360 
361  s = pool_elt_at_index (pool, i);
362 
363  if (session_cli_filter_check (s, states, tp))
364  {
365  count += 1;
366  if (verbose)
367  {
368  if (count > 50 || (verbose > 1 && count > 10))
369  {
370  output_suppressed = 1;
371  continue;
372  }
373  if (s->session_state < SESSION_STATE_TRANSPORT_DELETED)
374  vlib_cli_output (vm, "%U", format_session, s, verbose);
375  }
376  }
377  }
378 
379  if (!output_suppressed)
380  vlib_cli_output (vm, "Thread %d: %u sessions matched filter",
381  thread_index, count);
382  else
383  vlib_cli_output (vm, "Thread %d: %u sessions matched filter. Not all"
384  " shown. Use finer grained filter.", thread_index,
385  count);
386 }
387 
388 void
390 {
391  session_worker_t *wrk;
392 
393  wrk = session_main_get_worker_if_valid (thread_index);
394  if (!wrk)
395  {
396  vlib_cli_output (vm, "invalid thread index %u", thread_index);
397  return;
398  }
399 
400  vlib_cli_output (vm, "Thread %d:\n", thread_index);
401  vlib_cli_output (vm, " evt elements alloc: %u",
402  pool_elts (wrk->event_elts));
403  vlib_cli_output (vm, " ctrl evt elt data alloc: %d",
404  pool_elts (wrk->ctrl_evts_data));
405 }
406 
407 static void
409 {
411  if (!thread_index)
412  {
413  session_cli_show_events_thread (vm, thread_index);
414  return;
415  }
416 
417  for (thread_index = 0; thread_index < vec_len (smm->wrk); thread_index++)
418  session_cli_show_events_thread (vm, thread_index);
419 }
420 
421 static void
423 {
424 #define _(sym, str, sstr) vlib_cli_output (vm, str);
426 #undef _
427 }
428 
429 static void
431 {
432 #define _(sym, str) vlib_cli_output (vm, str);
434 #undef _
435 }
436 
437 static clib_error_t *
439  vlib_cli_command_t * cmd)
440 {
441  u8 one_session = 0, do_listeners = 0, sst, do_elog = 0, do_filter = 0;
442  u32 track_index, thread_index = 0, start = 0, end = ~0, session_index;
443  unformat_input_t _line_input, *line_input = &_line_input;
444  transport_proto_t transport_proto = TRANSPORT_N_PROTO;
445  session_state_t state = SESSION_N_STATES, *states = 0;
447  clib_error_t *error = 0;
448  app_worker_t *app_wrk;
449  u32 transport_index;
450  const u8 *app_name;
451  u8 do_events = 0;
452  int verbose = 0;
453  session_t *s;
454 
456 
457  if (!unformat_user (input, unformat_line_input, line_input))
458  {
460  return 0;
461  }
462 
463  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
464  {
465  if (unformat (line_input, "verbose %d", &verbose))
466  ;
467  else if (unformat (line_input, "verbose"))
468  verbose = 1;
469  else if (unformat (line_input, "listeners %U", unformat_transport_proto,
470  &transport_proto))
471  do_listeners = 1;
472  else if (unformat (line_input, "%U", unformat_session, &s))
473  {
474  one_session = 1;
475  }
476  else if (unformat (line_input, "thread %u index %u", &thread_index,
477  &session_index))
478  {
479  s = session_get_if_valid (session_index, thread_index);
480  if (!s)
481  {
482  vlib_cli_output (vm, "session is not allocated");
483  goto done;
484  }
485  one_session = 1;
486  }
487  else if (unformat (line_input, "thread %u", &thread_index))
488  {
489  do_filter = 1;
490  }
491  else
492  if (unformat (line_input, "state %U", unformat_session_state, &state))
493  {
494  vec_add1 (states, state);
495  do_filter = 1;
496  }
497  else if (unformat (line_input, "proto %U index %u",
498  unformat_transport_proto, &transport_proto,
499  &transport_index))
500  {
502  tc = transport_get_connection (transport_proto, transport_index,
503  thread_index);
504  if (!tc)
505  {
506  vlib_cli_output (vm, "transport connection %u thread %u is not"
507  " allocated", transport_index, thread_index);
508  goto done;
509  }
510  s = session_get_if_valid (tc->s_index, thread_index);
511  if (!s)
512  {
513  vlib_cli_output (vm, "session for transport connection %u "
514  "thread %u does not exist", transport_index,
515  thread_index);
516  goto done;
517  }
518  one_session = 1;
519  }
520  else if (unformat (line_input, "proto %U", unformat_transport_proto,
521  &transport_proto))
522  do_filter = 1;
523  else if (unformat (line_input, "range %u %u", &start, &end))
524  do_filter = 1;
525  else if (unformat (line_input, "range %u", &start))
526  {
527  end = start + 50;
528  do_filter = 1;
529  }
530  else if (unformat (line_input, "elog"))
531  do_elog = 1;
532  else if (unformat (line_input, "protos"))
533  {
535  goto done;
536  }
537  else if (unformat (line_input, "states"))
538  {
540  goto done;
541  }
542  else if (unformat (line_input, "events"))
543  do_events = 1;
544  else
545  {
546  error = clib_error_return (0, "unknown input `%U'",
547  format_unformat_error, line_input);
548  goto done;
549  }
550  }
551 
552  if (one_session)
553  {
554  u8 *str = format (0, "%U", format_session, s, 3);
555  if (do_elog && s->session_state != SESSION_STATE_LISTENING)
556  {
557  elog_main_t *em = &vm->elog_main;
559  f64 dt;
560 
561  tc = session_get_transport (s);
562  track_index = transport_elog_track_index (tc);
563  dt = (em->init_time.cpu - vm->clib_time.init_cpu_time)
565  if (track_index != ~0)
566  str = format (str, " session elog:\n%U", format_elog_track, em,
567  dt, track_index);
568  }
569  vlib_cli_output (vm, "%v", str);
570  vec_free (str);
571  goto done;
572  }
573 
574  if (do_listeners)
575  {
576  sst = session_type_from_proto_and_ip (transport_proto, 1);
577  vlib_cli_output (vm, "%-50s%-24s", "Listener", "App");
578  /* *INDENT-OFF* */
579  pool_foreach (s, smm->wrk[0].sessions, ({
580  if (s->session_state != SESSION_STATE_LISTENING
581  || s->session_type != sst)
582  continue;
583  app_wrk = app_worker_get (s->app_wrk_index);
584  app_name = application_name_from_index (app_wrk->app_index);
585  vlib_cli_output (vm, "%U%-25v%", format_session, s, 0,
586  app_name);
587  }));
588  /* *INDENT-ON* */
589  goto done;
590  }
591 
592  if (do_events)
593  {
594  session_cli_show_events (vm, thread_index);
595  goto done;
596  }
597 
598  if (do_filter)
599  {
600  if (end < start)
601  {
602  error = clib_error_return (0, "invalid range start: %u end: %u",
603  start, end);
604  goto done;
605  }
606  session_cli_show_session_filter (vm, thread_index, start, end, states,
607  transport_proto, verbose);
608  goto done;
609  }
610 
611  session_cli_show_all_sessions (vm, verbose);
612 
613 done:
614  unformat_free (line_input);
615  vec_free (states);
616  return error;
617 }
618 
619 /* *INDENT-OFF* */
620 VLIB_CLI_COMMAND (vlib_cli_show_session_command) =
621 {
622  .path = "show session",
623  .short_help = "show session [verbose [n]] [listeners <proto>] "
624  "[<session-id> [elog]] [thread <n> [index <n>] "
625  "[proto <proto>] [state <state>] [range <min> [<max>]] "
626  "[protos] [states] ",
627  .function = show_session_command_fn,
628 };
629 /* *INDENT-ON* */
630 
631 static int
633 {
634  app_worker_t *server_wrk = app_worker_get (s->app_wrk_index);
635  app_worker_close_notify (server_wrk, s);
636  return 0;
637 }
638 
639 static clib_error_t *
641  vlib_cli_command_t * cmd)
642 {
644  u32 thread_index = 0, clear_all = 0;
645  session_worker_t *wrk;
646  u32 session_index = ~0;
647  session_t *session;
648 
649  if (!smm->is_enabled)
650  {
651  return clib_error_return (0, "session layer is not enabled");
652  }
653 
655  {
656  if (unformat (input, "thread %d", &thread_index))
657  ;
658  else if (unformat (input, "session %d", &session_index))
659  ;
660  else if (unformat (input, "all"))
661  clear_all = 1;
662  else
663  return clib_error_return (0, "unknown input `%U'",
664  format_unformat_error, input);
665  }
666 
667  if (!clear_all && session_index == ~0)
668  return clib_error_return (0, "session <nn> required, but not set.");
669 
670  if (session_index != ~0)
671  {
672  session = session_get_if_valid (session_index, thread_index);
673  if (!session)
674  return clib_error_return (0, "no session %d on thread %d",
675  session_index, thread_index);
676  clear_session (session);
677  }
678 
679  if (clear_all)
680  {
681  /* *INDENT-OFF* */
682  vec_foreach (wrk, smm->wrk)
683  {
684  pool_foreach(session, wrk->sessions, ({
685  clear_session (session);
686  }));
687  };
688  /* *INDENT-ON* */
689  }
690 
691  return 0;
692 }
693 
694 /* *INDENT-OFF* */
695 VLIB_CLI_COMMAND (clear_session_command, static) =
696 {
697  .path = "clear session",
698  .short_help = "clear session thread <thread> session <index>",
699  .function = clear_session_command_fn,
700 };
701 /* *INDENT-ON* */
702 
703 static clib_error_t *
705  unformat_input_t * input,
706  vlib_cli_command_t * cmd)
707 {
708  session_t *s = 0;
709  u8 is_rx = 0, *str = 0;
710 
712  {
713  if (unformat (input, "%U", unformat_session, &s))
714  ;
715  else if (unformat (input, "rx"))
716  is_rx = 1;
717  else if (unformat (input, "tx"))
718  is_rx = 0;
719  else
720  return clib_error_return (0, "unknown input `%U'",
721  format_unformat_error, input);
722  }
723 
724  if (!SVM_FIFO_TRACE)
725  {
726  vlib_cli_output (vm, "fifo tracing not enabled");
727  return 0;
728  }
729 
730  if (!s)
731  {
732  vlib_cli_output (vm, "could not find session");
733  return 0;
734  }
735 
736  str = is_rx ?
737  svm_fifo_dump_trace (str, s->rx_fifo) :
738  svm_fifo_dump_trace (str, s->tx_fifo);
739 
740  vlib_cli_output (vm, "%v", str);
741  return 0;
742 }
743 
744 /* *INDENT-OFF* */
745 VLIB_CLI_COMMAND (show_session_fifo_trace_command, static) =
746 {
747  .path = "show session fifo trace",
748  .short_help = "show session fifo trace <session>",
750 };
751 /* *INDENT-ON* */
752 
753 static clib_error_t *
755  vlib_cli_command_t * cmd)
756 {
757  session_t *s = 0;
758  u8 is_rx = 0, *str = 0;
759 
761  {
762  if (unformat (input, "%U", unformat_session, &s))
763  ;
764  else if (unformat (input, "rx"))
765  is_rx = 1;
766  else
767  return clib_error_return (0, "unknown input `%U'",
768  format_unformat_error, input);
769  }
770 
771  if (!SVM_FIFO_TRACE)
772  {
773  vlib_cli_output (vm, "fifo tracing not enabled");
774  return 0;
775  }
776 
777  if (!s)
778  {
779  vlib_cli_output (vm, "could not find session");
780  return 0;
781  }
782 
783  str = is_rx ?
784  svm_fifo_replay (str, s->rx_fifo, 0, 1) :
785  svm_fifo_replay (str, s->tx_fifo, 0, 1);
786 
787  vlib_cli_output (vm, "%v", str);
788  return 0;
789 }
790 
791 /* *INDENT-OFF* */
792 VLIB_CLI_COMMAND (session_replay_fifo_trace_command, static) =
793 {
794  .path = "session replay fifo",
795  .short_help = "session replay fifo <session>",
796  .function = session_replay_fifo_command_fn,
797 };
798 /* *INDENT-ON* */
799 
800 static clib_error_t *
802  vlib_cli_command_t * cmd)
803 {
804  unformat_input_t _line_input, *line_input = &_line_input;
805  u8 is_en = 1;
806  clib_error_t *error;
807 
808  if (!unformat_user (input, unformat_line_input, line_input))
809  return clib_error_return (0, "expected enable | disable");
810 
811  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
812  {
813  if (unformat (line_input, "enable"))
814  is_en = 1;
815  else if (unformat (line_input, "disable"))
816  is_en = 0;
817  else
818  {
819  error = clib_error_return (0, "unknown input `%U'",
820  format_unformat_error, line_input);
821  unformat_free (line_input);
822  return error;
823  }
824  }
825 
826  unformat_free (line_input);
827  return vnet_session_enable_disable (vm, is_en);
828 }
829 
830 /* *INDENT-OFF* */
831 VLIB_CLI_COMMAND (session_enable_disable_command, static) =
832 {
833  .path = "session",
834  .short_help = "session [enable|disable]",
835  .function = session_enable_disable_fn,
836 };
837 /* *INDENT-ON* */
838 
839 /*
840  * fd.io coding-style-patch-verification: ON
841  *
842  * Local Variables:
843  * eval: (c-set-style "gnu")
844  * End:
845  */
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:302
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:618
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:1468
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:302
session_evt_ctrl_data_t * ctrl_evts_data
Pool of ctrl events data buffers.
Definition: session.h:108
#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:632
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:640
static void session_pool_remove_peeker(u32 thread_index)
Definition: session.h:353
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
session_evt_elt_t * event_elts
Pool of session event list elements.
Definition: session.h:105
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:438
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
void session_cli_show_events_thread(vlib_main_t *vm, u32 thread_index)
Definition: session_cli.c:389
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:162
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:214
f64 seconds_per_clock
Definition: time.h:58
uword unformat_session(unformat_input_t *input, va_list *args)
Definition: session_cli.c:183
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:1613
uword unformat_stream_session_id(unformat_input_t *input, va_list *args)
Definition: session_cli.c:109
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_show_events(vlib_main_t *vm, u32 thread_index)
Definition: session_cli.c:408
static void session_cli_print_session_states(vlib_main_t *vm)
Definition: session_cli.c:430
#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:328
uword unformat_transport_proto(unformat_input_t *input, va_list *args)
Definition: transport.c:156
static void session_cli_print_transport_protos(vlib_main_t *vm)
Definition: session_cli.c:422
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:308
#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
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:754
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:704
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:249
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:801
int app_worker_close_notify(app_worker_t *app_wrk, 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:599
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128