39 u32 *result = va_arg (*args,
u32 *);
48 else if (
unformat (input,
"%d", &tmp))
59 u32 nsh_action = va_arg (*args,
u32);
70 return format (s,
"unknown %d", nsh_action);
80 s =
format (s,
"nsh entry nsp: %d nsi: %d ",
83 s =
format (s,
"maps to nsp: %d nsi: %d ",
91 case NSH_NODE_NEXT_ENCAP_GRE4:
96 case NSH_NODE_NEXT_ENCAP_GRE6:
101 case NSH_NODE_NEXT_ENCAP_VXLANGPE:
106 case NSH_NODE_NEXT_ENCAP_VXLAN4:
111 case NSH_NODE_NEXT_ENCAP_VXLAN6:
116 case NSH_NODE_NEXT_DECAP_ETH_INPUT:
118 s =
format (s,
"encap-none");
121 case NSH_NODE_NEXT_ENCAP_LISP_GPE:
126 case NSH_NODE_NEXT_ENCAP_ETHERNET:
132 s =
format (s,
"only GRE and VXLANGPE support in this rev");
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;
173 u32 rx_sw_if_index = ~0;
186 else if (
unformat (line_input,
"nsp %d", &nsp))
188 else if (
unformat (line_input,
"nsi %d", &nsi))
190 else if (
unformat (line_input,
"mapped-nsp %d", &mapped_nsp))
192 else if (
unformat (line_input,
"mapped-nsi %d", &mapped_nsi))
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))
211 next_node = NSH_NODE_NEXT_ENCAP_ETHERNET;
216 (line_input,
"encap-none %d %d", &sw_if_index, &rx_sw_if_index))
217 next_node = NSH_NODE_NEXT_DECAP_ETH_INPUT;
225 if (nsp_set == 0 || nsi_set == 0)
228 if (mapped_nsp_set == 0 || mapped_nsi_set == 0)
230 "mapped-nsp mapped-nsi pair required. Key: for NSH entry");
232 if (nsh_action_set == 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>]");
259 "mapping already exists. Remove it first.");
279 "nsh-proxy-session already exists. Remove it first.");
286 (0,
"nsh_add_del_proxy_session() returned %d", rv);
295 .path =
"create nsh map",
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",
319 vlib_cli_output (vm,
"%U",
330 .path =
"show nsh map",
349 u8 next_protocol = 1;
360 nsh_tlv_header_t tlv_header;
361 u8 cur_len = 0, tlvs_len = 0;
370 u8 has_ioam_trace_option = 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))
388 else if (
unformat (line_input,
"md-type %d", &tmp))
390 else if (
unformat (line_input,
"next-ip4"))
392 else if (
unformat (line_input,
"next-ip6"))
394 else if (
unformat (line_input,
"next-ethernet"))
396 else if (
unformat (line_input,
"c1 %d", &c1))
398 else if (
unformat (line_input,
"c2 %d", &c2))
400 else if (
unformat (line_input,
"c3 %d", &c3))
402 else if (
unformat (line_input,
"c4 %d", &c4))
404 else if (
unformat (line_input,
"nsp %d", &nsp))
406 else if (
unformat (line_input,
"nsi %d", &nsi))
408 else if (
unformat (line_input,
"tlv-ioam-trace"))
409 has_ioam_trace_option = 1;
423 if (md_type == 1 && has_ioam_trace_option == 1)
426 nsp_nsi = (nsp << 8) | nsi;
437 length = (
sizeof (nsh_base_header_t) +
sizeof (nsh_md1_data_t)) >> 2;
439 else if (md_type == 2)
441 length =
sizeof (nsh_base_header_t) >> 2;
449 if (has_ioam_trace_option)
456 if (nsh_option ==
NULL)
470 option_size = (((option_size + 3) >> 2) << 2);
472 cur_len += option_size;
473 current = data + option_size;
479 length += (cur_len >> 2);
483 #define _(x) a->nsh_entry.nsh_base.x = x; 502 .path =
"create nsh entry",
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",
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);
527 -
sizeof (nsh_base_header_t)));
529 s =
format (s,
"nsh ver %d ", (nsh_base->ver_o_c >> 6));
539 s =
format (s,
"len %d (%d bytes) md_type %d next_protocol %d\n",
542 nsh_base->md_type, nsh_base->next_protocol);
544 s =
format (s,
" service path %d service index %d\n",
545 (clib_net_to_host_u32 (nsh_base->nsp_nsi) >>
NSH_NSP_SHIFT) &
547 clib_net_to_host_u32 (nsh_base->nsp_nsi) &
NSH_NSI_MASK);
549 if (nsh_base->md_type == 1)
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));
557 else if (nsh_base->md_type == 2)
559 s =
format (s,
" Supported TLVs: \n");
562 while (opt0 < limit0)
565 if (nsh_option !=
NULL)
574 format (s,
"\n untraced option %d length %d",
575 opt0->type, opt0->length);
581 format (s,
"\n unrecognized option %d length %d",
582 opt0->type, opt0->length);
586 option_len = ((opt0->length + 3) >> 2) << 2;
620 vlib_cli_output (vm,
"%U",
624 " rewrite_size: %d bytes",
625 nsh_entry->rewrite_size);
634 .path =
"show nsh entry",
#define NSH_MD2_IOAM_CLASS
ip_adjacency_t * adj_pool
The global adjacnecy pool.
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.
u8 *(* trace[MAX_MD2_OPTIONS])(u8 *s, nsh_tlv_header_t *opt)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static clib_error_t * show_nsh_entry_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static u8 * format_nsh_action(u8 *s, va_list *args)
union nsh_entry_t::@555 md
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
int nsh_add_del_proxy_session(nsh_add_del_map_args_t *a)
Action function to add or del an nsh-proxy-session.
u8 * format_nsh_pop_header(u8 *s, va_list *args)
u8 options_size[MAX_MD2_OPTIONS]
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
int(* add_options[MAX_MD2_OPTIONS])(u8 *opt, u8 *opt_size)
static adj_index_t nsh_get_adj_by_sw_if_index(u32 sw_if_index)
static uword unformat_nsh_action(unformat_input_t *input, va_list *args)
#define clib_error_return(e, args...)
#define foreach_copy_nsh_base_hdr_field
nsh_entry_t * nsh_entries
nsh_option_map_t * nsh_md2_lookup_option(u16 class, u8 type)
u8 * format_nsh_node_map_trace(u8 *s, va_list *args)
u8 * format_nsh_header(u8 *s, va_list *args)
u32 adj_get_sw_if_index(adj_index_t ai)
Return the sw interface index of the adjacency.
int nsh_add_del_map(nsh_add_del_map_args_t *a, u32 *map_indexp)
Action function to add or del an nsh map.
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.
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.
#define vec_free(V)
Free vector's memory (no header).
u8 * format_nsh_map(u8 *s, va_list *args)
u32 nsp_nsi
Key for nsh_header_t entry: 24bit NSP 8bit NSI.
u32 adj_index_t
An index for adjacencies.
nsh_tlv_header_t nsh_md2_data_t
#define VLIB_CLI_COMMAND(x,...)
u32 mapped_nsp_nsi
Key for nsh_header_t entry to map to.
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.
u8 * format_nsh_pop_node_map_trace(u8 *s, va_list *args)
Note: rewrite and rewrite_size used to support varied nsh header.
#define pool_foreach_index(i, v, body)
Iterate pool by index.
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define NSH_MD2_IOAM_OPTION_TYPE_TRACE
static uword pool_elts(void *v)
Number of active elements in a pool.