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, 62 u64 *opaquep = va_arg (*args,
u64 *);
66 if (
unformat (input,
"ioam-encap %s", &flow_name))
71 else if (
unformat (input,
"ioam-decap %s", &flow_name))
101 int rewrite_options (
u8 * rewrite_string,
137 int config_handler (
void *data,
u8 disable))
145 return (VNET_API_ERROR_INVALID_REGISTRATION);
161 return (VNET_API_ERROR_INVALID_REGISTRATION);
170 u32 ioam_flow_handler (
u32 flow_ctx,
u8 add))
178 return (VNET_API_ERROR_INVALID_REGISTRATION);
194 return (VNET_API_ERROR_INVALID_REGISTRATION);
220 #define foreach_ip6_add_hop_by_hop_error \ 221 _(PROCESSED, "Pkts w/ added ip6 hop-by-hop options") 225 #define _(sym,str) IP6_ADD_HOP_BY_HOP_ERROR_##sym, 231 static char *ip6_add_hop_by_hop_error_strings[] = {
232 #define _(sym,string) string, 242 u32 n_left_from, *from, *to_next;
252 while (n_left_from > 0)
257 while (n_left_from >= 4 && n_left_to_next >= 2)
264 u64 *copy_src0, *copy_dst0, *copy_src1, *copy_dst1;
284 to_next[0] = bi0 = from[0];
285 to_next[1] = bi1 = from[1];
299 copy_dst0 = (
u64 *) (((
u8 *) ip0) - rewrite_length);
300 copy_dst1 = (
u64 *) (((
u8 *) ip1) - rewrite_length);
301 copy_src0 = (
u64 *) ip0;
302 copy_src1 = (
u64 *) ip1;
304 copy_dst0[0] = copy_src0[0];
305 copy_dst0[1] = copy_src0[1];
306 copy_dst0[2] = copy_src0[2];
307 copy_dst0[3] = copy_src0[3];
308 copy_dst0[4] = copy_src0[4];
310 copy_dst1[0] = copy_src1[0];
311 copy_dst1[1] = copy_src1[1];
312 copy_dst1[2] = copy_src1[2];
313 copy_dst1[3] = copy_src1[3];
314 copy_dst1[4] = copy_src1[4];
332 clib_net_to_host_u16 (ip0->payload_length) + rewrite_length;
335 ip0->payload_length = clib_host_to_net_u16 (new_l0);
339 next0 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP;
340 next1 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP;
347 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
353 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
363 to_next, n_left_to_next,
364 bi0, bi1, next0, next1);
366 while (n_left_from > 0 && n_left_to_next > 0)
373 u64 *copy_src0, *copy_dst0;
389 copy_dst0 = (
u64 *) (((
u8 *) ip0) - rewrite_length);
390 copy_src0 = (
u64 *) ip0;
392 copy_dst0[0] = copy_src0[0];
393 copy_dst0[1] = copy_src0[1];
394 copy_dst0[2] = copy_src0[2];
395 copy_dst0[3] = copy_src0[3];
396 copy_dst0[4] = copy_src0[4];
407 clib_net_to_host_u16 (ip0->payload_length) + rewrite_length;
408 ip0->payload_length = clib_host_to_net_u16 (new_l0);
411 next0 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP;
414 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
425 to_next, n_left_to_next,
433 IP6_ADD_HOP_BY_HOP_ERROR_PROCESSED, processed);
441 "ip6-add-hop-by-hop",.vector_size =
sizeof (
u32),.format_trace =
444 ARRAY_LEN (ip6_add_hop_by_hop_error_strings),.error_strings =
449 #define _(s,n) [IP6_HBYH_IOAM_INPUT_NEXT_##s] = n, 515 #define foreach_ip6_pop_hop_by_hop_error \ 516 _(PROCESSED, "Pkts w/ removed ip6 hop-by-hop options") \ 517 _(NO_HOHO, "Pkts w/ no ip6 hop-by-hop options") \ 518 _(OPTION_FAILED, "ip6 pop hop-by-hop failed to process") 522 #define _(sym,str) IP6_POP_HOP_BY_HOP_ERROR_##sym, 528 static char *ip6_pop_hop_by_hop_error_strings[] = {
529 #define _(sym,string) string, 549 ((
u8 *) hbh0 + ((hbh0->
length + 1) << 3));
552 while (opt0 < limit0)
568 ip6_pop_hop_by_hop_node.index,
569 IP6_POP_HOP_BY_HOP_ERROR_OPTION_FAILED,
584 u32 n_left_from, *from, *to_next;
593 while (n_left_from > 0)
599 while (n_left_from >= 4 && n_left_to_next >= 2)
604 u32 adj_index0, adj_index1;
608 u64 *copy_dst0, *copy_src0, *copy_dst1, *copy_src1;
626 to_next[0] = bi0 = from[0];
627 to_next[1] = bi1 = from[1];
657 ((hbh0->
length + 1) << 3);
659 ((hbh1->
length + 1) << 3);
667 copy_src0 = (
u64 *) ip0;
668 copy_src1 = (
u64 *) ip1;
669 copy_dst0 = copy_src0 + (hbh0->
length + 1);
670 copy_dst0[4] = copy_src0[4];
671 copy_dst0[3] = copy_src0[3];
672 copy_dst0[2] = copy_src0[2];
673 copy_dst0[1] = copy_src0[1];
674 copy_dst0[0] = copy_src0[0];
675 copy_dst1 = copy_src1 + (hbh1->
length + 1);
676 copy_dst1[4] = copy_src1[4];
677 copy_dst1[3] = copy_src1[3];
678 copy_dst1[2] = copy_src1[2];
679 copy_dst1[1] = copy_src1[1];
680 copy_dst1[0] = copy_src1[0];
686 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
692 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
702 to_next, n_left_to_next,
703 bi0, bi1, next0, next1);
706 while (n_left_from > 0 && n_left_to_next > 0)
715 u64 *copy_dst0, *copy_src0;
743 ((hbh0->
length + 1) << 3);
746 copy_src0 = (
u64 *) ip0;
747 copy_dst0 = copy_src0 + (hbh0->
length + 1);
748 copy_dst0[4] = copy_src0[4];
749 copy_dst0[3] = copy_src0[3];
750 copy_dst0[2] = copy_src0[2];
751 copy_dst0[1] = copy_src0[1];
752 copy_dst0[0] = copy_src0[0];
756 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
765 to_next, n_left_to_next,
773 IP6_POP_HOP_BY_HOP_ERROR_PROCESSED, processed);
775 IP6_POP_HOP_BY_HOP_ERROR_NO_HOHO, no_header);
783 "ip6-pop-hop-by-hop",.vector_size =
sizeof (
u32),.format_trace =
786 ARRAY_LEN (ip6_pop_hop_by_hop_error_strings),.error_strings =
825 int has_pot_option,
int has_seqno_option)
832 u8 *trace_data_size =
NULL;
837 if (has_trace_option == 0 && has_pot_option == 0)
855 if (has_seqno_option)
861 rnd_size = (size + 7) & ~7;
868 hbh->
length = (rnd_size >> 3) - 1;
869 current = (
u8 *) (hbh + 1);
881 current += *trace_data_size;
892 current += *pot_data_size;
895 if (has_seqno_option &&
955 .path =
"clear ioam rewrite",
956 .short_help =
"clear ioam rewrite",
963 int has_seqno_option,
int has_analyse_option)
968 has_pot_option, has_seqno_option);
973 if (has_trace_option)
989 if (has_seqno_option)
1003 "ip6_ioam_set_rewrite returned %d", rv);
1015 int has_trace_option = 0;
1016 int has_pot_option = 0;
1017 int has_seqno_option = 0;
1018 int has_analyse_option = 0;
1024 has_trace_option = 1;
1027 else if (
unformat (input,
"seqno"))
1028 has_seqno_option = 1;
1029 else if (
unformat (input,
"analyse"))
1030 has_analyse_option = 1;
1037 has_seqno_option, has_analyse_option);
1062 .path =
"set ioam rewrite",
1063 .short_help =
"set ioam [trace] [pot] [seqno] [analyse]",
1079 s =
format (s,
" REWRITE FLOW CONFIGS - \n");
1080 s =
format (s,
" Destination Address : %U\n",
1083 format (s,
" Flow operation : %d (%s)\n",
1091 s =
format (s,
" REWRITE FLOW CONFIGS - Not configured\n");
1095 s =
format (s,
" TRACE OPTION - %d (%s)\n",
1101 "Try 'show ioam trace and show ioam-trace profile' for more information\n");
1104 s =
format (s,
" POT OPTION - %d (%s)\n",
1110 "Try 'show ioam pot and show pot profile' for more information\n");
1112 s =
format (s,
" EDGE TO EDGE - SeqNo OPTION - %d (%s)\n",
1116 s =
format (s,
"Try 'show ioam e2e' for more information\n");
1118 s =
format (s,
" iOAM Analyse OPTION - %d (%s)\n",
1146 .path =
"show ioam summary",
1147 .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)
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)
VLIB_NODE_FUNCTION_MULTIARCH(ip6_add_hop_by_hop_node, ip6_add_hop_by_hop_node_fn)
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)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
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)
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))
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)
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[]
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
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.
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)
u16 flags
Copy of main node flags.
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
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
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