47 u8 code = va_arg (*args,
int);
50 #define _(n,f) case n: t = #f; break; 63 return format (s,
"unknown 0x%x", type);
68 switch ((type << 8) | code)
70 #define _(a,n,f) case (ICMP6_##a << 8) | (n): t = #f; break; 85 icmp46_header_t * icmp = va_arg (*args, icmp46_header_t *);
86 u32 max_header_bytes = va_arg (*args,
u32);
89 if (max_header_bytes <
sizeof (icmp[0]))
90 return format (s,
"ICMP header truncated");
92 s =
format (s,
"ICMP %U checksum 0x%x",
94 clib_net_to_host_u16 (icmp->checksum));
96 if (max_header_bytes >=
97 sizeof(icmp6_neighbor_solicitation_or_advertisement_header_t) &&
98 (icmp->type == ICMP6_neighbor_solicitation ||
99 icmp->type == ICMP6_neighbor_advertisement))
101 icmp6_neighbor_solicitation_or_advertisement_header_t *icmp6_nd =
102 (icmp6_neighbor_solicitation_or_advertisement_header_t *) icmp;
103 s =
format (s,
"\n target address %U",
140 u8 input_next_index_by_type[256];
143 u8 max_valid_code_by_type[256];
146 u8 min_valid_hop_limit_by_type[256];
148 u8 min_valid_length_by_type[256];
159 u32 * from, * to_next;
160 u32 n_left_from, n_left_to_next, next_index;
171 while (n_left_from > 0)
175 while (n_left_from > 0 && n_left_to_next > 0)
179 icmp46_header_t * icmp0;
181 u32 bi0, next0, error0, len0;
183 bi0 = to_next[0] = from[0];
195 error0 = ICMP6_ERROR_NONE;
216 to_next, n_left_to_next,
228 .name =
"ip6-icmp-input",
230 .vector_size =
sizeof (
u32),
254 u32 * from, * to_next;
255 u32 n_left_from, n_left_to_next, next_index;
267 while (n_left_from > 0)
271 while (n_left_from > 2 && n_left_to_next > 2)
275 icmp46_header_t * icmp0, * icmp1;
279 u32 fib_index0, fib_index1;
283 bi0 = to_next[0] = from[0];
284 bi1 = to_next[1] = from[1];
299 sum0 = icmp0->checksum;
300 sum1 = icmp1->checksum;
302 ASSERT (icmp0->type == ICMP6_echo_request);
303 ASSERT (icmp1->type == ICMP6_echo_request);
304 sum0 =
ip_csum_update (sum0, ICMP6_echo_request, ICMP6_echo_reply,
305 icmp46_header_t,
type);
306 sum1 =
ip_csum_update (sum1, ICMP6_echo_request, ICMP6_echo_reply,
307 icmp46_header_t,
type);
312 icmp0->type = ICMP6_echo_reply;
313 icmp1->type = ICMP6_echo_reply;
385 to_next, n_left_to_next,
386 bi0, bi1, next0, next1);
389 while (n_left_from > 0 && n_left_to_next > 0)
393 icmp46_header_t * icmp0;
400 bi0 = to_next[0] = from[0];
412 sum0 = icmp0->checksum;
414 ASSERT (icmp0->type == ICMP6_echo_request);
415 sum0 =
ip_csum_update (sum0, ICMP6_echo_request, ICMP6_echo_reply,
416 icmp46_header_t,
type);
420 icmp0->type = ICMP6_echo_reply;
456 to_next, n_left_to_next,
464 ICMP6_ERROR_ECHO_REPLIES_SENT,
472 .name =
"ip6-icmp-echo-request",
474 .vector_size =
sizeof (
u32),
503 case ICMP6_destination_unreachable:
504 return ICMP6_ERROR_DEST_UNREACH_SENT;
505 case ICMP6_packet_too_big:
506 return ICMP6_ERROR_PACKET_TOO_BIG_SENT;
507 case ICMP6_time_exceeded:
508 return ICMP6_ERROR_TTL_EXPIRE_SENT;
509 case ICMP6_parameter_problem:
510 return ICMP6_ERROR_PARAM_PROBLEM_SENT;
512 return ICMP6_ERROR_DROP;
521 u32 * from, * to_next;
522 uword n_left_from, n_left_to_next;
535 while (n_left_from > 0)
539 while (n_left_from > 0 && n_left_to_next > 0)
543 u8 error0 = ICMP6_ERROR_NONE;
546 icmp46_header_t * icmp0;
547 u32 sw_if_index0, if_add_index0;
580 icmp0 = (icmp46_header_t *) &out_ip0[1];
584 clib_host_to_net_u32(0x6<<28);
587 out_ip0->
protocol = IP_PROTOCOL_ICMP6;
603 error0 = ICMP6_ERROR_DROP;
609 *((
u32 *)(icmp0 + 1)) = clib_host_to_net_u32(
vnet_buffer(p0)->ip.icmp.data);
612 vm, p0, out_ip0, &bogus_length);
617 if (error0 == ICMP6_ERROR_NONE)
623 to_next, n_left_to_next,
634 .name =
"ip6-icmp-error",
635 .vector_size =
sizeof (
u32),
652 icmp46_header_t * h = va_arg (*args, icmp46_header_t *);
659 h->type = (i >> 8) & 0xff;
660 h->code = (i >> 0) & 0xff;
682 u32 ip_offset, icmp_offset;
686 ip_offset = (g-1)->start_byte_offset;
688 while (n_packets >= 1)
692 icmp46_header_t * icmp0;
699 ip0 = (
void *) (p0->
data + ip_offset);
700 icmp0 = (
void *) (p0->
data + icmp_offset);
704 ASSERT (bogus_length == 0);
717 #define _(f) pg_edit_init (&p->f, icmp46_header_t, f); 805 #define _(n,t) hash_set_mem (cm->type_by_name, #t, (n)); 810 #define _(a,n,t) hash_set_mem (cm->type_by_name, #t, (n) | (ICMP6_##a << 8)); 819 #define _(a,n,t) cm->max_valid_code_by_type[ICMP6_##a] = clib_max (cm->max_valid_code_by_type[ICMP6_##a], n); 834 =
sizeof (icmp6_neighbor_solicitation_or_advertisement_header_t);
836 =
sizeof (icmp6_neighbor_solicitation_or_advertisement_header_t);
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
always_inline void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
sll srl srl sll sra u16x4 i
static char * icmp_error_strings[]
uword * type_and_code_by_name
static u8 * format_icmp6_header(u8 *s, va_list *args)
static clib_error_t * ip6_neighbor_init(vlib_main_t *vm)
static u8 * format_ip6_icmp_type_and_code(u8 *s, va_list *args)
ip_interface_address_t * if_address_pool
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
static void pg_edit_set_fixed(pg_edit_t *e, u64 value)
static uword ip6_icmp_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
always_inline uword ip6_address_is_link_local_unicast(ip6_address_t *a)
icmp6_echo_request_next_t
u8 input_next_index_by_type[256]
uword unformat_pg_edit(unformat_input_t *input, va_list *args)
always_inline void * ip6_next_header(ip6_header_t *i)
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u8 min_valid_hop_limit_by_type[256]
vlib_node_registration_t ip6_icmp_error_node
(constructor) VLIB_REGISTER_NODE (ip6_icmp_error_node)
always_inline void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
vlib_node_registration_t ip6_icmp_echo_request_node
(constructor) VLIB_REGISTER_NODE (ip6_icmp_echo_request_node)
always_inline void pg_icmp_header_init(pg_icmp46_header_t *p)
unformat_function_t * unformat_pg_edit
always_inline pg_edit_group_t * pg_stream_get_group(pg_stream_t *s, u32 group_index)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define VLIB_INIT_FUNCTION(x)
u32 local_interface_sw_if_index
uword unformat_pg_payload(unformat_input_t *input, va_list *args)
static clib_error_t * icmp6_init(vlib_main_t *vm)
struct ip6_main_t::@108 host_config
#define vlib_call_init_function(vm, x)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
#define hash_create_string(elts, value_bytes)
#define VLIB_BUFFER_NEXT_PRESENT
void icmp6_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
always_inline u16 ip_csum_fold(ip_csum_t c)
static uword ip6_icmp_echo_request(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static uword unformat_icmp_type_and_code(unformat_input_t *input, va_list *args)
#define pool_elt_at_index(p, i)
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
u16 current_length
Nbytes between current data and the end of this buffer.
format_function_t * format_header
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
always_inline void vlib_buffer_reset(vlib_buffer_t *b)
Reset current header & length to state they were in when packet was received.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
u8 min_valid_length_by_type[256]
static uword ip6_icmp_error(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
vlib_node_registration_t ip6_icmp_input_node
(constructor) VLIB_REGISTER_NODE (ip6_icmp_input_node)
always_inline void * pg_create_edit_group(pg_stream_t *s, int n_edit_bytes, int n_packet_bytes, u32 *group_index)
clib_error_t * ip_main_init(vlib_main_t *vm)
static uword unformat_pg_icmp_header(unformat_input_t *input, va_list *args)
u8 * format_icmp6_input_trace(u8 *s, va_list *va)
#define clib_memcpy(a, b, c)
u8 max_valid_code_by_type[256]
static void icmp6_pg_edit_function(pg_main_t *pg, pg_stream_t *s, pg_edit_group_t *g, u32 *packets, u32 n_packets)
u32 * if_address_pool_index_by_sw_if_index
u16 ip6_tcp_udp_icmp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip6_header_t *ip0, int *bogus_lengthp)
ip_lookup_main_t lookup_main
u32 next_buffer
Next buffer for this linked-list of buffers.
static u8 icmp6_icmp_type_to_error(u8 type)
#define VLIB_NODE_FLAG_TRACE
uword edit_function_opaque
always_inline uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
#define vec_elt(v, i)
Get vector value at index i.
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
void vlib_trace_frame_buffers_only(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, uword n_buffers, uword next_buffer_stride, uword n_buffer_data_bytes_in_trace)
void icmp6_register_type(vlib_main_t *vm, icmp6_type_t type, u32 node_index)
void(* edit_function)(struct pg_main_t *pg, struct pg_stream_t *s, struct pg_edit_group_t *g, u32 *buffers, u32 n_buffers)
always_inline void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define ip_csum_update(sum, old, new, type, field)
uword unformat_pg_number(unformat_input_t *input, va_list *args)
#define VLIB_REGISTER_NODE(x,...)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
always_inline void pg_free_edit_group(pg_stream_t *s)
u32 * fib_index_by_sw_if_index
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.