FD.io VPP  v21.06-3-gbb25fbf28
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->shr->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->shr->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 const char *session_state_str[] = {
47 #define _(sym, str) str,
49 #undef _
50 };
51 
52 u8 *
53 format_session_state (u8 * s, va_list * args)
54 {
55  session_t *ss = va_arg (*args, session_t *);
56 
58  s = format (s, "%s", session_state_str[ss->session_state]);
59  else
60  s = format (s, "UNKNOWN STATE (%d)", ss->session_state);
61 
62  return s;
63 }
64 
65 const char *session_flags_str[] = {
66 #define _(sym, str) str,
68 #undef _
69 };
70 
71 u8 *
72 format_session_flags (u8 * s, va_list * args)
73 {
74  session_t *ss = va_arg (*args, session_t *);
75  int i, last = -1;
76 
77  for (i = 0; i < SESSION_N_FLAGS; i++)
78  if (ss->flags & (1 << i))
79  last = i;
80 
81  for (i = 0; i < last; i++)
82  {
83  if (ss->flags & (1 << i))
84  s = format (s, "%s, ", session_flags_str[i]);
85  }
86  if (last >= 0)
87  s = format (s, "%s", session_flags_str[last]);
88 
89  return s;
90 }
91 
92 /**
93  * Format stream session as per the following format
94  *
95  * verbose:
96  * "Connection", "Rx fifo", "Tx fifo", "Session Index"
97  * non-verbose:
98  * "Connection"
99  */
100 u8 *
101 format_session (u8 * s, va_list * args)
102 {
103  session_t *ss = va_arg (*args, session_t *);
104  int verbose = va_arg (*args, int);
106  u8 *str = 0;
107 
108  if (ss->session_state >= SESSION_STATE_TRANSPORT_DELETED)
109  {
110  s = format (s, "[%u:%u] CLOSED", ss->thread_index, ss->session_index);
111  return s;
112  }
113 
114  if (verbose == 1)
115  {
116  u32 rxf, txf;
117 
118  rxf = ss->rx_fifo ? svm_fifo_max_dequeue (ss->rx_fifo) : 0;
119  txf = ss->tx_fifo ? svm_fifo_max_dequeue (ss->tx_fifo) : 0;
120  str = format (0, "%-10u%-10u", rxf, txf);
121  }
122 
123  if (ss->session_state >= SESSION_STATE_ACCEPTING
124  || ss->session_state == SESSION_STATE_CREATED)
125  {
126  s = format (s, "%U", format_transport_connection, tp,
127  ss->connection_index, ss->thread_index, verbose);
128  if (verbose == 1)
129  s = format (s, "%v", str);
130  if (verbose > 1)
131  {
132  s = format (s, "%U", format_session_fifos, ss, verbose);
133  s = format (s, " session: state: %U opaque: 0x%x flags: %U\n",
134  format_session_state, ss, ss->opaque,
136  }
137  }
138  else if (ss->session_state == SESSION_STATE_LISTENING)
139  {
141  tp, ss->connection_index, ss->thread_index, verbose, str);
142  if (verbose > 1)
143  s = format (s, "\n%U", format_session_fifos, ss, verbose);
144  }
145  else if (ss->session_state == SESSION_STATE_CONNECTING)
146  {
147  if (ss->flags & SESSION_F_HALF_OPEN)
148  s = format (s, "%U%v", format_transport_half_open_connection, tp,
149  ss->connection_index, ss->thread_index, verbose, str);
150  else
151  s = format (s, "%U", format_transport_connection, tp,
152  ss->connection_index, ss->thread_index, verbose);
153  }
154  else
155  {
156  clib_warning ("Session in state: %d!", ss->session_state);
157  }
158  vec_free (str);
159 
160  return s;
161 }
162 
163 uword
165 {
166  u8 *proto = va_arg (*args, u8 *);
167  u32 *fib_index = va_arg (*args, u32 *);
168  ip46_address_t *lcl = va_arg (*args, ip46_address_t *);
169  ip46_address_t *rmt = va_arg (*args, ip46_address_t *);
170  u16 *lcl_port = va_arg (*args, u16 *);
171  u16 *rmt_port = va_arg (*args, u16 *);
172  u8 *is_ip4 = va_arg (*args, u8 *);
173  u8 tuple_is_set = 0;
174  u32 vrf = ~0;
175 
176  clib_memset (lcl, 0, sizeof (*lcl));
177  clib_memset (rmt, 0, sizeof (*rmt));
178 
179  if (unformat (input, "tcp"))
180  {
181  *proto = TRANSPORT_PROTO_TCP;
182  }
183  else if (unformat (input, "udp"))
184  {
185  *proto = TRANSPORT_PROTO_UDP;
186  }
187  else
188  return 0;
189 
190  if (unformat (input, "vrf %u", &vrf))
191  ;
192 
193  if (unformat (input, "%U:%d->%U:%d", unformat_ip4_address, &lcl->ip4,
194  lcl_port, unformat_ip4_address, &rmt->ip4, rmt_port))
195  {
196  *is_ip4 = 1;
197  tuple_is_set = 1;
198  }
199  else if (unformat (input, "%U:%d->%U:%d", unformat_ip6_address, &lcl->ip6,
200  lcl_port, unformat_ip6_address, &rmt->ip6, rmt_port))
201  {
202  *is_ip4 = 0;
203  tuple_is_set = 1;
204  }
205 
206  if (vrf != ~0)
207  {
208  fib_protocol_t fib_proto;
209  fib_proto = *is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
210  *fib_index = fib_table_find (fib_proto, vrf);
211  }
212 
213  return tuple_is_set;
214 }
215 
216 uword
217 unformat_session_state (unformat_input_t * input, va_list * args)
218 {
219  session_state_t *state = va_arg (*args, session_state_t *);
220  u8 *state_vec = 0;
221  int rv = 0;
222 
223 #define _(sym, str) \
224  if (unformat (input, str)) \
225  { \
226  *state = SESSION_STATE_ ## sym; \
227  rv = 1; \
228  goto done; \
229  }
231 #undef _
232 done:
233  vec_free (state_vec);
234  return rv;
235 }
236 
237 uword
238 unformat_session (unformat_input_t * input, va_list * args)
239 {
240  session_t **result = va_arg (*args, session_t **);
241  u32 lcl_port = 0, rmt_port = 0, fib_index = 0;
242  ip46_address_t lcl, rmt;
243  session_t *s;
244  u8 proto = ~0;
245  u8 is_ip4 = 0;
246 
247  if (!unformat (input, "%U", unformat_stream_session_id, &proto, &fib_index,
248  &lcl, &rmt, &lcl_port, &rmt_port, &is_ip4))
249  return 0;
250 
251  if (is_ip4)
252  s = session_lookup_safe4 (fib_index, &lcl.ip4, &rmt.ip4,
253  clib_host_to_net_u16 (lcl_port),
254  clib_host_to_net_u16 (rmt_port), proto);
255  else
256  s = session_lookup_safe6 (fib_index, &lcl.ip6, &rmt.ip6,
257  clib_host_to_net_u16 (lcl_port),
258  clib_host_to_net_u16 (rmt_port), proto);
259  if (s)
260  {
261  *result = s;
263  return 1;
264  }
265  return 0;
266 }
267 
268 uword
270 {
271  transport_connection_t **result = va_arg (*args, transport_connection_t **);
272  u32 suggested_proto = va_arg (*args, u32);
274  u8 proto = ~0;
275  ip46_address_t lcl, rmt;
276  u32 lcl_port = 0, rmt_port = 0, fib_index = 0;
277  u8 is_ip4 = 0;
278 
279  if (!unformat (input, "%U", unformat_stream_session_id, &fib_index, &proto,
280  &lcl, &rmt, &lcl_port, &rmt_port, &is_ip4))
281  return 0;
282 
283  proto = (proto == (u8) ~ 0) ? suggested_proto : proto;
284  if (proto == (u8) ~ 0)
285  return 0;
286  if (is_ip4)
287  tc = session_lookup_connection4 (fib_index, &lcl.ip4, &rmt.ip4,
288  clib_host_to_net_u16 (lcl_port),
289  clib_host_to_net_u16 (rmt_port), proto);
290  else
291  tc = session_lookup_connection6 (fib_index, &lcl.ip6, &rmt.ip6,
292  clib_host_to_net_u16 (lcl_port),
293  clib_host_to_net_u16 (rmt_port), proto);
294 
295  if (tc)
296  {
297  *result = tc;
298  return 1;
299  }
300  return 0;
301 }
302 
303 static void
305 {
307  u32 n_closed, thread_index;
308  session_t *pool, *s;
309 
310  for (thread_index = 0; thread_index < vec_len (smm->wrk); thread_index++)
311  {
312  pool = smm->wrk[thread_index].sessions;
313 
314  if (!pool_elts (pool))
315  {
316  vlib_cli_output (vm, "Thread %d: no sessions", thread_index);
317  continue;
318  }
319 
320  if (!verbose)
321  {
322  vlib_cli_output (vm, "Thread %d: %d sessions", thread_index,
323  pool_elts (pool));
324  continue;
325  }
326 
327  if (pool_elts (pool) > 50)
328  {
329  vlib_cli_output (vm, "Thread %u: %d sessions. Verbose output "
330  "suppressed. For more details use filters.",
331  thread_index, pool_elts (pool));
332  continue;
333  }
334 
335  if (verbose == 1)
336  vlib_cli_output (vm, "%s%-" SESSION_CLI_ID_LEN "s%-"
337  SESSION_CLI_STATE_LEN "s%-10s%-10s",
338  thread_index ? "\n" : "",
339  "Connection", "State", "Rx-f", "Tx-f");
340 
341  n_closed = 0;
342 
343  /* *INDENT-OFF* */
344  pool_foreach (s, pool) {
345  if (s->session_state >= SESSION_STATE_TRANSPORT_DELETED)
346  {
347  n_closed += 1;
348  continue;
349  }
350  vlib_cli_output (vm, "%U", format_session, s, verbose);
351  }
352  /* *INDENT-ON* */
353 
354  if (!n_closed)
355  vlib_cli_output (vm, "Thread %d: active sessions %u", thread_index,
356  pool_elts (pool) - n_closed);
357  else
358  vlib_cli_output (vm, "Thread %d: active sessions %u closed %u",
359  thread_index, pool_elts (pool) - n_closed, n_closed);
360  }
361 }
362 
363 static int
366 {
367  if (states)
368  {
370  vec_foreach (state, states) if (s->session_state == *state)
371  goto check_transport;
372  return 0;
373  }
374 
375 check_transport:
376 
378  return 0;
379 
380  return 1;
381 }
382 
383 static void
385  u32 start, u32 end, session_state_t * states,
386  transport_proto_t tp, int verbose)
387 {
388  u8 output_suppressed = 0;
390  session_t *pool, *s;
391  u32 count = 0, max_index;
392  int i;
393 
395  if (!wrk)
396  {
397  vlib_cli_output (vm, "invalid thread index %u", thread_index);
398  return;
399  }
400 
401  pool = wrk->sessions;
402 
403  if (tp == TRANSPORT_PROTO_INVALID && states == 0 && !verbose
404  && (start == 0 && end == ~0))
405  {
406  vlib_cli_output (vm, "Thread %d: %u sessions", thread_index,
407  pool_elts (pool));
408  return;
409  }
410 
411  max_index = pool_len (pool) ? pool_len (pool) - 1 : 0;
412  for (i = start; i <= clib_min (end, max_index); i++)
413  {
414  if (pool_is_free_index (pool, i))
415  continue;
416 
417  s = pool_elt_at_index (pool, i);
418 
419  if (session_cli_filter_check (s, states, tp))
420  {
421  count += 1;
422  if (verbose)
423  {
424  if (count > 50 || (verbose > 1 && count > 10))
425  {
426  output_suppressed = 1;
427  continue;
428  }
429  if (s->session_state < SESSION_STATE_TRANSPORT_DELETED)
430  vlib_cli_output (vm, "%U", format_session, s, verbose);
431  }
432  }
433  }
434 
435  if (!output_suppressed)
436  vlib_cli_output (vm, "Thread %d: %u sessions matched filter",
438  else
439  vlib_cli_output (vm, "Thread %d: %u sessions matched filter. Not all"
440  " shown. Use finer grained filter.", thread_index,
441  count);
442 }
443 
444 void
446 {
448 
450  if (!wrk)
451  {
452  vlib_cli_output (vm, "invalid thread index %u", thread_index);
453  return;
454  }
455 
456  vlib_cli_output (vm, "Thread %d:\n", thread_index);
457  vlib_cli_output (vm, " evt elements alloc: %u",
459  vlib_cli_output (vm, " ctrl evt elt data alloc: %d",
461 }
462 
463 static void
465 {
467  if (!thread_index)
468  {
470  return;
471  }
472 
473  for (thread_index = 0; thread_index < vec_len (smm->wrk); thread_index++)
475 }
476 
477 static void
479 {
480 #define _(sym, str) vlib_cli_output (vm, str);
482 #undef _
483 }
484 
485 static clib_error_t *
487  vlib_cli_command_t * cmd)
488 {
489  u8 one_session = 0, do_listeners = 0, sst, do_elog = 0, do_filter = 0;
490  u32 track_index, thread_index = 0, start = 0, end = ~0, session_index;
491  unformat_input_t _line_input, *line_input = &_line_input;
493  session_state_t state = SESSION_N_STATES, *states = 0;
495  clib_error_t *error = 0;
496  app_worker_t *app_wrk;
497  u32 transport_index;
498  const u8 *app_name;
499  u8 do_events = 0;
500  int verbose = 0;
501  session_t *s;
502 
504 
505  if (!unformat_user (input, unformat_line_input, line_input))
506  {
508  return 0;
509  }
510 
511  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
512  {
513  if (unformat (line_input, "verbose %d", &verbose))
514  ;
515  else if (unformat (line_input, "verbose"))
516  verbose = 1;
517  else if (unformat (line_input, "listeners %U", unformat_transport_proto,
518  &transport_proto))
519  do_listeners = 1;
520  else if (unformat (line_input, "%U", unformat_session, &s))
521  {
522  one_session = 1;
523  }
524  else if (unformat (line_input, "thread %u index %u", &thread_index,
525  &session_index))
526  {
527  s = session_get_if_valid (session_index, thread_index);
528  if (!s)
529  {
530  vlib_cli_output (vm, "session is not allocated");
531  goto done;
532  }
533  one_session = 1;
534  }
535  else if (unformat (line_input, "thread %u", &thread_index))
536  {
537  do_filter = 1;
538  }
539  else
540  if (unformat (line_input, "state %U", unformat_session_state, &state))
541  {
542  vec_add1 (states, state);
543  do_filter = 1;
544  }
545  else if (unformat (line_input, "proto %U index %u",
547  &transport_index))
548  {
550  tc = transport_get_connection (transport_proto, transport_index,
551  thread_index);
552  if (!tc)
553  {
554  vlib_cli_output (vm, "transport connection %u thread %u is not"
555  " allocated", transport_index, thread_index);
556  goto done;
557  }
558  s = session_get_if_valid (tc->s_index, thread_index);
559  if (!s)
560  {
561  vlib_cli_output (vm, "session for transport connection %u "
562  "thread %u does not exist", transport_index,
563  thread_index);
564  goto done;
565  }
566  one_session = 1;
567  }
568  else if (unformat (line_input, "proto %U", unformat_transport_proto,
569  &transport_proto))
570  do_filter = 1;
571  else if (unformat (line_input, "range %u %u", &start, &end))
572  do_filter = 1;
573  else if (unformat (line_input, "range %u", &start))
574  {
575  end = start + 50;
576  do_filter = 1;
577  }
578  else if (unformat (line_input, "elog"))
579  do_elog = 1;
580  else if (unformat (line_input, "protos"))
581  {
583  goto done;
584  }
585  else if (unformat (line_input, "states"))
586  {
588  goto done;
589  }
590  else if (unformat (line_input, "events"))
591  do_events = 1;
592  else
593  {
594  error = clib_error_return (0, "unknown input `%U'",
595  format_unformat_error, line_input);
596  goto done;
597  }
598  }
599 
600  if (one_session)
601  {
602  u8 *str = format (0, "%U", format_session, s, 3);
603  if (do_elog && s->session_state != SESSION_STATE_LISTENING)
604  {
607  f64 dt;
608 
609  tc = session_get_transport (s);
610  track_index = transport_elog_track_index (tc);
611  dt = (em->init_time.cpu - vm->clib_time.init_cpu_time)
613  if (track_index != ~0)
614  str = format (str, " session elog:\n%U", format_elog_track, em,
615  dt, track_index);
616  }
617  vlib_cli_output (vm, "%v", str);
618  vec_free (str);
619  goto done;
620  }
621 
622  if (do_listeners)
623  {
625  vlib_cli_output (vm, "%-" SESSION_CLI_ID_LEN "s%-24s", "Listener",
626  "App");
627 
628  /* *INDENT-OFF* */
629  pool_foreach (s, smm->wrk[0].sessions) {
630  if (s->session_state != SESSION_STATE_LISTENING
631  || s->session_type != sst)
632  continue;
633  app_wrk = app_worker_get (s->app_wrk_index);
635  vlib_cli_output (vm, "%U%-25v%", format_session, s, 0,
636  app_name);
637  }
638  /* *INDENT-ON* */
639  goto done;
640  }
641 
642  if (do_events)
643  {
645  goto done;
646  }
647 
648  if (do_filter)
649  {
650  if (end < start)
651  {
652  error = clib_error_return (0, "invalid range start: %u end: %u",
653  start, end);
654  goto done;
655  }
657  transport_proto, verbose);
658  goto done;
659  }
660 
662 
663 done:
664  unformat_free (line_input);
665  vec_free (states);
666  return error;
667 }
668 
669 /* *INDENT-OFF* */
671 {
672  .path = "show session",
673  .short_help = "show session [verbose [n]] [listeners <proto>] "
674  "[<session-id> [elog]] [thread <n> [index <n>] "
675  "[proto <proto>] [state <state>] [range <min> [<max>]] "
676  "[protos] [states] ",
677  .function = show_session_command_fn,
678 };
679 /* *INDENT-ON* */
680 
681 static int
683 {
684  app_worker_t *server_wrk = app_worker_get (s->app_wrk_index);
685  app_worker_close_notify (server_wrk, s);
686  return 0;
687 }
688 
689 static clib_error_t *
691  vlib_cli_command_t * cmd)
692 {
694  u32 thread_index = 0, clear_all = 0;
696  u32 session_index = ~0;
697  session_t *session;
698 
699  if (!smm->is_enabled)
700  {
701  return clib_error_return (0, "session layer is not enabled");
702  }
703 
705  {
706  if (unformat (input, "thread %d", &thread_index))
707  ;
708  else if (unformat (input, "session %d", &session_index))
709  ;
710  else if (unformat (input, "all"))
711  clear_all = 1;
712  else
713  return clib_error_return (0, "unknown input `%U'",
714  format_unformat_error, input);
715  }
716 
717  if (!clear_all && session_index == ~0)
718  return clib_error_return (0, "session <nn> required, but not set.");
719 
720  if (session_index != ~0)
721  {
722  session = session_get_if_valid (session_index, thread_index);
723  if (!session)
724  return clib_error_return (0, "no session %d on thread %d",
725  session_index, thread_index);
726  clear_session (session);
727  }
728 
729  if (clear_all)
730  {
731  /* *INDENT-OFF* */
732  vec_foreach (wrk, smm->wrk)
733  {
734  pool_foreach (session, wrk->sessions) {
735  clear_session (session);
736  }
737  };
738  /* *INDENT-ON* */
739  }
740 
741  return 0;
742 }
743 
744 /* *INDENT-OFF* */
746 {
747  .path = "clear session",
748  .short_help = "clear session thread <thread> session <index>",
749  .function = clear_session_command_fn,
750 };
751 /* *INDENT-ON* */
752 
753 static clib_error_t *
755  unformat_input_t * input,
756  vlib_cli_command_t * cmd)
757 {
758  session_t *s = 0;
759  u8 is_rx = 0, *str = 0;
760 
762  {
763  if (unformat (input, "%U", unformat_session, &s))
764  ;
765  else if (unformat (input, "rx"))
766  is_rx = 1;
767  else if (unformat (input, "tx"))
768  is_rx = 0;
769  else
770  return clib_error_return (0, "unknown input `%U'",
771  format_unformat_error, input);
772  }
773 
774  if (!SVM_FIFO_TRACE)
775  {
776  vlib_cli_output (vm, "fifo tracing not enabled");
777  return 0;
778  }
779 
780  if (!s)
781  {
782  vlib_cli_output (vm, "could not find session");
783  return 0;
784  }
785 
786  str = is_rx ?
787  svm_fifo_dump_trace (str, s->rx_fifo) :
788  svm_fifo_dump_trace (str, s->tx_fifo);
789 
790  vlib_cli_output (vm, "%v", str);
791  return 0;
792 }
793 
794 /* *INDENT-OFF* */
796 {
797  .path = "show session fifo trace",
798  .short_help = "show session fifo trace <session>",
800 };
801 /* *INDENT-ON* */
802 
803 static clib_error_t *
805  vlib_cli_command_t * cmd)
806 {
807  session_t *s = 0;
808  u8 is_rx = 0, *str = 0;
809 
811  {
812  if (unformat (input, "%U", unformat_session, &s))
813  ;
814  else if (unformat (input, "rx"))
815  is_rx = 1;
816  else
817  return clib_error_return (0, "unknown input `%U'",
818  format_unformat_error, input);
819  }
820 
821  if (!SVM_FIFO_TRACE)
822  {
823  vlib_cli_output (vm, "fifo tracing not enabled");
824  return 0;
825  }
826 
827  if (!s)
828  {
829  vlib_cli_output (vm, "could not find session");
830  return 0;
831  }
832 
833  str = is_rx ?
834  svm_fifo_replay (str, s->rx_fifo, 0, 1) :
835  svm_fifo_replay (str, s->tx_fifo, 0, 1);
836 
837  vlib_cli_output (vm, "%v", str);
838  return 0;
839 }
840 
841 /* *INDENT-OFF* */
843 {
844  .path = "session replay fifo",
845  .short_help = "session replay fifo <session>",
846  .function = session_replay_fifo_command_fn,
847 };
848 /* *INDENT-ON* */
849 
850 static clib_error_t *
852  vlib_cli_command_t * cmd)
853 {
854  unformat_input_t _line_input, *line_input = &_line_input;
855  u8 is_en = 1;
857 
858  if (!unformat_user (input, unformat_line_input, line_input))
859  return clib_error_return (0, "expected enable | disable");
860 
861  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
862  {
863  if (unformat (line_input, "enable"))
864  is_en = 1;
865  else if (unformat (line_input, "disable"))
866  is_en = 0;
867  else
868  {
869  error = clib_error_return (0, "unknown input `%U'",
870  format_unformat_error, line_input);
871  unformat_free (line_input);
872  return error;
873  }
874  }
875 
876  unformat_free (line_input);
877  return vnet_session_enable_disable (vm, is_en);
878 }
879 
880 /* *INDENT-OFF* */
882 {
883  .path = "session",
884  .short_help = "session [enable|disable]",
885  .function = session_enable_disable_fn,
886 };
887 /* *INDENT-ON* */
888 
889 /*
890  * fd.io coding-style-patch-verification: ON
891  *
892  * Local Variables:
893  * eval: (c-set-style "gnu")
894  * End:
895  */
session_lookup_connection6
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.
Definition: session_lookup.c:1197
SESSION_CLI_STATE_LEN
#define SESSION_CLI_STATE_LEN
Definition: session_types.h:507
format_session_flags
u8 * format_session_flags(u8 *s, va_list *args)
Definition: session_cli.c:72
foreach_session_flag
@ foreach_session_flag
Definition: session_types.h:171
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:492
clear_session_command_fn
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:690
foreach_session_state
#define foreach_session_state
Definition: session_types.h:129
SESSION_N_FLAGS
@ SESSION_N_FLAGS
Definition: session_types.h:165
session_::session_index
u32 session_index
Index in thread pool where session was allocated.
Definition: session_types.h:188
vlib_main_t::clib_time
clib_time_t clib_time
Definition: main.h:106
SESSION_CLI_ID_LEN
#define SESSION_CLI_ID_LEN
Definition: session_types.h:506
session_replay_fifo_command_fn
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:804
unformat_line_input
unformat_function_t unformat_line_input
Definition: format.h:275
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
session_::tx_fifo
svm_fifo_t * tx_fifo
Definition: session_types.h:179
svm_fifo_dump_trace
u8 * svm_fifo_dump_trace(u8 *s, svm_fifo_t *f)
Definition: svm_fifo.c:1531
elog_main_t::init_time
elog_time_stamp_t init_time
Timestamps.
Definition: elog.h:172
session_
Definition: session_types.h:175
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
session_main_get_worker_if_valid
static session_worker_t * session_main_get_worker_if_valid(u32 thread_index)
Definition: session.h:708
u8
#define u8
Padding.
Definition: clib.h:121
vlib_cli_command_t::path
char * path
Definition: cli.h:96
wrk
session_worker_t * wrk
Definition: application.c:490
u16
unsigned short u16
Definition: types.h:57
vlib_cli_show_session_command
vlib_cli_command_t vlib_cli_show_session_command
(constructor) VLIB_CLI_COMMAND (vlib_cli_show_session_command)
Definition: session_cli.c:670
session_::thread_index
u8 thread_index
Index of the thread that allocated the session.
Definition: session_types.h:194
session_::session_type
session_type_t session_type
Type built from transport and network protocol types.
Definition: session_types.h:182
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
clib_llist_elts
#define clib_llist_elts(LP)
Get number of elements in supporting container.
Definition: llist.h:91
state
vl_api_dhcp_client_state_t state
Definition: dhcp.api:201
session_node_lookup_fifo_event
u8 session_node_lookup_fifo_event(svm_fifo_t *f, session_event_t *e)
Definition: session_debug.c:213
format_session_state
u8 * format_session_state(u8 *s, va_list *args)
Definition: session_cli.c:53
unformat_transport_connection
uword unformat_transport_connection(unformat_input_t *input, va_list *args)
Definition: session_cli.c:269
transport_connection_t
struct _transport_connection transport_connection_t
unformat_input_t
struct _unformat_input_t unformat_input_t
error
Definition: cJSON.c:88
session_lookup_connection4
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.
Definition: session_lookup.c:980
show_session_command_fn
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:486
session_main_::wrk
session_worker_t * wrk
Worker contexts.
Definition: session.h:176
clib_time_t::seconds_per_clock
f64 seconds_per_clock
Definition: time.h:58
session_lookup_safe6
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.
Definition: session_lookup.c:1260
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
unformat_session
uword unformat_session(unformat_input_t *input, va_list *args)
Definition: session_cli.c:238
pool_is_free_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:302
svm_fifo_replay
u8 * svm_fifo_replay(u8 *s, svm_fifo_t *f, u8 no_read, u8 verbose)
Definition: svm_fifo.c:1555
session_::app_wrk_index
u32 app_wrk_index
Index of the app worker that owns the session.
Definition: session_types.h:191
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
count
u8 count
Definition: dhcp.api:208
session_::rx_fifo
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
Definition: session_types.h:178
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
unformat_free
static void unformat_free(unformat_input_t *i)
Definition: format.h:155
unformat_transport_proto
uword unformat_transport_proto(unformat_input_t *input, va_list *args)
Definition: transport.c:155
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
session_cli_print_session_states
static void session_cli_print_session_states(vlib_main_t *vm)
Definition: session_cli.c:478
elog_time_stamp_t::cpu
u64 cpu
CPU cycle counter.
Definition: elog.h:126
session_get_transport
transport_connection_t * session_get_transport(session_t *s)
Definition: session.c:1745
show_session_fifo_trace_command
static vlib_cli_command_t show_session_fifo_trace_command
(constructor) VLIB_CLI_COMMAND (show_session_fifo_trace_command)
Definition: session_cli.c:795
TRANSPORT_PROTO_INVALID
#define TRANSPORT_PROTO_INVALID
Definition: session.h:257
app_worker_close_notify
int app_worker_close_notify(app_worker_t *app_wrk, session_t *s)
Definition: application_worker.c:407
session_enable_disable_command
static vlib_cli_command_t session_enable_disable_command
(constructor) VLIB_CLI_COMMAND (session_enable_disable_command)
Definition: session_cli.c:881
session_cli_show_events
static void session_cli_show_events(vlib_main_t *vm, u32 thread_index)
Definition: session_cli.c:464
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
end
f64 end
end of the time range
Definition: mactime.api:44
vlib_global_main
vlib_global_main_t vlib_global_main
Definition: main.c:1786
SVM_FIFO_TRACE
#define SVM_FIFO_TRACE
Definition: fifo_types.h:32
uword
u64 uword
Definition: types.h:112
session_flags_str
const char * session_flags_str[]
Definition: session_cli.c:65
unformat_session_state
uword unformat_session_state(unformat_input_t *input, va_list *args)
Definition: session_cli.c:217
last
static heap_elt_t * last(heap_header_t *h)
Definition: heap.c:53
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
session_lookup_safe4
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.
Definition: session_lookup.c:1052
session_cli_filter_check
static int session_cli_filter_check(session_t *s, session_state_t *states, transport_proto_t tp)
Definition: session_cli.c:364
session_main
session_main_t session_main
Definition: session.c:25
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
session_cli_show_events_thread
void session_cli_show_events_thread(vlib_main_t *vm, u32 thread_index)
Definition: session_cli.c:445
f64
double f64
Definition: types.h:142
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
app_name
static char * app_name
Definition: vapi_cpp_test.cpp:33
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
session_main_::is_enabled
u8 is_enabled
Session manager is enabled.
Definition: session.h:202
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
unformat_stream_session_id
uword unformat_stream_session_id(unformat_input_t *input, va_list *args)
Definition: session_cli.c:164
clib_time_t::init_cpu_time
u64 init_cpu_time
Definition: time.h:61
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
clib_min
#define clib_min(x, y)
Definition: clib.h:342
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
vlib_global_main_t::elog_main
elog_main_t elog_main
Definition: main.h:300
format_transport_half_open_connection
u8 * format_transport_half_open_connection(u8 *s, va_list *args)
Definition: transport.c:124
format_elog_track
__clib_export u8 * format_elog_track(u8 *s, va_list *args)
Definition: elog.c:408
session_type_from_proto_and_ip
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
Definition: session_types.h:224
session_worker_::event_elts
session_evt_elt_t * event_elts
Pool of session event list elements.
Definition: session.h:122
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
pool_len
#define pool_len(p)
Number of elements in pool vector.
Definition: pool.h:139
format
description fragment has unexpected format
Definition: map.api:433
session_state_t
session_state_t
Definition: session_types.h:143
session_enable_disable_fn
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:851
session_get_if_valid
static session_t * session_get_if_valid(u64 si, u32 thread_index)
Definition: session.h:343
session_::opaque
u32 opaque
Opaque, for general use.
Definition: session_types.h:218
u32
unsigned int u32
Definition: types.h:88
session_replay_fifo_trace_command
static vlib_cli_command_t session_replay_fifo_trace_command
(constructor) VLIB_CLI_COMMAND (session_replay_fifo_trace_command)
Definition: session_cli.c:842
format_transport_listen_connection
u8 * format_transport_listen_connection(u8 *s, va_list *args)
Definition: transport.c:110
transport_proto_t
enum _transport_proto transport_proto_t
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
format_transport_connection
u8 * format_transport_connection(u8 *s, va_list *args)
Definition: transport.c:80
app_worker_get
app_worker_t * app_worker_get(u32 wrk_index)
Definition: application_worker.c:41
app_worker_
Definition: application.h:32
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
pool_elts
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127
application_name_from_index
const u8 * application_name_from_index(u32 app_index)
Returns app name for app-index.
Definition: application.c:386
session_worker_::sessions
session_t * sessions
Worker session pool.
Definition: session.h:92
SESSION_N_STATES
@ SESSION_N_STATES
Definition: session_types.h:148
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
session_get_transport_proto
static transport_proto_t session_get_transport_proto(session_t *s)
Definition: session_types.h:242
transport_get_connection
static transport_connection_t * transport_get_connection(transport_proto_t tp, u32 conn_index, u8 thread_index)
Definition: transport.h:158
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
session_worker_::ctrl_evts_data
session_evt_ctrl_data_t * ctrl_evts_data
Pool of ctrl events data buffers.
Definition: session.h:125
elog_main_t
Definition: elog.h:132
session.h
transport_elog_track_index
static u32 transport_elog_track_index(transport_connection_t *tc)
Definition: transport.h:260
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
unformat_ip6_address
unformat_function_t unformat_ip6_address
Definition: format.h:89
format_transport_protos
u8 * format_transport_protos(u8 *s, va_list *args)
Definition: transport.c:190
session_::flags
u32 flags
Session flags.
Definition: session_types.h:197
rv
int __clib_unused rv
Definition: application.c:491
unformat_ip4_address
unformat_function_t unformat_ip4_address
Definition: format.h:68
session_pool_remove_peeker
static void session_pool_remove_peeker(u32 thread_index)
Definition: session.h:394
transport_proto
transport_proto
Definition: session.api:22
clear_session
static int clear_session(session_t *s)
Definition: session_cli.c:682
format_svm_fifo
format_function_t format_svm_fifo
Definition: svm_fifo.h:478
session_cli_show_all_sessions
static void session_cli_show_all_sessions(vlib_main_t *vm, int verbose)
Definition: session_cli.c:304
app_worker_::app_index
u32 app_index
Index of owning app.
Definition: application.h:43
session_main_
Definition: session.h:173
session_cli_return_if_not_enabled
#define session_cli_return_if_not_enabled()
Definition: session.h:727
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
session_cli_show_session_filter
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:384
vlib_cli_command_t
Definition: cli.h:92
fib_table_find
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:1106
session_state_str
const char * session_state_str[]
Definition: session_cli.c:46
format_session_fifos
u8 * format_session_fifos(u8 *s, va_list *args)
Definition: session_cli.c:19
session_::session_state
volatile u8 session_state
State in session layer state machine.
Definition: session_types.h:185
session_::connection_index
u32 connection_index
Index of the transport connection associated to the session.
Definition: session_types.h:200
show_session_fifo_trace_command_fn
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:754
clear_session_command
static vlib_cli_command_t clear_session_command
(constructor) VLIB_CLI_COMMAND (clear_session_command)
Definition: session_cli.c:745
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
vnet_session_enable_disable
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1927
session_worker_
Definition: session.h:87
svm_fifo_max_dequeue
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Fifo max bytes to dequeue.
Definition: svm_fifo.h:516
application.h
format_session
u8 * format_session(u8 *s, va_list *args)
Format stream session as per the following format.
Definition: session_cli.c:101