51 clib_host_to_net_u16 (lcl_port));
54 clib_host_to_net_u16 (lcl_port));
115 uc->c_c_index = uc - um->
connections[thread_index];
116 uc->c_thread_index = thread_index;
117 uc->c_proto = TRANSPORT_PROTO_UDP;
125 u32 thread_index = uc->c_thread_index;
176 lcl_port_ho = clib_net_to_host_u16 (lcl->port);
181 return SESSION_E_PORTINUSE;
187 listener->c_lcl_port = lcl->port;
195 ip_set (&lcl->ip, iface_ip, lcl->is_ip4);
197 ip_copy (&listener->c_lcl_ip, &lcl->ip, lcl->is_ip4);
198 listener->c_is_ip4 = lcl->is_ip4;
199 listener->c_proto = TRANSPORT_PROTO_UDP;
200 listener->c_s_index = session_index;
201 listener->c_fib_index = lcl->fib_index;
203 listener->
flags |= UDP_CONN_F_OWNS_PORT | UDP_CONN_F_LISTEN;
206 listener->
flags |= UDP_CONN_F_CONNECTED;
212 return listener->c_c_index;
255 b->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
288 uc->
flags |= UDP_CONN_F_CLOSING;
298 if (uc->
flags & UDP_CONN_F_MIGRATED)
327 ip46_address_t lcl_addr;
336 if (rv != SESSION_E_PORTINUSE)
340 return SESSION_E_PORTINUSE;
344 lcl_port, rmt->port, TRANSPORT_PROTO_UDP,
346 return SESSION_E_PORTINUSE;
359 return SESSION_E_PORTINUSE;
367 return SESSION_E_PORTINUSE;
380 ip_copy (&uc->c_rmt_ip, &rmt->ip, rmt->is_ip4);
381 ip_copy (&uc->c_lcl_ip, &lcl_addr, rmt->is_ip4);
382 uc->c_rmt_port = rmt->port;
383 uc->c_lcl_port = clib_host_to_net_u16 (lcl_port);
384 uc->c_is_ip4 = rmt->is_ip4;
385 uc->c_proto = TRANSPORT_PROTO_UDP;
386 uc->c_fib_index = rmt->fib_index;
388 uc->
flags |= UDP_CONN_F_OWNS_PORT;
390 uc->
flags |= UDP_CONN_F_CONNECTED;
394 return uc->c_c_index;
414 u32 uci = va_arg (*args,
u32);
415 u32 thread_index = va_arg (*args,
u32);
416 u32 verbose = va_arg (*args,
u32);
426 u32 __clib_unused tci = va_arg (*args,
u32);
427 u32 __clib_unused thread_index = va_arg (*args,
u32);
435 u32 tci = va_arg (*args,
u32);
436 u32 __clib_unused thread_index = va_arg (*args,
u32);
437 u32 verbose = va_arg (*args,
u32);
457 .transport_options = {
504 for (i = 0; i < num_threads; i++)
522 .runs_after =
VLIB_INITS(
"ip_main_init",
"ip4_lookup_init",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void udp_connection_cleanup(udp_connection_t *uc)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static udp_connection_t * udp_connection_from_transport(transport_connection_t *tc)
#define ENDPOINT_INVALID_INDEX
static udp_connection_t * udp_listener_get(u32 conn_index)
void ip_copy(ip46_address_t *dst, ip46_address_t *src, u8 is_ip4)
void udp_connection_share_port(u16 lcl_port, u8 is_ip4)
static void udp_session_close(u32 connection_index, u32 thread_index)
void transport_share_local_endpoint(u8 proto, ip46_address_t *lcl_ip, u16 port)
void * ip_interface_get_first_ip(u32 sw_if_index, u8 is_ip4)
void ip_set(ip46_address_t *dst, void *src, u8 is_ip4)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
static clib_error_t * udp_init(vlib_main_t *vm)
static u32 udp_push_header(transport_connection_t *tc, vlib_buffer_t *b)
static void udp_connection_unregister_port(u16 lcl_port, u8 is_ip4)
static u32 udp_session_bind(u32 session_index, transport_endpoint_t *lcl)
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
#define pool_get_aligned_will_expand(P, YESNO, A)
See if pool_get will expand the pool or not.
static void * vlib_buffer_push_ip4_custom(vlib_main_t *vm, vlib_buffer_t *b, ip4_address_t *src, ip4_address_t *dst, int proto, u8 csum_offload, u8 is_df)
static udp_dst_port_info_t * udp_get_dst_port_info(udp_main_t *um, udp_dst_port_t dst_port, u8 is_ip4)
static u8 * format_udp_session(u8 *s, va_list *args)
vlib_node_registration_t udp4_local_node
(constructor) VLIB_REGISTER_NODE (udp4_local_node)
static void * vlib_buffer_push_udp(vlib_buffer_t *b, u16 sp, u16 dp, u8 offload_csum)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static udp_main_t * vnet_get_udp_main()
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
unformat_function_t * unformat_pg_edit
void udp_connection_free(udp_connection_t *uc)
Connection is "connection less".
#define VLIB_INIT_FUNCTION(x)
#define sparse_vec_validate(v, i)
void udp_add_dst_port(udp_main_t *um, udp_dst_port_t dst_port, char *dst_port_name, u8 is_ip4)
#define clib_error_return(e, args...)
int transport_alloc_local_endpoint(u8 proto, transport_endpoint_cfg_t *rmt_cfg, ip46_address_t *lcl_addr, u16 *lcl_port)
static transport_connection_t * udp_session_get(u32 connection_index, u32 thread_index)
struct _transport_proto_vft transport_proto_vft_t
static void clib_spinlock_init(clib_spinlock_t *p)
static transport_connection_t * udp_session_get_listener(u32 listener_index)
vlib_node_registration_t udp4_input_node
(constructor) VLIB_REGISTER_NODE (udp4_input_node)
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
format_function_t * format_header
format_function_t format_udp_connection
static u8 * format_udp_listener_session(u8 *s, va_list *args)
udp_connection_t * udp_connection_alloc(u32 thread_index)
clib_spinlock_t * peekers_readers_locks
#define pool_put(P, E)
Free an object E in pool P.
vlib_node_registration_t udp6_input_node
(constructor) VLIB_REGISTER_NODE (udp6_input_node)
static u8 udp_connection_port_used_extern(u16 lcl_port, u8 is_ip4)
udp_connection_t * listener_pool
#define clib_atomic_fetch_add_rel(a, b)
void udp_connection_delete(udp_connection_t *uc)
#define clib_atomic_sub_fetch(a, b)
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
static int udp_session_send_params(transport_connection_t *tconn, transport_send_params_t *sp)
sll srl srl sll sra u16x4 i
void udp_unregister_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u8 is_ip4)
#define clib_warning(format, args...)
static udp_connection_t * udp_connection_get(u32 conn_index, u32 thread_index)
static int udp_open_connection(transport_endpoint_cfg_t *rmt)
struct _transport_connection transport_connection_t
void transport_endpoint_cleanup(u8 proto, ip46_address_t *lcl_ip, u16 port)
void transport_register_protocol(transport_proto_t transport_proto, const transport_proto_vft_t *vft, fib_protocol_t fib_proto, u32 output_node)
Register transport virtual function table.
transport_snd_flags_t flags
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
vlib_node_registration_t ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (ip6_lookup_node)
static void udp_connection_register_port(vlib_main_t *vm, u16 lcl_port, u8 is_ip4)
static u8 * format_udp_half_open_session(u8 *s, va_list *args)
clib_spinlock_t * peekers_write_locks
static vlib_main_t * vlib_get_main(void)
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
u32 local_to_input_edge[N_UDP_AF]
static u16 udp_default_mtu(udp_main_t *um, u8 is_ip4)
static u32 udp_session_unbind(u32 listener_index)
static const transport_proto_vft_t udp_proto
static void * vlib_buffer_push_ip6(vlib_main_t *vm, vlib_buffer_t *b, ip6_address_t *src, ip6_address_t *dst, int proto)
Push IPv6 header to buffer.
transport_connection_t connection
must be first
clib_spinlock_t rx_lock
rx fifo lock
bool udp_is_valid_dst_port(udp_dst_port_t dst_port, u8 is_ip4)
VLIB buffer representation.
transport_connection_t * session_lookup_connection(u32 fib_index, ip46_address_t *lcl, ip46_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u8 is_ip4)
vlib_node_registration_t udp6_local_node
(constructor) VLIB_REGISTER_NODE (udp6_local_node)
static vlib_thread_main_t * vlib_get_thread_main()
static u32 vlib_num_workers()
int transport_alloc_local_port(u8 proto, ip46_address_t *ip)
Allocate local port and add if successful add entry to local endpoint table to mark the pair as used...
static transport_connection_t * udp_session_get_half_open(u32 conn_index)
#define CLIB_CACHE_LINE_BYTES
udp_connection_t ** connections
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
static void udp_session_cleanup(u32 connection_index, u32 thread_index)