26 #define foreach_udp_input_next \ 27 _ (PUNT, "error-punt") \ 28 _ (DROP, "error-drop") \ 29 _ (ICMP4_ERROR, "ip4-icmp-error") \ 30 _ (ICMP6_ERROR, "ip6-icmp-error") 33 #define _(s,n) UDP_INPUT_NEXT_##s, 51 s =
format (s,
"UDP: src-port %d dst-port %d%s",
54 t->
bound ?
"" :
" (no listener)");
76 __attribute__((unused))
u32 n_left_from, next_index, * from, * to_next;
77 word n_no_listener = 0;
84 while (n_left_from > 0)
89 to_next, n_left_to_next);
91 while (n_left_from >= 4 && n_left_to_next >= 2)
96 u32 i0, i1, dst_port0, dst_port1;
97 u32 advance0, advance1;
98 u32 error0, next0, error1, next1;
140 error0 = UDP_ERROR_LENGTH_ERROR;
141 next0 = UDP_INPUT_NEXT_DROP;
151 error0 = UDP_ERROR_LENGTH_ERROR;
152 next0 = UDP_INPUT_NEXT_DROP;
158 error1 = UDP_ERROR_LENGTH_ERROR;
159 next1 = UDP_INPUT_NEXT_DROP;
169 error1 = UDP_ERROR_LENGTH_ERROR;
170 next1 = UDP_INPUT_NEXT_DROP;
175 dst_port0 = (error0 == 0) ? h0->
dst_port : 0;
176 dst_port1 = (error1 == 0) ? h1->dst_port : 0;
191 ICMP4_destination_unreachable_port_unreachable, 0);
192 next0 = UDP_INPUT_NEXT_ICMP4_ERROR;
197 ICMP6_destination_unreachable_port_unreachable, 0);
198 next0 = UDP_INPUT_NEXT_ICMP6_ERROR;
218 ICMP4_destination_unreachable_port_unreachable, 0);
219 next1 = UDP_INPUT_NEXT_ICMP4_ERROR;
224 ICMP6_destination_unreachable_port_unreachable, 0);
225 next1 = UDP_INPUT_NEXT_ICMP6_ERROR;
240 if (b0->
error != node->
errors[UDP_ERROR_LENGTH_ERROR])
244 tr->
bound = (next0 != UDP_INPUT_NEXT_ICMP4_ERROR &&
245 next0 != UDP_INPUT_NEXT_ICMP6_ERROR);
252 if (b1->
error != node->
errors[UDP_ERROR_LENGTH_ERROR])
254 tr->
src_port = h1 ? h1->src_port : 0;
255 tr->
dst_port = h1 ? h1->dst_port : 0;
256 tr->
bound = (next1 != UDP_INPUT_NEXT_ICMP4_ERROR &&
257 next1 != UDP_INPUT_NEXT_ICMP6_ERROR);
262 to_next, n_left_to_next,
263 bi0, bi1, next0, next1);
266 while (n_left_from > 0 && n_left_to_next > 0)
292 next0 = UDP_INPUT_NEXT_DROP;
315 ICMP4_destination_unreachable_port_unreachable, 0);
316 next0 = UDP_INPUT_NEXT_ICMP4_ERROR;
321 ICMP6_destination_unreachable_port_unreachable, 0);
322 next0 = UDP_INPUT_NEXT_ICMP6_ERROR;
336 next0 = UDP_INPUT_NEXT_DROP;
344 if (b0->
error != node->
errors[UDP_ERROR_LENGTH_ERROR])
348 tr->
bound = (next0 != UDP_INPUT_NEXT_ICMP4_ERROR &&
349 next0 != UDP_INPUT_NEXT_ICMP6_ERROR);
354 to_next, n_left_to_next,
365 #define udp_error(n,s) s, 389 .name =
"ip4-udp-lookup",
391 .vector_size =
sizeof (
u32),
395 .n_errors = UDP_N_ERROR,
400 #define _(s,n) [UDP_INPUT_NEXT_##s] = n, 414 .name =
"ip6-udp-lookup",
416 .vector_size =
sizeof (
u32),
420 .n_errors = UDP_N_ERROR,
425 #define _(s,n) [UDP_INPUT_NEXT_##s] = n, 439 char * dst_port_name,
u8 is_ip4)
444 vec_add2 (um->dst_port_infos[is_ip4], pi, 1);
445 i = pi - um->dst_port_infos[is_ip4];
447 pi->
name = dst_port_name;
451 hash_set (um->dst_port_info_by_dst_port[is_ip4], dst_port,
i);
460 u32 node_index,
u8 is_ip4)
491 clib_host_to_net_u16 (dst_port));
498 u8 ** result = va_arg (*args,
u8 **);
500 __attribute__((unused))
int old_length;
501 u16 src_port, dst_port;
507 old_length =
vec_len (*result);
512 memset (udp, 0,
sizeof (udp[0]));
513 if (
unformat (input,
"src-port %d dst-port %d",
514 &src_port, &dst_port))
516 udp->
src_port = clib_host_to_net_u16 (src_port);
517 udp->
dst_port = clib_host_to_net_u16 (dst_port);
548 for (i = 0; i < 2; i++)
563 #define _(n,s) add_dst_port (um, UDP_DST_PORT_##s, #s, 1 ); 570 (
sizeof (rt->next_by_dst_port[0]),
573 #define _(n,s) add_dst_port (um, UDP_DST_PORT_##s, #s, 0 ); 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.
#define hash_set(h, key, value)
sll srl srl sll sra u16x4 i
clib_error_t * udp_local_init(vlib_main_t *vm)
static char * udp_error_strings[]
uword * dst_port_info_by_dst_port[N_UDP_AF]
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
clib_error_t * udp_init(vlib_main_t *vm)
struct _vlib_node_registration vlib_node_registration_t
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
#define hash_set_mem(h, key, value)
static udp_dst_port_info_t * udp_get_dst_port_info(udp_main_t *um, udp_dst_port_t dst_port, u8 is_ip4)
#define clib_error_report(e)
void ip4_register_protocol(u32 protocol, u32 node_index)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static void add_dst_port(udp_main_t *um, udp_dst_port_t dst_port, char *dst_port_name, u8 is_ip4)
static pg_node_t * pg_get_node(uword node_index)
#define VLIB_INIT_FUNCTION(x)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define sparse_vec_validate(v, i)
static void sparse_vec_index2(void *v, u32 si0, u32 si1, u32 *i0_return, u32 *i1_return)
#define vlib_call_init_function(vm, x)
#define hash_create_string(elts, value_bytes)
void icmp6_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
u16 current_length
Nbytes between current data and the end of this buffer.
uword * dst_port_info_by_name[N_UDP_AF]
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
format_function_t * format_buffer
#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).
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void udp_setup_node(vlib_main_t *vm, u32 node_index)
#define CLIB_PREFETCH(addr, size, type)
vlib_node_registration_t udp4_input_node
(constructor) VLIB_REGISTER_NODE (udp4_input_node)
void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
unformat_function_t * unformat_buffer
unformat_function_t * unformat_edit
static uword udp46_input_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip4)
vlib_node_registration_t udp6_input_node
(constructor) VLIB_REGISTER_NODE (udp6_input_node)
#define hash_create(elts, value_bytes)
static uword sparse_vec_index(void *v, uword sparse_index)
#define foreach_udp4_dst_port
#define foreach_udp_input_next
static uword udp6_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
#define VLIB_BUFFER_IS_TRACED
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vec_elt(v, i)
Get vector value at index i.
static uword udp4_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
uword unformat_udp_header(unformat_input_t *input, va_list *args)
u8 * format_udp_rx_trace(u8 *s, va_list *args)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
#define VLIB_REGISTER_NODE(x,...)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
static void * sparse_vec_new(uword elt_bytes, uword sparse_index_bits)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define SPARSE_VEC_INVALID_INDEX