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];
336 clib_net_to_host_u16 (ip0->payload_length) + rewrite_length;
339 ip0->payload_length = clib_host_to_net_u16 (new_l0);
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];
411 clib_net_to_host_u16 (ip0->payload_length) + rewrite_length;
412 ip0->payload_length = clib_host_to_net_u16 (new_l0);
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;
444 .name =
"ip6-add-hop-by-hop",
445 .vector_size =
sizeof (
u32),
448 .n_errors =
ARRAY_LEN (ip6_add_hop_by_hop_error_strings),
453 #define _(s,n) [IP6_HBYH_IOAM_INPUT_NEXT_##s] = n, 479 #ifndef CLIB_MARCH_VARIANT 517 #define foreach_ip6_pop_hop_by_hop_error \ 518 _(PROCESSED, "Pkts w/ removed ip6 hop-by-hop options") \ 519 _(NO_HOHO, "Pkts w/ no ip6 hop-by-hop options") \ 520 _(OPTION_FAILED, "ip6 pop hop-by-hop failed to process") 524 #define _(sym,str) IP6_POP_HOP_BY_HOP_ERROR_##sym, 530 static char *ip6_pop_hop_by_hop_error_strings[] = {
531 #define _(sym,string) string, 551 ((
u8 *) hbh0 + ((hbh0->
length + 1) << 3));
554 while (opt0 < limit0)
570 ip6_pop_hop_by_hop_node.index,
571 IP6_POP_HOP_BY_HOP_ERROR_OPTION_FAILED,
586 u32 n_left_from, *from, *to_next;
592 n_left_from =
frame->n_vectors;
593 next_index = node->cached_next_index;
595 while (n_left_from > 0)
601 while (n_left_from >= 4 && n_left_to_next >= 2)
606 u32 adj_index0, adj_index1;
610 u64 *copy_dst0, *copy_src0, *copy_dst1, *copy_src1;
628 to_next[0] = bi0 = from[0];
629 to_next[1] = bi1 = from[1];
659 ((hbh0->
length + 1) << 3);
661 ((hbh1->
length + 1) << 3);
669 copy_src0 = (
u64 *) ip0;
670 copy_src1 = (
u64 *) ip1;
671 copy_dst0 = copy_src0 + (hbh0->
length + 1);
672 copy_dst0[4] = copy_src0[4];
673 copy_dst0[3] = copy_src0[3];
674 copy_dst0[2] = copy_src0[2];
675 copy_dst0[1] = copy_src0[1];
676 copy_dst0[0] = copy_src0[0];
677 copy_dst1 = copy_src1 + (hbh1->
length + 1);
678 copy_dst1[4] = copy_src1[4];
679 copy_dst1[3] = copy_src1[3];
680 copy_dst1[2] = copy_src1[2];
681 copy_dst1[1] = copy_src1[1];
682 copy_dst1[0] = copy_src1[0];
688 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
694 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
704 to_next, n_left_to_next,
705 bi0, bi1, next0, next1);
708 while (n_left_from > 0 && n_left_to_next > 0)
717 u64 *copy_dst0, *copy_src0;
745 ((hbh0->
length + 1) << 3);
748 copy_src0 = (
u64 *) ip0;
749 copy_dst0 = copy_src0 + (hbh0->
length + 1);
750 copy_dst0[4] = copy_src0[4];
751 copy_dst0[3] = copy_src0[3];
752 copy_dst0[2] = copy_src0[2];
753 copy_dst0[1] = copy_src0[1];
754 copy_dst0[0] = copy_src0[0];
758 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
767 to_next, n_left_to_next,
775 IP6_POP_HOP_BY_HOP_ERROR_PROCESSED, processed);
777 IP6_POP_HOP_BY_HOP_ERROR_NO_HOHO, no_header);
778 return frame->n_vectors;
784 .name =
"ip6-pop-hop-by-hop",
785 .vector_size =
sizeof (
u32),
788 .sibling_of =
"ip6-lookup",
789 .n_errors =
ARRAY_LEN (ip6_pop_hop_by_hop_error_strings),
802 #ifndef CLIB_MARCH_VARIANT 813 s =
format (s,
"IP6_LOCAL_HOP_BY_HOP: protocol %d, next index %d\n",
822 #define foreach_ip6_local_hop_by_hop_error \ 823 _(UNKNOWN, "Unknown protocol ip6 local h-b-h packets dropped") \ 824 _(OK, "Good ip6 local h-b-h packets") 828 #define _(sym,str) IP6_LOCAL_HOP_BY_HOP_ERROR_##sym, 834 #ifndef CLIB_MARCH_VARIANT 835 static char *ip6_local_hop_by_hop_error_strings[] = {
836 #define _(sym,string) string, 853 u32 n_left_from, *from;
857 u32 unknown_proto_error = node->
errors[IP6_LOCAL_HOP_BY_HOP_ERROR_UNKNOWN];
870 while (n_left_from >= 4)
873 u8 *hbh0, *hbh1, *hbh2, *hbh3;
913 b[0]->
error = unknown_proto_error;
914 b[1]->
error = unknown_proto_error;
915 b[2]->
error = unknown_proto_error;
916 b[3]->
error = unknown_proto_error;
926 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
933 if (b[1]->
flags & VLIB_BUFFER_IS_TRACED)
940 if (b[2]->
flags & VLIB_BUFFER_IS_TRACED)
947 if (b[3]->
flags & VLIB_BUFFER_IS_TRACED)
961 while (n_left_from > 0)
972 b[0]->
error = unknown_proto_error;
977 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
994 IP6_LOCAL_HOP_BY_HOP_ERROR_OK, ok);
1008 #ifndef CLIB_MARCH_VARIANT 1012 .name =
"ip6-local-hop-by-hop",
1013 .vector_size =
sizeof (
u32),
1017 .n_errors =
ARRAY_LEN(ip6_local_hop_by_hop_error_strings),
1064 .path =
"show ip6 hbh",
1065 .short_help =
"show ip6 hbh",
1074 #ifndef CLIB_MARCH_VARIANT 1104 ip6_local_hop_by_hop_node.index);
1111 .runs_after =
VLIB_INITS(
"ip_main_init",
"ip6_lookup_init"),
1132 if (old_next_index &&
1134 clib_warning (
"WARNING: replaced next index for protocol %d", protocol);
1139 int has_pot_option,
int has_seqno_option)
1146 u8 *trace_data_size =
NULL;
1147 u8 *pot_data_size =
NULL;
1151 if (has_trace_option == 0 && has_pot_option == 0)
1158 if (has_trace_option
1169 if (has_seqno_option)
1175 rnd_size = (size + 7) & ~7;
1182 hbh->
length = (rnd_size >> 3) - 1;
1183 current = (
u8 *) (hbh + 1);
1185 if (has_trace_option
1195 current += *trace_data_size;
1206 current += *pot_data_size;
1209 if (has_seqno_option &&
1269 .path =
"clear ioam rewrite",
1270 .short_help =
"clear ioam rewrite",
1277 int has_seqno_option,
int has_analyse_option)
1282 has_pot_option, has_seqno_option);
1287 if (has_trace_option)
1303 if (has_seqno_option)
1309 &has_analyse_option,
1317 "ip6_ioam_set_rewrite returned %d", rv);
1329 int has_trace_option = 0;
1330 int has_pot_option = 0;
1331 int has_seqno_option = 0;
1332 int has_analyse_option = 0;
1338 has_trace_option = 1;
1341 else if (
unformat (input,
"seqno"))
1342 has_seqno_option = 1;
1343 else if (
unformat (input,
"analyse"))
1344 has_analyse_option = 1;
1351 has_seqno_option, has_analyse_option);
1376 .path =
"set ioam rewrite",
1377 .short_help =
"set ioam [trace] [pot] [seqno] [analyse]",
1393 s =
format (s,
" REWRITE FLOW CONFIGS - \n");
1394 s =
format (s,
" Destination Address : %U\n",
1397 format (s,
" Flow operation : %d (%s)\n",
1405 s =
format (s,
" REWRITE FLOW CONFIGS - Not configured\n");
1409 s =
format (s,
" TRACE OPTION - %d (%s)\n",
1415 "Try 'show ioam trace and show ioam-trace profile' for more information\n");
1418 s =
format (s,
" POT OPTION - %d (%s)\n",
1424 "Try 'show ioam pot and show pot profile' for more information\n");
1426 s =
format (s,
" EDGE TO EDGE - SeqNo OPTION - %d (%s)\n",
1430 s =
format (s,
"Try 'show ioam e2e' for more information\n");
1432 s =
format (s,
" iOAM Analyse OPTION - %d (%s)\n",
1460 .path =
"show ioam summary",
1461 .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.
void ip6_local_hop_by_hop_register_protocol(u32 protocol, u32 node_index)
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)
void ip6_register_protocol(u32 protocol, u32 node_index)
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)
#define foreach_ip6_local_hop_by_hop_error
static u8 * format_ip6_add_hop_by_hop_trace(u8 *s, va_list *args)
#define VLIB_NODE_FN(node)
vlib_error_t * errors
Vector of errors for this node.
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_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)
vl_api_ip_proto_t protocol
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]
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
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)
vlib_node_registration_t ip6_local_hop_by_hop_node
(constructor) VLIB_REGISTER_NODE (ip6_local_hop_by_hop_node)
u32 node_index
Node index.
#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).
ip6_local_hop_by_hop_runtime_t * ip6_local_hbh_runtime
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
clib_error_t * show_ip6_hbh_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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)
static uword ip6_local_hop_by_hop_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_trace)
#define CLIB_PREFETCH(addr, size, type)
int ip6_hbh_config_handler_register(u8 option, int config_handler(void *data, u8 disable))
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
#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)
#define clib_warning(format, args...)
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.
vlib_main_t vlib_node_runtime_t * node
static void * ip6_next_header(ip6_header_t *i)
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 char * ip6_local_hop_by_hop_error_strings[]
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 u8 * format_ip6_local_hop_by_hop_trace(u8 *s, va_list *args)
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)
static void * clib_mem_alloc_aligned(uword size, uword align)
static struct option options[]
#define foreach_ip6_add_hop_by_hop_error
#define IOAM_MASK_DECAP_BIT(x)
#define clib_error_return_code(e, code, flags, args...)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
clib_error_t * clear_ioam_rewrite_fn(void)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
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_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE
static clib_error_t * ip6_lookup_init(vlib_main_t *vm)
#define CLIB_CACHE_LINE_BYTES
ip6_local_hop_by_hop_error_t
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)
ip6_local_hop_by_hop_next_t
int(* add_options[MAX_IP6_HBH_OPTION])(u8 *rewrite_string, u8 *rewrite_size)
u8 next_index_by_protocol[256]
ip6_add_hop_by_hop_error_t