46 #define foreach_ip6_hbyh_ioam_input_next \ 47 _(IP6_REWRITE, "ip6-rewrite") \ 48 _(IP6_LOOKUP, "ip6-lookup") \ 53 #define _(s,n) IP6_HBYH_IOAM_INPUT_NEXT_##s, 71 index = flow - hm->
flows;
72 strncpy ((
char *) flow->
flow_name, (
char *) flow_name, 31);
77 for (i = 0; i < 255; i++)
88 u64 *opaquep = va_arg (*args,
u64 *);
92 if (
unformat (input,
"ioam-encap %s", &flow_name))
97 else if (
unformat (input,
"ioam-decap %s", &flow_name))
127 int rewrite_options (
u8 * rewrite_string,
163 int config_handler (
void *data,
u8 disable))
171 return (VNET_API_ERROR_INVALID_REGISTRATION);
187 return (VNET_API_ERROR_INVALID_REGISTRATION);
204 return (VNET_API_ERROR_INVALID_REGISTRATION);
220 return (VNET_API_ERROR_INVALID_REGISTRATION);
246 #define foreach_ip6_add_hop_by_hop_error \ 247 _(PROCESSED, "Pkts w/ added ip6 hop-by-hop options") 251 #define _(sym,str) IP6_ADD_HOP_BY_HOP_ERROR_##sym, 257 static char *ip6_add_hop_by_hop_error_strings[] = {
258 #define _(sym,string) string, 268 u32 n_left_from, *from, *to_next;
278 while (n_left_from > 0)
283 while (n_left_from >= 4 && n_left_to_next >= 2)
290 u64 *copy_src0, *copy_dst0, *copy_src1, *copy_dst1;
310 to_next[0] = bi0 = from[0];
311 to_next[1] = bi1 = from[1];
325 copy_dst0 = (
u64 *) (((
u8 *) ip0) - rewrite_length);
326 copy_dst1 = (
u64 *) (((
u8 *) ip1) - rewrite_length);
327 copy_src0 = (
u64 *) ip0;
328 copy_src1 = (
u64 *) ip1;
330 copy_dst0[0] = copy_src0[0];
331 copy_dst0[1] = copy_src0[1];
332 copy_dst0[2] = copy_src0[2];
333 copy_dst0[3] = copy_src0[3];
334 copy_dst0[4] = copy_src0[4];
336 copy_dst1[0] = copy_src1[0];
337 copy_dst1[1] = copy_src1[1];
338 copy_dst1[2] = copy_src1[2];
339 copy_dst1[3] = copy_src1[3];
340 copy_dst1[4] = copy_src1[4];
365 next0 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP;
366 next1 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP;
389 to_next, n_left_to_next,
390 bi0, bi1, next0, next1);
392 while (n_left_from > 0 && n_left_to_next > 0)
399 u64 *copy_src0, *copy_dst0;
415 copy_dst0 = (
u64 *) (((
u8 *) ip0) - rewrite_length);
416 copy_src0 = (
u64 *) ip0;
418 copy_dst0[0] = copy_src0[0];
419 copy_dst0[1] = copy_src0[1];
420 copy_dst0[2] = copy_src0[2];
421 copy_dst0[3] = copy_src0[3];
422 copy_dst0[4] = copy_src0[4];
437 next0 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP;
451 to_next, n_left_to_next,
459 IP6_ADD_HOP_BY_HOP_ERROR_PROCESSED, processed);
467 "ip6-add-hop-by-hop",.vector_size =
sizeof (
u32),.format_trace =
470 ARRAY_LEN (ip6_add_hop_by_hop_error_strings),.error_strings =
475 #define _(s,n) [IP6_HBYH_IOAM_INPUT_NEXT_##s] = n, 541 #define foreach_ip6_pop_hop_by_hop_error \ 542 _(PROCESSED, "Pkts w/ removed ip6 hop-by-hop options") \ 543 _(NO_HOHO, "Pkts w/ no ip6 hop-by-hop options") \ 544 _(OPTION_FAILED, "ip6 pop hop-by-hop failed to process") 548 #define _(sym,str) IP6_POP_HOP_BY_HOP_ERROR_##sym, 554 static char *ip6_pop_hop_by_hop_error_strings[] = {
555 #define _(sym,string) string, 575 ((
u8 *) hbh0 + ((hbh0->
length + 1) << 3));
578 while (opt0 < limit0)
594 ip6_pop_hop_by_hop_node.index,
595 IP6_POP_HOP_BY_HOP_ERROR_OPTION_FAILED,
612 u32 n_left_from, *from, *to_next;
621 while (n_left_from > 0)
627 while (n_left_from >= 4 && n_left_to_next >= 2)
632 u32 adj_index0, adj_index1;
636 u64 *copy_dst0, *copy_src0, *copy_dst1, *copy_src1;
654 to_next[0] = bi0 = from[0];
655 to_next[1] = bi1 = from[1];
685 ((hbh0->
length + 1) << 3);
687 ((hbh1->
length + 1) << 3);
695 copy_src0 = (
u64 *) ip0;
696 copy_src1 = (
u64 *) ip1;
697 copy_dst0 = copy_src0 + (hbh0->
length + 1);
698 copy_dst0[4] = copy_src0[4];
699 copy_dst0[3] = copy_src0[3];
700 copy_dst0[2] = copy_src0[2];
701 copy_dst0[1] = copy_src0[1];
702 copy_dst0[0] = copy_src0[0];
703 copy_dst1 = copy_src1 + (hbh1->
length + 1);
704 copy_dst1[4] = copy_src1[4];
705 copy_dst1[3] = copy_src1[3];
706 copy_dst1[2] = copy_src1[2];
707 copy_dst1[1] = copy_src1[1];
708 copy_dst1[0] = copy_src1[0];
730 to_next, n_left_to_next,
731 bi0, bi1, next0, next1);
734 while (n_left_from > 0 && n_left_to_next > 0)
743 u64 *copy_dst0, *copy_src0;
771 ((hbh0->
length + 1) << 3);
774 copy_src0 = (
u64 *) ip0;
775 copy_dst0 = copy_src0 + (hbh0->
length + 1);
776 copy_dst0[4] = copy_src0[4];
777 copy_dst0[3] = copy_src0[3];
778 copy_dst0[2] = copy_src0[2];
779 copy_dst0[1] = copy_src0[1];
780 copy_dst0[0] = copy_src0[0];
793 to_next, n_left_to_next,
801 IP6_POP_HOP_BY_HOP_ERROR_PROCESSED, processed);
803 IP6_POP_HOP_BY_HOP_ERROR_NO_HOHO, no_header);
811 "ip6-pop-hop-by-hop",.vector_size =
sizeof (
u32),.format_trace =
814 ARRAY_LEN (ip6_pop_hop_by_hop_error_strings),.error_strings =
853 int has_pot_option,
int has_seqno_option)
860 u8 *trace_data_size =
NULL;
865 if (has_trace_option == 0 && has_pot_option == 0)
883 if (has_seqno_option)
889 rnd_size = (size + 7) & ~7;
896 hbh->
length = (rnd_size >> 3) - 1;
897 current = (
u8 *) (hbh + 1);
909 current += *trace_data_size;
920 current += *pot_data_size;
923 if (has_seqno_option &&
983 .path =
"clear ioam rewrite",
984 .short_help =
"clear ioam rewrite",
991 int has_seqno_option,
int has_analyse_option)
996 has_pot_option, has_seqno_option);
1001 if (has_trace_option)
1017 if (has_seqno_option)
1023 &has_analyse_option,
1031 "ip6_ioam_set_rewrite returned %d", rv);
1043 int has_trace_option = 0;
1044 int has_pot_option = 0;
1045 int has_seqno_option = 0;
1046 int has_analyse_option = 0;
1052 has_trace_option = 1;
1055 else if (
unformat (input,
"seqno"))
1056 has_seqno_option = 1;
1057 else if (
unformat (input,
"analyse"))
1058 has_analyse_option = 1;
1065 has_seqno_option, has_analyse_option);
1090 .path =
"set ioam rewrite",
1091 .short_help =
"set ioam [trace] [pot] [seqno] [analyse]",
1107 s =
format (s,
" REWRITE FLOW CONFIGS - \n");
1108 s =
format (s,
" Destination Address : %U\n",
1111 format (s,
" Flow operation : %d (%s)\n",
1119 s =
format (s,
" REWRITE FLOW CONFIGS - Not configured\n");
1123 s =
format (s,
" TRACE OPTION - %d (%s)\n",
1129 "Try 'show ioam trace and show ioam-trace profile' for more information\n");
1132 s =
format (s,
" POT OPTION - %d (%s)\n",
1138 "Try 'show ioam pot and show pot profile' for more information\n");
1140 s =
format (s,
" EDGE TO EDGE - SeqNo OPTION - %d (%s)\n",
1144 s =
format (s,
"Try 'show ioam e2e' for more information\n");
1146 s =
format (s,
" iOAM Analyse OPTION - %d (%s)\n",
1174 .path =
"show ioam summary",
1175 .short_help =
"show ioam summary",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static uword ip6_pop_hop_by_hop_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
ip_lookup_next_t
Common (IP4/IP6) next index stored in adjacency.
ip6_hop_by_hop_ioam_main_t ip6_hop_by_hop_ioam_main
void * ioam_end_of_path_cb
#define clib_error_return_code(e, code, flags, args...)
sll srl srl sll sra u16x4 i
static void ioam_pop_hop_by_hop_processing(vlib_main_t *vm, ip6_header_t *ip0, ip6_hop_by_hop_header_t *hbh0, vlib_buffer_t *b)
VLIB_NODE_FUNCTION_MULTIARCH(ip6_add_hop_by_hop_node, ip6_add_hop_by_hop_node_fn)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
static clib_error_t * ip6_show_ioam_summary_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 ioam_flow_add(u8 encap, u8 *flow_name)
static f64 vlib_time_now(vlib_main_t *vm)
static clib_error_t * ip6_set_ioam_rewrite_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
struct _vlib_node_registration vlib_node_registration_t
static u8 * format_ip6_add_hop_by_hop_trace(u8 *s, va_list *args)
u32 ctx[MAX_IP6_HBH_OPTION]
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
int ip6_hbh_flow_handler_register(u8 option, u32 ioam_flow_handler(u32 flow_ctx, u8 add))
static uword ip6_add_hop_by_hop_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
int ip6_hbh_flow_handler_unregister(u8 option)
int ip6_hbh_pop_unregister_option(u8 option)
int ip6_hbh_config_handler_unregister(u8 option)
vnet_main_t * vnet_get_main(void)
static char * ip6_add_hop_by_hop_error_strings[]
#define HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT
#define VLIB_INIT_FUNCTION(x)
#define HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE
int ip6_hbh_pop_register_option(u8 option, int options(vlib_buffer_t *b, ip6_header_t *ip, ip6_hop_by_hop_option_t *opt))
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
ip6_pop_hop_by_hop_error_t
vlib_node_registration_t ip6_pop_hop_by_hop_node
(constructor) VLIB_REGISTER_NODE (ip6_pop_hop_by_hop_node)
#define vlib_call_init_function(vm, x)
int ip6_ioam_set_rewrite(u8 **rwp, int has_trace_option, int has_pot_option, int has_seqno_option)
u8 options_size[MAX_IP6_HBH_OPTION]
static uword unformat_opaque_ioam(unformat_input_t *input, va_list *args)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define foreach_ip6_pop_hop_by_hop_error
void vnet_classify_register_unformat_opaque_index_fn(unformat_function_t *fn)
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
clib_error_t * ip_main_init(vlib_main_t *vm)
u32(* flow_handler[MAX_IP6_HBH_OPTION])(u32 flow_ctx, u8 add)
static u8 * format_ip6_pop_hop_by_hop_trace(u8 *s, va_list *args)
#define CLIB_PREFETCH(addr, size, type)
int ip6_hbh_config_handler_register(u8 option, int config_handler(void *data, u8 disable))
#define vec_free(V)
Free vector's memory (no header).
int ip6_hbh_add_unregister_option(u8 option)
#define clib_memcpy(a, b, c)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
clib_error_t * ip6_ioam_enable(int has_trace_option, int has_pot_option, int has_seqno_option, int has_analyse_option)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
void vnet_register_ioam_end_of_path_callback(void *cb)
#define VLIB_CLI_COMMAND(x,...)
static char * ip6_pop_hop_by_hop_error_strings[]
ip_lookup_main_t lookup_main
static u8 is_zero_ip6_address(ip6_address_t *a)
#define VLIB_NODE_FLAG_TRACE
#define HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST
int(* config_handler[MAX_IP6_HBH_OPTION])(void *data, u8 disable)
#define foreach_ip6_hbyh_ioam_input_next
#define VLIB_BUFFER_IS_TRACED
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define IOAM_SET_DECAP(opaque_data)
u8 * get_flow_name_from_flow_ctx(u32 flow_ctx)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip6_hbyh_ioam_input_next_t
static clib_error_t * ip6_hop_by_hop_ioam_init(vlib_main_t *vm)
ip_lookup_next_t lookup_next_index
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
clib_error_t * clear_ioam_rewrite_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define foreach_ip6_add_hop_by_hop_error
#define VLIB_REGISTER_NODE(x,...)
#define IOAM_MASK_DECAP_BIT(x)
clib_error_t * clear_ioam_rewrite_fn(void)
int ip6_hbh_add_register_option(u8 option, u8 size, int rewrite_options(u8 *rewrite_string, u8 *rewrite_size))
int(* pop_options[MAX_IP6_HBH_OPTION])(vlib_buffer_t *b, ip6_header_t *ip, ip6_hop_by_hop_option_t *opt)
static clib_error_t * ip6_lookup_init(vlib_main_t *vm)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
vlib_node_registration_t ip6_add_hop_by_hop_node
(constructor) VLIB_REGISTER_NODE (ip6_add_hop_by_hop_node)
int(* add_options[MAX_IP6_HBH_OPTION])(u8 *rewrite_string, u8 *rewrite_size)
static ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
ip6_add_hop_by_hop_error_t