FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
nsh_cli.c
Go to the documentation of this file.
1 /*
2  * nsh_cli.c - nsh cli functions
3  *
4  * Copyright (c) 2019 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <vnet/vnet.h>
19 #include <vnet/plugin/plugin.h>
20 #include <nsh/nsh.h>
21 #include <vnet/adj/adj.h>
22 
23 /* format from network order */
24 u8 *
25 format_nsh_pop_header (u8 * s, va_list * args)
26 {
27  return format_nsh_header (s, args);
28 }
29 
30 u8 *
31 format_nsh_pop_node_map_trace (u8 * s, va_list * args)
32 {
33  return format_nsh_node_map_trace (s, args);
34 }
35 
36 static uword
37 unformat_nsh_action (unformat_input_t * input, va_list * args)
38 {
39  u32 *result = va_arg (*args, u32 *);
40  u32 tmp;
41 
42  if (unformat (input, "swap"))
43  *result = NSH_ACTION_SWAP;
44  else if (unformat (input, "push"))
45  *result = NSH_ACTION_PUSH;
46  else if (unformat (input, "pop"))
47  *result = NSH_ACTION_POP;
48  else if (unformat (input, "%d", &tmp))
49  *result = tmp;
50  else
51  return 0;
52 
53  return 1;
54 }
55 
56 static u8 *
57 format_nsh_action (u8 * s, va_list * args)
58 {
59  u32 nsh_action = va_arg (*args, u32);
60 
61  switch (nsh_action)
62  {
63  case NSH_ACTION_SWAP:
64  return format (s, "swap");
65  case NSH_ACTION_PUSH:
66  return format (s, "push");
67  case NSH_ACTION_POP:
68  return format (s, "pop");
69  default:
70  return format (s, "unknown %d", nsh_action);
71  }
72  return s;
73 }
74 
75 u8 *
76 format_nsh_map (u8 * s, va_list * args)
77 {
78  nsh_map_t *map = va_arg (*args, nsh_map_t *);
79 
80  s = format (s, "nsh entry nsp: %d nsi: %d ",
82  map->nsp_nsi & NSH_NSI_MASK);
83  s = format (s, "maps to nsp: %d nsi: %d ",
84  (map->mapped_nsp_nsi >> NSH_NSP_SHIFT) & NSH_NSP_MASK,
86 
87  s = format (s, " nsh_action %U\n", format_nsh_action, map->nsh_action);
88 
89  switch (map->next_node)
90  {
91  case NSH_NODE_NEXT_ENCAP_GRE4:
92  {
93  s = format (s, "encapped by GRE4 intf: %d", map->sw_if_index);
94  break;
95  }
96  case NSH_NODE_NEXT_ENCAP_GRE6:
97  {
98  s = format (s, "encapped by GRE6 intf: %d", map->sw_if_index);
99  break;
100  }
101  case NSH_NODE_NEXT_ENCAP_VXLANGPE:
102  {
103  s = format (s, "encapped by VXLAN GPE intf: %d", map->sw_if_index);
104  break;
105  }
106  case NSH_NODE_NEXT_ENCAP_VXLAN4:
107  {
108  s = format (s, "encapped by VXLAN4 intf: %d", map->sw_if_index);
109  break;
110  }
111  case NSH_NODE_NEXT_ENCAP_VXLAN6:
112  {
113  s = format (s, "encapped by VXLAN6 intf: %d", map->sw_if_index);
114  break;
115  }
116  case NSH_NODE_NEXT_DECAP_ETH_INPUT:
117  {
118  s = format (s, "encap-none");
119  break;
120  }
121  case NSH_NODE_NEXT_ENCAP_LISP_GPE:
122  {
123  s = format (s, "encapped by LISP GPE intf: %d", map->sw_if_index);
124  break;
125  }
126  case NSH_NODE_NEXT_ENCAP_ETHERNET:
127  {
128  s = format (s, "encapped by Ethernet intf: %d", map->sw_if_index);
129  break;
130  }
131  default:
132  s = format (s, "only GRE and VXLANGPE support in this rev");
133  }
134 
135  return s;
136 }
137 
138 static adj_index_t
140 {
141  adj_index_t ai = ~0;
142 
143  /* *INDENT-OFF* */
145  ({
146  if (sw_if_index == adj_get_sw_if_index(ai))
147  {
148  return ai;
149  }
150  }));
151  /* *INDENT-ON* */
152 
153  return ~0;
154 }
155 
156 
157 /**
158  * CLI command for NSH map
159  */
160 static clib_error_t *
162  unformat_input_t * input,
163  vlib_cli_command_t * cmd)
164 {
165  unformat_input_t _line_input, *line_input = &_line_input;
166  u8 is_add = 1;
167  u32 nsp, nsi, mapped_nsp, mapped_nsi, nsh_action;
168  int nsp_set = 0, nsi_set = 0, mapped_nsp_set = 0, mapped_nsi_set = 0;
169  int nsh_action_set = 0;
170  u32 next_node = ~0;
171  u32 adj_index = ~0;
172  u32 sw_if_index = ~0; // temporary requirement to get this moved over to NSHSFC
173  u32 rx_sw_if_index = ~0; // temporary requirement to get this moved over to NSHSFC
174  nsh_add_del_map_args_t _a, *a = &_a;
175  u32 map_index;
176  int rv;
177 
178  /* Get a line of input. */
179  if (!unformat_user (input, unformat_line_input, line_input))
180  return 0;
181 
182  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
183  {
184  if (unformat (line_input, "del"))
185  is_add = 0;
186  else if (unformat (line_input, "nsp %d", &nsp))
187  nsp_set = 1;
188  else if (unformat (line_input, "nsi %d", &nsi))
189  nsi_set = 1;
190  else if (unformat (line_input, "mapped-nsp %d", &mapped_nsp))
191  mapped_nsp_set = 1;
192  else if (unformat (line_input, "mapped-nsi %d", &mapped_nsi))
193  mapped_nsi_set = 1;
194  else if (unformat (line_input, "nsh_action %U", unformat_nsh_action,
195  &nsh_action))
196  nsh_action_set = 1;
197  else if (unformat (line_input, "encap-gre4-intf %d", &sw_if_index))
198  next_node = NSH_NODE_NEXT_ENCAP_GRE4;
199  else if (unformat (line_input, "encap-gre6-intf %d", &sw_if_index))
200  next_node = NSH_NODE_NEXT_ENCAP_GRE6;
201  else if (unformat (line_input, "encap-vxlan-gpe-intf %d", &sw_if_index))
202  next_node = NSH_NODE_NEXT_ENCAP_VXLANGPE;
203  else if (unformat (line_input, "encap-lisp-gpe-intf %d", &sw_if_index))
204  next_node = NSH_NODE_NEXT_ENCAP_LISP_GPE;
205  else if (unformat (line_input, "encap-vxlan4-intf %d", &sw_if_index))
206  next_node = NSH_NODE_NEXT_ENCAP_VXLAN4;
207  else if (unformat (line_input, "encap-vxlan6-intf %d", &sw_if_index))
208  next_node = NSH_NODE_NEXT_ENCAP_VXLAN6;
209  else if (unformat (line_input, "encap-eth-intf %d", &sw_if_index))
210  {
211  next_node = NSH_NODE_NEXT_ENCAP_ETHERNET;
212  adj_index = nsh_get_adj_by_sw_if_index (sw_if_index);
213  }
214  else
215  if (unformat
216  (line_input, "encap-none %d %d", &sw_if_index, &rx_sw_if_index))
217  next_node = NSH_NODE_NEXT_DECAP_ETH_INPUT;
218  else
219  return clib_error_return (0, "parse error: '%U'",
220  format_unformat_error, line_input);
221  }
222 
223  unformat_free (line_input);
224 
225  if (nsp_set == 0 || nsi_set == 0)
226  return clib_error_return (0, "nsp nsi pair required. Key: for NSH entry");
227 
228  if (mapped_nsp_set == 0 || mapped_nsi_set == 0)
229  return clib_error_return (0,
230  "mapped-nsp mapped-nsi pair required. Key: for NSH entry");
231 
232  if (nsh_action_set == 0)
233  return clib_error_return (0, "nsh_action required: swap|push|pop.");
234 
235  if (next_node == ~0)
236  return clib_error_return (0,
237  "must specific action: [encap-gre-intf <nn> | encap-vxlan-gpe-intf <nn> | encap-lisp-gpe-intf <nn> | encap-none <tx_sw_if_index> <rx_sw_if_index>]");
238 
239  clib_memset (a, 0, sizeof (*a));
240 
241  /* set args structure */
242  a->is_add = is_add;
243  a->map.nsp_nsi = (nsp << NSH_NSP_SHIFT) | nsi;
244  a->map.mapped_nsp_nsi = (mapped_nsp << NSH_NSP_SHIFT) | mapped_nsi;
245  a->map.nsh_action = nsh_action;
247  a->map.rx_sw_if_index = rx_sw_if_index;
248  a->map.next_node = next_node;
249  a->map.adj_index = adj_index;
250 
251  rv = nsh_add_del_map (a, &map_index);
252 
253  switch (rv)
254  {
255  case 0:
256  break;
257  case -1: //TODO API_ERROR_INVALID_VALUE:
258  return clib_error_return (0,
259  "mapping already exists. Remove it first.");
260 
261  case -2: // TODO API_ERROR_NO_SUCH_ENTRY:
262  return clib_error_return (0, "mapping does not exist.");
263 
264  default:
265  return clib_error_return (0, "nsh_add_del_map returned %d", rv);
266  }
267 
268  if ((a->map.next_node == NSH_NODE_NEXT_ENCAP_VXLAN4)
269  | (a->map.next_node == NSH_NODE_NEXT_ENCAP_VXLAN6))
270  {
271  rv = nsh_add_del_proxy_session (a);
272 
273  switch (rv)
274  {
275  case 0:
276  break;
277  case -1: //TODO API_ERROR_INVALID_VALUE:
278  return clib_error_return (0,
279  "nsh-proxy-session already exists. Remove it first.");
280 
281  case -2: // TODO API_ERROR_NO_SUCH_ENTRY:
282  return clib_error_return (0, "nsh-proxy-session does not exist.");
283 
284  default:
285  return clib_error_return
286  (0, "nsh_add_del_proxy_session() returned %d", rv);
287  }
288  }
289 
290  return 0;
291 }
292 
293 /* *INDENT-OFF* */
294 VLIB_CLI_COMMAND (create_nsh_map_command, static) = {
295  .path = "create nsh map",
296  .short_help =
297  "create nsh map nsp <nn> nsi <nn> [del] mapped-nsp <nn> mapped-nsi <nn> nsh_action [swap|push|pop] "
298  "[encap-gre4-intf <nn> | encap-gre4-intf <nn> | encap-vxlan-gpe-intf <nn> | encap-lisp-gpe-intf <nn> "
299  " encap-vxlan4-intf <nn> | encap-vxlan6-intf <nn>| encap-eth-intf <nn> | encap-none]\n",
300  .function = nsh_add_del_map_command_fn,
301 };
302 /* *INDENT-ON* */
303 
304 /**
305  * CLI command for showing the mapping between NSH entries
306  */
307 static clib_error_t *
309  unformat_input_t * input, vlib_cli_command_t * cmd)
310 {
311  nsh_main_t *nm = &nsh_main;
312  nsh_map_t *map;
313 
314  if (pool_elts (nm->nsh_mappings) == 0)
315  vlib_cli_output (vm, "No nsh maps configured.");
316 
317  pool_foreach (map, nm->nsh_mappings, (
318  {
319  vlib_cli_output (vm, "%U",
320  format_nsh_map,
321  map);
322  }
323  ));
324 
325  return 0;
326 }
327 
328 /* *INDENT-OFF* */
329 VLIB_CLI_COMMAND (show_nsh_map_command, static) = {
330  .path = "show nsh map",
331  .function = show_nsh_map_command_fn,
332 };
333 /* *INDENT-ON* */
334 
335 /**
336  * CLI command for adding NSH entry
337  */
338 static clib_error_t *
340  unformat_input_t * input,
341  vlib_cli_command_t * cmd)
342 {
343  unformat_input_t _line_input, *line_input = &_line_input;
344  u8 is_add = 1;
345  u8 ver_o_c = 0;
346  u8 ttl = 63;
347  u8 length = 0;
348  u8 md_type = 0;
349  u8 next_protocol = 1; /* default: ip4 */
350  u32 nsp;
351  u8 nsp_set = 0;
352  u32 nsi;
353  u8 nsi_set = 0;
354  u32 nsp_nsi;
355  u32 c1 = 0;
356  u32 c2 = 0;
357  u32 c3 = 0;
358  u32 c4 = 0;
359  u8 *data = 0;
360  nsh_tlv_header_t tlv_header;
361  u8 cur_len = 0, tlvs_len = 0;
362  u8 *current;
363  nsh_main_t *nm = &nsh_main;
364  nsh_option_map_t _nsh_option, *nsh_option = &_nsh_option;
365  u8 option_size = 0;
366  u32 tmp;
367  int rv;
368  u32 entry_index;
369  nsh_add_del_entry_args_t _a, *a = &_a;
370  u8 has_ioam_trace_option = 0;
371 
372  /* Get a line of input. */
373  if (!unformat_user (input, unformat_line_input, line_input))
374  return 0;
375 
376  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
377  {
378  if (unformat (line_input, "del"))
379  is_add = 0;
380  else if (unformat (line_input, "version %d", &tmp))
381  ver_o_c |= (tmp & 3) << 6;
382  else if (unformat (line_input, "o-bit %d", &tmp))
383  ver_o_c |= (tmp & 1) << 5;
384  else if (unformat (line_input, "c-bit %d", &tmp))
385  ver_o_c |= (tmp & 1) << 4;
386  else if (unformat (line_input, "ttl %d", &ttl))
387  ver_o_c |= (ttl & NSH_LEN_MASK) >> 2;
388  else if (unformat (line_input, "md-type %d", &tmp))
389  md_type = tmp;
390  else if (unformat (line_input, "next-ip4"))
391  next_protocol = 1;
392  else if (unformat (line_input, "next-ip6"))
393  next_protocol = 2;
394  else if (unformat (line_input, "next-ethernet"))
395  next_protocol = 3;
396  else if (unformat (line_input, "c1 %d", &c1))
397  ;
398  else if (unformat (line_input, "c2 %d", &c2))
399  ;
400  else if (unformat (line_input, "c3 %d", &c3))
401  ;
402  else if (unformat (line_input, "c4 %d", &c4))
403  ;
404  else if (unformat (line_input, "nsp %d", &nsp))
405  nsp_set = 1;
406  else if (unformat (line_input, "nsi %d", &nsi))
407  nsi_set = 1;
408  else if (unformat (line_input, "tlv-ioam-trace"))
409  has_ioam_trace_option = 1;
410  else
411  return clib_error_return (0, "parse error: '%U'",
412  format_unformat_error, line_input);
413  }
414 
415  unformat_free (line_input);
416 
417  if (nsp_set == 0)
418  return clib_error_return (0, "nsp not specified");
419 
420  if (nsi_set == 0)
421  return clib_error_return (0, "nsi not specified");
422 
423  if (md_type == 1 && has_ioam_trace_option == 1)
424  return clib_error_return (0, "Invalid MD Type");
425 
426  nsp_nsi = (nsp << 8) | nsi;
427 
428  clib_memset (a, 0, sizeof (*a));
429  a->is_add = is_add;
430 
431  if (md_type == 1)
432  {
433  a->nsh_entry.md.md1_data.c1 = c1;
434  a->nsh_entry.md.md1_data.c2 = c2;
435  a->nsh_entry.md.md1_data.c3 = c3;
436  a->nsh_entry.md.md1_data.c4 = c4;
437  length = (sizeof (nsh_base_header_t) + sizeof (nsh_md1_data_t)) >> 2;
438  }
439  else if (md_type == 2)
440  {
441  length = sizeof (nsh_base_header_t) >> 2;
442 
444  tlvs_len = (MAX_METADATA_LEN << 2);
445  vec_validate_aligned (data, tlvs_len - 1, CLIB_CACHE_LINE_BYTES);
446  a->nsh_entry.tlvs_data = data;
447  current = data;
448 
449  if (has_ioam_trace_option)
450  {
451  tlv_header.class = clib_host_to_net_u16 (NSH_MD2_IOAM_CLASS);
452  tlv_header.type = NSH_MD2_IOAM_OPTION_TYPE_TRACE;
453  /* Uses network order's class and type to lookup */
454  nsh_option =
455  nsh_md2_lookup_option (tlv_header.class, tlv_header.type);
456  if (nsh_option == NULL)
457  return clib_error_return (0, "iOAM Trace not registered");
458 
459  if (nm->add_options[nsh_option->option_id] != NULL)
460  {
461  if (0 != nm->add_options[nsh_option->option_id] ((u8 *) current,
462  &option_size))
463  {
464  return clib_error_return (0, "Invalid MD Type");
465  }
466  }
467 
468  nm->options_size[nsh_option->option_id] = option_size;
469  /* round to 4-byte */
470  option_size = (((option_size + 3) >> 2) << 2);
471 
472  cur_len += option_size;
473  current = data + option_size;
474  }
475 
476  /* Add more options' parsing */
477 
478  a->nsh_entry.tlvs_len = cur_len;
479  length += (cur_len >> 2);
480  }
481  length = (length & NSH_LEN_MASK) | ((ttl & 0x3) << 6);
482 
483 #define _(x) a->nsh_entry.nsh_base.x = x;
485 #undef _
486 
487  rv = nsh_add_del_entry (a, &entry_index);
488 
489  switch (rv)
490  {
491  case 0:
492  break;
493  default:
494  return clib_error_return (0, "nsh_add_del_entry returned %d", rv);
495  }
496 
497  return 0;
498 }
499 
500 /* *INDENT-OFF* */
501 VLIB_CLI_COMMAND (create_nsh_entry_command, static) = {
502  .path = "create nsh entry",
503  .short_help =
504  "create nsh entry {nsp <nn> nsi <nn>} [ttl <nn>] [md-type <nn>]"
505  " [c1 <nn> c2 <nn> c3 <nn> c4 <nn>] [tlv-ioam-trace] [del]\n",
506  .function = nsh_add_del_entry_command_fn,
507 };
508 /* *INDENT-ON* */
509 
510 /* format from network order */
511 u8 *
512 format_nsh_header (u8 * s, va_list * args)
513 {
514  nsh_main_t *nm = &nsh_main;
515  nsh_md2_data_t *opt0;
516  nsh_md2_data_t *limit0;
517  nsh_option_map_t *nsh_option;
518  u8 option_len = 0;
519 
520  u8 *header = va_arg (*args, u8 *);
521  nsh_base_header_t *nsh_base = (nsh_base_header_t *) header;
522  nsh_md1_data_t *nsh_md1 = (nsh_md1_data_t *) (nsh_base + 1);
523  nsh_md2_data_t *nsh_md2 = (nsh_md2_data_t *) (nsh_base + 1);
524  opt0 = (nsh_md2_data_t *) nsh_md2;
525  limit0 = (nsh_md2_data_t *) ((u8 *) nsh_md2 +
526  ((nsh_base->length & NSH_LEN_MASK) * 4
527  - sizeof (nsh_base_header_t)));
528 
529  s = format (s, "nsh ver %d ", (nsh_base->ver_o_c >> 6));
530  if (nsh_base->ver_o_c & NSH_O_BIT)
531  s = format (s, "O-set ");
532 
533  if (nsh_base->ver_o_c & NSH_C_BIT)
534  s = format (s, "C-set ");
535 
536  s = format (s, "ttl %d ", (nsh_base->ver_o_c & NSH_TTL_H4_MASK) << 2 |
537  (nsh_base->length & NSH_TTL_L2_MASK) >> 6);
538 
539  s = format (s, "len %d (%d bytes) md_type %d next_protocol %d\n",
540  (nsh_base->length & NSH_LEN_MASK),
541  (nsh_base->length & NSH_LEN_MASK) * 4,
542  nsh_base->md_type, nsh_base->next_protocol);
543 
544  s = format (s, " service path %d service index %d\n",
545  (clib_net_to_host_u32 (nsh_base->nsp_nsi) >> NSH_NSP_SHIFT) &
546  NSH_NSP_MASK,
547  clib_net_to_host_u32 (nsh_base->nsp_nsi) & NSH_NSI_MASK);
548 
549  if (nsh_base->md_type == 1)
550  {
551  s = format (s, " c1 %d c2 %d c3 %d c4 %d\n",
552  clib_net_to_host_u32 (nsh_md1->c1),
553  clib_net_to_host_u32 (nsh_md1->c2),
554  clib_net_to_host_u32 (nsh_md1->c3),
555  clib_net_to_host_u32 (nsh_md1->c4));
556  }
557  else if (nsh_base->md_type == 2)
558  {
559  s = format (s, " Supported TLVs: \n");
560 
561  /* Scan the set of variable metadata, network order */
562  while (opt0 < limit0)
563  {
564  nsh_option = nsh_md2_lookup_option (opt0->class, opt0->type);
565  if (nsh_option != NULL)
566  {
567  if (nm->trace[nsh_option->option_id] != NULL)
568  {
569  s = (*nm->trace[nsh_option->option_id]) (s, opt0);
570  }
571  else
572  {
573  s =
574  format (s, "\n untraced option %d length %d",
575  opt0->type, opt0->length);
576  }
577  }
578  else
579  {
580  s =
581  format (s, "\n unrecognized option %d length %d",
582  opt0->type, opt0->length);
583  }
584 
585  /* round to 4-byte */
586  option_len = ((opt0->length + 3) >> 2) << 2;
587  opt0 =
588  (nsh_md2_data_t *) (((u8 *) opt0) + sizeof (nsh_md2_data_t) +
589  option_len);
590  }
591  }
592 
593  return s;
594 }
595 
596 u8 *
597 format_nsh_node_map_trace (u8 * s, va_list * args)
598 {
599  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
600  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
601  nsh_input_trace_t *t = va_arg (*args, nsh_input_trace_t *);
602 
603  s = format (s, "\n %U", format_nsh_header, &(t->trace_data));
604 
605  return s;
606 }
607 
608 static clib_error_t *
610  unformat_input_t * input, vlib_cli_command_t * cmd)
611 {
612  nsh_main_t *nm = &nsh_main;
613  nsh_entry_t *nsh_entry;
614 
615  if (pool_elts (nm->nsh_entries) == 0)
616  vlib_cli_output (vm, "No nsh entries configured.");
617 
618  pool_foreach (nsh_entry, nm->nsh_entries, (
619  {
620  vlib_cli_output (vm, "%U",
621  format_nsh_header,
622  nsh_entry->rewrite);
623  vlib_cli_output (vm,
624  " rewrite_size: %d bytes",
625  nsh_entry->rewrite_size);
626  }
627  ));
628 
629  return 0;
630 }
631 
632 /* *INDENT-OFF* */
633 VLIB_CLI_COMMAND (show_nsh_entry_command, static) = {
634  .path = "show nsh entry",
635  .function = show_nsh_entry_command_fn,
636 };
637 /* *INDENT-ON* */
638 
639 /*
640  * fd.io coding-style-patch-verification: ON
641  *
642  * Local Variables:
643  * eval: (c-set-style "gnu")
644  * End:
645  */
u32 sw_if_index
Definition: nsh.h:82
u32 nsh_action
Definition: nsh.h:74
#define NSH_MD2_IOAM_CLASS
Definition: nsh.h:244
#define NSH_NSP_MASK
Definition: nsh_packet.h:113
ip_adjacency_t * adj_pool
The global adjacency pool.
Definition: adj.c:33
#define CLIB_UNUSED(x)
Definition: clib.h:87
a
Definition: bitmap.h:538
static clib_error_t * nsh_add_del_entry_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command for adding NSH entry.
Definition: nsh_cli.c:339
u8 *(* trace[MAX_MD2_OPTIONS])(u8 *s, nsh_tlv_header_t *opt)
Definition: nsh.h:155
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
u32 next_node
Definition: nsh.h:84
static clib_error_t * show_nsh_entry_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: nsh_cli.c:609
static u8 * format_nsh_action(u8 *s, va_list *args)
Definition: nsh_cli.c:57
union nsh_entry_t::@675 md
#define NSH_LEN_MASK
Definition: nsh_packet.h:109
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
vlib_main_t * vm
Definition: in2out_ed.c:1582
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:520
int nsh_add_del_proxy_session(nsh_add_del_map_args_t *a)
Action function to add or del an nsh-proxy-session.
Definition: nsh_api.c:449
u8 * format_nsh_pop_header(u8 *s, va_list *args)
Definition: nsh_cli.c:25
unsigned char u8
Definition: types.h:56
u8 data[128]
Definition: ipsec_types.api:89
u8 options_size[MAX_MD2_OPTIONS]
Definition: nsh.h:145
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:513
int(* add_options[MAX_MD2_OPTIONS])(u8 *opt, u8 *opt_size)
Definition: nsh.h:146
static adj_index_t nsh_get_adj_by_sw_if_index(u32 sw_if_index)
Definition: nsh_cli.c:139
u8 is_add
Definition: nsh.h:55
static uword unformat_nsh_action(unformat_input_t *input, va_list *args)
Definition: nsh_cli.c:37
#define clib_error_return(e, args...)
Definition: error.h:99
#define foreach_copy_nsh_base_hdr_field
Definition: nsh.h:183
nsh_entry_t * nsh_entries
Definition: nsh.h:110
u32 adj_index
Definition: nsh.h:85
unsigned int u32
Definition: types.h:88
nsh_option_map_t * nsh_md2_lookup_option(u16 class, u8 type)
Definition: nsh.c:88
u8 * format_nsh_node_map_trace(u8 *s, va_list *args)
Definition: nsh_cli.c:597
unformat_function_t unformat_line_input
Definition: format.h:283
u8 * format_nsh_header(u8 *s, va_list *args)
Definition: nsh_cli.c:512
Definition: nsh.h:59
nsh_map_t * nsh_mappings
Definition: nsh.h:116
u32 adj_get_sw_if_index(adj_index_t ai)
Return the sw interface index of the adjacency.
Definition: adj.c:520
#define NSH_O_BIT
Definition: nsh_packet.h:104
struct _unformat_input_t unformat_input_t
int nsh_add_del_map(nsh_add_del_map_args_t *a, u32 *map_indexp)
Action function to add or del an nsh map.
Definition: nsh_api.c:347
Definition: nsh.h:54
#define UNFORMAT_END_OF_INPUT
Definition: format.h:145
int nsh_add_del_entry(nsh_add_del_entry_args_t *a, u32 *entry_indexp)
Action function for adding an NSH entry nsh_add_del_entry_args_t *a: host order.
Definition: nsh_api.c:511
static clib_error_t * nsh_add_del_map_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command for NSH map.
Definition: nsh_cli.c:161
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
u8 ttl
Definition: fib_types.api:26
u8 * format_nsh_map(u8 *s, va_list *args)
Definition: nsh_cli.c:76
u32 nsp_nsi
Key for nsh_header_t entry: 24bit NSP 8bit NSI.
Definition: nsh.h:64
#define NSH_NSI_MASK
Definition: nsh_packet.h:112
nsh_main_t nsh_main
Definition: nsh.c:28
u8 tlvs_len
Definition: nsh.h:45
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
#define MAX_METADATA_LEN
Definition: nsh.h:32
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1582
nsh_tlv_header_t nsh_md2_data_t
Definition: nsh_packet.h:93
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:158
u32 mapped_nsp_nsi
Key for nsh_header_t entry to map to.
Definition: nsh.h:72
static clib_error_t * show_nsh_map_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command for showing the mapping between NSH entries.
Definition: nsh_cli.c:308
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:696
u32 rx_sw_if_index
Definition: nsh.h:83
u32 option_id
Definition: nsh.h:29
nsh_map_t map
Definition: nsh.h:90
u8 * format_nsh_pop_node_map_trace(u8 *s, va_list *args)
Definition: nsh_cli.c:31
nsh_md1_data_t md1_data
Definition: nsh.h:42
u8 * tlvs_data
Definition: nsh.h:46
u64 uword
Definition: types.h:112
u8 trace_data[256]
Definition: nsh.h:176
static void unformat_free(unformat_input_t *i)
Definition: format.h:163
#define NSH_NSP_SHIFT
Definition: nsh_packet.h:114
#define NSH_TTL_L2_MASK
Definition: nsh_packet.h:108
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
Note: rewrite and rewrite_size used to support varied nsh header.
Definition: nsh.h:36
#define NSH_TTL_H4_MASK
Definition: nsh_packet.h:107
#define pool_foreach_index(i, v, body)
Iterate pool by index.
Definition: pool.h:558
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
#define NSH_C_BIT
Definition: nsh_packet.h:105
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:33
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
nsh_entry_t nsh_entry
Definition: nsh.h:56
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171
#define NSH_MD2_IOAM_OPTION_TYPE_TRACE
Definition: nsh.h:245
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128