|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
55 u8 code = va_arg (*args,
int);
58 #define _(n,f) case n: t = #f; break;
76 switch ((
type << 8) | code)
78 #define _(a,n,f) case (ICMP4_##a << 8) | (n): t = #f; break;
94 icmp46_header_t *
icmp = va_arg (*args, icmp46_header_t *);
95 u32 max_header_bytes = va_arg (*args,
u32);
98 if (max_header_bytes <
sizeof (
icmp[0]))
99 return format (s,
"ICMP header truncated");
101 s =
format (s,
"ICMP %U checksum 0x%x",
103 clib_net_to_host_u16 (
icmp->checksum));
105 if ((ICMP4_echo_request ==
icmp->type || ICMP4_echo_reply ==
icmp->type)
106 && sizeof (
icmp[0]) +
sizeof (
u16) < max_header_bytes)
108 s =
format (s,
" id %u", clib_net_to_host_u16 (*(
u16 *) (
icmp + 1)));
140 u8 ip4_input_next_index_by_type[256];
171 icmp46_header_t *icmp0;
183 bi0 = to_next[0] =
from[0];
194 next0 =
im->ip4_input_next_index_by_type[type0];
196 p0->
error =
node->errors[ICMP4_ERROR_UNKNOWN_TYPE];
200 n_left_to_next, bi0, next0);
206 return frame->n_vectors;
212 .name =
"ip4-icmp-input",
214 .vector_size =
sizeof (
u32),
240 case ICMP4_destination_unreachable:
241 return ICMP4_ERROR_DEST_UNREACH_SENT;
242 case ICMP4_time_exceeded:
243 return ICMP4_ERROR_TTL_EXPIRE_SENT;
244 case ICMP4_parameter_problem:
245 return ICMP4_ERROR_PARAM_PROBLEM_SENT;
247 return ICMP4_ERROR_DROP;
284 u8 error0 = ICMP4_ERROR_NONE;
287 icmp46_header_t *icmp0;
293 if (!p0 || pi0 == ~0)
309 sizeof (icmp46_header_t) - 4);
314 icmp0 = (icmp46_header_t *) & out_ip0[1];
323 out_ip0->
protocol = IP_PROTOCOL_ICMP;
330 error0 = ICMP4_ERROR_DROP;
338 *((
u32 *) (icmp0 + 1)) =
339 clib_host_to_net_u32 (
vnet_buffer (p0)->ip.icmp.data);
348 if (error0 == ICMP4_ERROR_NONE)
355 to_next, n_left_to_next,
370 return frame->n_vectors;
376 .name =
"ip4-icmp-error",
377 .vector_size =
sizeof (
u32),
396 icmp46_header_t *
h = va_arg (*args, icmp46_header_t *);
401 cm->type_and_code_by_name, &
i))
403 h->type = (
i >> 8) & 0xff;
404 h->code = (
i >> 0) & 0xff;
407 cm->type_by_name, &
i))
424 u32 ip_offset, icmp_offset;
427 ip_offset = (g - 1)->start_byte_offset;
429 while (n_packets >= 1)
433 icmp46_header_t *icmp0;
441 ip0 = (
void *) (p0->
data + ip_offset);
442 icmp0 = (
void *) (p0->
data + icmp_offset);
448 len0 = clib_net_to_host_u16 (ip0->
length) - icmp_offset;
465 #define _(f) pg_edit_init (&p->f, icmp46_header_t, f);
532 old_next_index =
im->ip4_input_next_index_by_type[
type];
534 im->ip4_input_next_index_by_type[
type]
537 if (old_next_index &&
538 (old_next_index !=
im->ip4_input_next_index_by_type[
type]))
560 #define _(n,t) hash_set_mem (cm->type_by_name, #t, (n));
565 #define _(a,n,t) hash_set_mem (cm->type_by_name, #t, (n) | (ICMP4_##a << 8));
571 sizeof (
cm->ip4_input_next_index_by_type));
static u8 * format_icmp_input_trace(u8 *s, va_list *va)
vnet_interface_main_t * im
static void pg_edit_set_fixed(pg_edit_t *e, u64 value)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
nat44_ei_hairpin_src_next_t next_index
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
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)
vlib_main_t vlib_node_runtime_t * node
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
#define hash_create_string(elts, value_bytes)
format_function_t * format_header
#define vlib_call_init_function(vm, x)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static u8 * format_ip4_icmp_header(u8 *s, va_list *args)
uword unformat_pg_number(unformat_input_t *input, va_list *args)
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
void ip4_icmp_register_type(vlib_main_t *vm, icmp4_type_t type, u32 node_index)
static void icmp4_pg_edit_function(pg_main_t *pg, pg_stream_t *s, pg_edit_group_t *g, u32 *packets, u32 n_packets)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
bool ip4_sas_by_sw_if_index(u32 sw_if_index, const ip4_address_t *dst, ip4_address_t *src)
static_always_inline void vlib_buffer_enqueue_to_single_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 next_index, u32 count)
uword edit_function_opaque
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
vlib_error_t error
Error code for buffers to be enqueued to error handler.
@ IP4_ICMP_ERROR_NEXT_LOOKUP
#define VLIB_NODE_FLAG_TRACE
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define vlib_prefetch_buffer_with_index(vm, bi, type)
Prefetch buffer metadata by buffer index The first 64 bytes of buffer contains most header informatio...
static u8 icmp4_icmp_type_to_error(u8 type)
vnet_feature_config_main_t * cm
static pg_edit_group_t * pg_stream_get_group(pg_stream_t *s, u32 group_index)
static void pg_free_edit_group(pg_stream_t *s)
clib_error_t * ip_main_init(vlib_main_t *vm)
static vlib_buffer_t * vlib_buffer_copy_no_chain(vlib_main_t *vm, vlib_buffer_t *b, u32 *di)
struct _vlib_node_registration vlib_node_registration_t
uword unformat_pg_edit(unformat_input_t *input, va_list *args)
u16 current_length
Nbytes between current data and the end of this buffer.
uword unformat_pg_payload(unformat_input_t *input, va_list *args)
#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.
static clib_error_t * icmp4_init(vlib_main_t *vm)
description fragment has unexpected format
static void * pg_create_edit_group(pg_stream_t *s, int n_edit_bytes, int n_packet_bytes, u32 *group_index)
vlib_put_next_frame(vm, node, next_index, 0)
#define VLIB_INIT_FUNCTION(x)
static u8 * format_ip4_icmp_type_and_code(u8 *s, va_list *args)
static_always_inline void clib_prefetch_load(void *p)
uword * type_and_code_by_name
static void pg_icmp_header_init(pg_icmp46_header_t *p)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static uword ip4_icmp_error(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
vlib_node_registration_t ip4_icmp_input_node
(constructor) VLIB_REGISTER_NODE (ip4_icmp_input_node)
static vlib_main_t * vlib_get_main(void)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static u16 ip4_header_checksum(ip4_header_t *i)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
static uword unformat_pg_icmp_header(unformat_input_t *input, va_list *args)
#define clib_warning(format, args...)
static uword ip4_icmp_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
void(* edit_function)(struct pg_main_t *pg, struct pg_stream_t *s, struct pg_edit_group_t *g, u32 *buffers, u32 n_buffers)
static char * icmp_error_strings[]
static uword unformat_icmp_type_and_code(unformat_input_t *input, va_list *args)
#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 u16 ip_csum_fold(ip_csum_t c)
unformat_function_t * unformat_pg_edit
@ IP4_ICMP_ERROR_NEXT_DROP
vl_api_fib_path_type_t type
static void * ip4_next_header(ip4_header_t *i)
VLIB buffer representation.
vlib_node_registration_t ip4_icmp_error_node
(constructor) VLIB_REGISTER_NODE (ip4_icmp_error_node)
#define VLIB_REGISTER_NODE(x,...)