39 #define UDP_NO_NODE_SET ((u16) ~0) 41 #ifndef CLIB_MARCH_VARIANT 49 s =
format (s,
"UDP: src-port %d dst-port %d%s",
52 t->
bound ?
"" :
" (no listener)");
63 __attribute__ ((unused))
u32 n_left_from, next_index, *from, *to_next;
64 word n_no_listener = 0;
66 u16 *next_by_dst_port = (is_ip4 ?
73 while (n_left_from > 0)
79 while (n_left_from >= 4 && n_left_to_next >= 2)
84 u32 i0, i1, dst_port0, dst_port1;
85 u32 advance0, advance1;
86 u32 error0, next0, error1, next1;
128 error0 = UDP_ERROR_LENGTH_ERROR;
135 error0 = UDP_ERROR_NONE;
140 error0 = UDP_ERROR_LENGTH_ERROR;
147 error1 = UDP_ERROR_LENGTH_ERROR;
154 error1 = UDP_ERROR_NONE;
159 error1 = UDP_ERROR_LENGTH_ERROR;
165 dst_port0 = (error0 == 0) ? h0->
dst_port : 0;
166 dst_port1 = (error1 == 0) ? h1->dst_port : 0;
169 next0 = (error0 == 0) ?
vec_elt (next_by_dst_port, i0) : next0;
170 next1 = (error1 == 0) ?
vec_elt (next_by_dst_port, i1) : next1;
187 ICMP4_destination_unreachable,
188 ICMP4_destination_unreachable_port_unreachable,
196 ICMP6_destination_unreachable,
197 ICMP6_destination_unreachable_port_unreachable,
225 ICMP4_destination_unreachable,
226 ICMP4_destination_unreachable_port_unreachable,
234 ICMP6_destination_unreachable,
235 ICMP6_destination_unreachable_port_unreachable,
252 if (b0->
error != node->
errors[UDP_ERROR_LENGTH_ERROR])
263 if (b1->
error != node->
errors[UDP_ERROR_LENGTH_ERROR])
265 tr->
src_port = h1 ? h1->src_port : 0;
266 tr->
dst_port = h1 ? h1->dst_port : 0;
272 to_next, n_left_to_next,
273 bi0, bi1, next0, next1);
276 while (n_left_from > 0 && n_left_to_next > 0)
314 next0 =
vec_elt (next_by_dst_port, i0);
331 ICMP4_destination_unreachable,
332 ICMP4_destination_unreachable_port_unreachable,
340 ICMP6_destination_unreachable,
341 ICMP6_destination_unreachable_port_unreachable,
365 if (b0->
error != node->
errors[UDP_ERROR_LENGTH_ERROR])
374 to_next, n_left_to_next,
386 #define udp_error(n,s) s, 407 .name =
"ip4-udp-lookup",
409 .vector_size =
sizeof (
u32),
429 .name =
"ip6-udp-lookup",
431 .vector_size =
sizeof (
u32),
449 #ifndef CLIB_MARCH_VARIANT 460 pi->
name = dst_port_name;
500 clib_host_to_net_u16 (dst_port));
503 clib_host_to_net_u16 (dst_port));
523 clib_host_to_net_u16 (dst_port));
526 clib_host_to_net_u16 (dst_port));
539 clib_host_to_net_u16 (dst_port));
542 clib_host_to_net_u16 (dst_port));
567 u8 **result = va_arg (*args,
u8 **);
569 __attribute__ ((unused))
int old_length;
576 old_length =
vec_len (*result);
582 if (
unformat (input,
"src-port %d dst-port %d", &src_port, &dst_port))
584 udp->
src_port = clib_host_to_net_u16 (src_port);
585 udp->
dst_port = clib_host_to_net_u16 (dst_port);
616 for (i = 0; i < 2; i++)
636 #define _(n,s) add_dst_port (um, UDP_DST_PORT_##s, #s, 1 ); 639 #define _(n,s) add_dst_port (um, UDP_DST_PORT_##s, #s, 0 ); void udp_unregister_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u8 is_ip4)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
bool udp_is_valid_dst_port(udp_dst_port_t dst_port, u8 is_ip4)
#define hash_set(h, key, value)
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_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static clib_error_t * udp_init(vlib_main_t *vm)
u16 current_length
Nbytes between current data and the end of this buffer.
#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 VLIB_NODE_FN(node)
void ip4_register_protocol(u32 protocol, u32 node_index)
vlib_error_t * errors
Vector of errors for this node.
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)
vlib_node_registration_t udp6_local_node
(constructor) VLIB_REGISTER_NODE (udp6_local_node)
#define sparse_vec_validate(v, i)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
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)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
udp_dst_port_info_t * dst_port_infos[N_UDP_AF]
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static uword udp46_local_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip4)
uword * dst_port_info_by_name[N_UDP_AF]
format_function_t * format_buffer
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).
static void udp_setup_node(vlib_main_t *vm, u32 node_index)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
unformat_function_t * unformat_buffer
unformat_function_t * unformat_edit
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 udp_punt_unknown(vlib_main_t *vm, u8 is_ip4, u8 is_add)
vlib_main_t vlib_node_runtime_t * node
vlib_node_registration_t udp4_local_node
(constructor) VLIB_REGISTER_NODE (udp4_local_node)
#define hash_create(elts, value_bytes)
static uword sparse_vec_index(void *v, uword sparse_index)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define foreach_udp4_dst_port
#define clib_error_report(e)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
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.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
VLIB buffer representation.
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)
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)
static_always_inline void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
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