44 #ifndef CLIB_MARCH_VARIANT 48 #define foreach_ip6_hbyh_ioam_input_next \ 49 _(IP6_REWRITE, "ip6-rewrite") \ 50 _(IP6_LOOKUP, "ip6-lookup") \ 55 #define _(s,n) IP6_HBYH_IOAM_INPUT_NEXT_##s, 61 #ifndef CLIB_MARCH_VARIANT 65 u64 *opaquep = va_arg (*args,
u64 *);
69 if (
unformat (input,
"ioam-encap %s", &flow_name))
74 else if (
unformat (input,
"ioam-decap %s", &flow_name))
104 int rewrite_options (
u8 * rewrite_string,
140 int config_handler (
void *
data,
u8 disable))
148 return (VNET_API_ERROR_INVALID_REGISTRATION);
164 return (VNET_API_ERROR_INVALID_REGISTRATION);
173 u32 ioam_flow_handler (
u32 flow_ctx,
u8 add))
181 return (VNET_API_ERROR_INVALID_REGISTRATION);
197 return (VNET_API_ERROR_INVALID_REGISTRATION);
224 #define foreach_ip6_add_hop_by_hop_error \ 225 _(PROCESSED, "Pkts w/ added ip6 hop-by-hop options") 229 #define _(sym,str) IP6_ADD_HOP_BY_HOP_ERROR_##sym, 235 static char *ip6_add_hop_by_hop_error_strings[] = {
236 #define _(sym,string) string, 246 u32 n_left_from, *from, *to_next;
253 n_left_from = frame->n_vectors;
254 next_index = node->cached_next_index;
256 while (n_left_from > 0)
261 while (n_left_from >= 4 && n_left_to_next >= 2)
268 u64 *copy_src0, *copy_dst0, *copy_src1, *copy_dst1;
288 to_next[0] = bi0 = from[0];
289 to_next[1] = bi1 = from[1];
303 copy_dst0 = (
u64 *) (((
u8 *) ip0) - rewrite_length);
304 copy_dst1 = (
u64 *) (((
u8 *) ip1) - rewrite_length);
305 copy_src0 = (
u64 *) ip0;
306 copy_src1 = (
u64 *) ip1;
308 copy_dst0[0] = copy_src0[0];
309 copy_dst0[1] = copy_src0[1];
310 copy_dst0[2] = copy_src0[2];
311 copy_dst0[3] = copy_src0[3];
312 copy_dst0[4] = copy_src0[4];
314 copy_dst1[0] = copy_src1[0];
315 copy_dst1[1] = copy_src1[1];
316 copy_dst1[2] = copy_src1[2];
317 copy_dst1[3] = copy_src1[3];
318 copy_dst1[4] = copy_src1[4];
343 next0 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP;
344 next1 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP;
351 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
357 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
367 to_next, n_left_to_next,
368 bi0, bi1, next0, next1);
370 while (n_left_from > 0 && n_left_to_next > 0)
377 u64 *copy_src0, *copy_dst0;
393 copy_dst0 = (
u64 *) (((
u8 *) ip0) - rewrite_length);
394 copy_src0 = (
u64 *) ip0;
396 copy_dst0[0] = copy_src0[0];
397 copy_dst0[1] = copy_src0[1];
398 copy_dst0[2] = copy_src0[2];
399 copy_dst0[3] = copy_src0[3];
400 copy_dst0[4] = copy_src0[4];
415 next0 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP;
418 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
429 to_next, n_left_to_next,
437 IP6_ADD_HOP_BY_HOP_ERROR_PROCESSED, processed);
438 return frame->n_vectors;
445 "ip6-add-hop-by-hop",.vector_size =
sizeof (
u32),.format_trace =
448 ARRAY_LEN (ip6_add_hop_by_hop_error_strings),.error_strings =
453 #define _(s,n) [IP6_HBYH_IOAM_INPUT_NEXT_##s] = n, 481 #ifndef CLIB_MARCH_VARIANT 519 #define foreach_ip6_pop_hop_by_hop_error \ 520 _(PROCESSED, "Pkts w/ removed ip6 hop-by-hop options") \ 521 _(NO_HOHO, "Pkts w/ no ip6 hop-by-hop options") \ 522 _(OPTION_FAILED, "ip6 pop hop-by-hop failed to process") 526 #define _(sym,str) IP6_POP_HOP_BY_HOP_ERROR_##sym, 532 static char *ip6_pop_hop_by_hop_error_strings[] = {
533 #define _(sym,string) string, 553 ((
u8 *) hbh0 + ((hbh0->
length + 1) << 3));
556 while (opt0 < limit0)
572 ip6_pop_hop_by_hop_node.index,
573 IP6_POP_HOP_BY_HOP_ERROR_OPTION_FAILED,
588 u32 n_left_from, *from, *to_next;
594 n_left_from = frame->n_vectors;
595 next_index = node->cached_next_index;
597 while (n_left_from > 0)
603 while (n_left_from >= 4 && n_left_to_next >= 2)
608 u32 adj_index0, adj_index1;
612 u64 *copy_dst0, *copy_src0, *copy_dst1, *copy_src1;
630 to_next[0] = bi0 = from[0];
631 to_next[1] = bi1 = from[1];
661 ((hbh0->
length + 1) << 3);
663 ((hbh1->
length + 1) << 3);
671 copy_src0 = (
u64 *) ip0;
672 copy_src1 = (
u64 *) ip1;
673 copy_dst0 = copy_src0 + (hbh0->
length + 1);
674 copy_dst0[4] = copy_src0[4];
675 copy_dst0[3] = copy_src0[3];
676 copy_dst0[2] = copy_src0[2];
677 copy_dst0[1] = copy_src0[1];
678 copy_dst0[0] = copy_src0[0];
679 copy_dst1 = copy_src1 + (hbh1->
length + 1);
680 copy_dst1[4] = copy_src1[4];
681 copy_dst1[3] = copy_src1[3];
682 copy_dst1[2] = copy_src1[2];
683 copy_dst1[1] = copy_src1[1];
684 copy_dst1[0] = copy_src1[0];
690 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
696 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
706 to_next, n_left_to_next,
707 bi0, bi1, next0, next1);
710 while (n_left_from > 0 && n_left_to_next > 0)
719 u64 *copy_dst0, *copy_src0;
747 ((hbh0->
length + 1) << 3);
750 copy_src0 = (
u64 *) ip0;
751 copy_dst0 = copy_src0 + (hbh0->
length + 1);
752 copy_dst0[4] = copy_src0[4];
753 copy_dst0[3] = copy_src0[3];
754 copy_dst0[2] = copy_src0[2];
755 copy_dst0[1] = copy_src0[1];
756 copy_dst0[0] = copy_src0[0];
760 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
769 to_next, n_left_to_next,
777 IP6_POP_HOP_BY_HOP_ERROR_PROCESSED, processed);
779 IP6_POP_HOP_BY_HOP_ERROR_NO_HOHO, no_header);
780 return frame->n_vectors;
787 "ip6-pop-hop-by-hop",.vector_size =
sizeof (
u32),.format_trace =
790 ARRAY_LEN (ip6_pop_hop_by_hop_error_strings),.error_strings =
797 #ifndef CLIB_MARCH_VARIANT 828 int has_pot_option,
int has_seqno_option)
835 u8 *trace_data_size =
NULL;
840 if (has_trace_option == 0 && has_pot_option == 0)
858 if (has_seqno_option)
864 rnd_size = (size + 7) & ~7;
871 hbh->
length = (rnd_size >> 3) - 1;
872 current = (
u8 *) (hbh + 1);
884 current += *trace_data_size;
895 current += *pot_data_size;
898 if (has_seqno_option &&
958 .path =
"clear ioam rewrite",
959 .short_help =
"clear ioam rewrite",
966 int has_seqno_option,
int has_analyse_option)
971 has_pot_option, has_seqno_option);
976 if (has_trace_option)
992 if (has_seqno_option)
1006 "ip6_ioam_set_rewrite returned %d", rv);
1018 int has_trace_option = 0;
1019 int has_pot_option = 0;
1020 int has_seqno_option = 0;
1021 int has_analyse_option = 0;
1027 has_trace_option = 1;
1030 else if (
unformat (input,
"seqno"))
1031 has_seqno_option = 1;
1032 else if (
unformat (input,
"analyse"))
1033 has_analyse_option = 1;
1040 has_seqno_option, has_analyse_option);
1065 .path =
"set ioam rewrite",
1066 .short_help =
"set ioam [trace] [pot] [seqno] [analyse]",
1082 s =
format (s,
" REWRITE FLOW CONFIGS - \n");
1083 s =
format (s,
" Destination Address : %U\n",
1086 format (s,
" Flow operation : %d (%s)\n",
1094 s =
format (s,
" REWRITE FLOW CONFIGS - Not configured\n");
1098 s =
format (s,
" TRACE OPTION - %d (%s)\n",
1104 "Try 'show ioam trace and show ioam-trace profile' for more information\n");
1107 s =
format (s,
" POT OPTION - %d (%s)\n",
1113 "Try 'show ioam pot and show pot profile' for more information\n");
1115 s =
format (s,
" EDGE TO EDGE - SeqNo OPTION - %d (%s)\n",
1119 s =
format (s,
"Try 'show ioam e2e' for more information\n");
1121 s =
format (s,
" iOAM Analyse OPTION - %d (%s)\n",
1149 .path =
"show ioam summary",
1150 .short_help =
"show ioam summary",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
ip6_hop_by_hop_ioam_main_t ip6_hop_by_hop_ioam_main
void * ioam_end_of_path_cb
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)
vnet_main_t * vnet_get_main(void)
static clib_error_t * ip6_show_ioam_summary_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_memcpy_fast(a, b, c)
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)
static u8 * format_ip6_add_hop_by_hop_trace(u8 *s, va_list *args)
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
#define VLIB_NODE_FN(node)
ip_lookup_next_t
An adjacency is a representation of an attached L3 peer.
int ip6_hbh_flow_handler_register(u8 option, u32 ioam_flow_handler(u32 flow_ctx, u8 add))
int ip6_hbh_flow_handler_unregister(u8 option)
int ip6_hbh_pop_unregister_option(u8 option)
int ip6_hbh_config_handler_unregister(u8 option)
static char * ip6_add_hop_by_hop_error_strings[]
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
#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))
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
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
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
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).
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
#define VLIB_REGISTER_NODE(x,...)
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)
static u32 ioam_flow_add(u8 encap, u8 *flow_name)
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 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.
void vnet_register_ioam_end_of_path_callback(void *cb)
#define VLIB_CLI_COMMAND(x,...)
static char * ip6_pop_hop_by_hop_error_strings[]
static u8 is_zero_ip6_address(ip6_address_t *a)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#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
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
struct _vlib_node_registration vlib_node_registration_t
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
Next hop after ip4-lookup.
VLIB buffer representation.
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 foreach_ip6_add_hop_by_hop_error
#define IOAM_MASK_DECAP_BIT(x)
#define clib_error_return_code(e, code, flags, args...)
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)
#define VLIB_NODE_FLAG_TRACE
static clib_error_t * ip6_lookup_init(vlib_main_t *vm)
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
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)
ip6_add_hop_by_hop_error_t