#include <vnet/udp/udp.h>
#include <vnet/session/session.h>
#include <vnet/dpo/load_balance.h>
-#include <vnet/fib/ip4_fib.h>
+#include <vnet/ip/ip4_inlines.h>
+#include <vnet/ip/ip6_inlines.h>
#include <vppinfra/sparse_vec.h>
udp_main_t udp_main;
uc->c_c_index = uc - um->connections[thread_index];
uc->c_thread_index = thread_index;
uc->c_proto = TRANSPORT_PROTO_UDP;
- clib_spinlock_init (&uc->rx_lock);
return uc;
}
udp_connection_free (udp_connection_t * uc)
{
u32 thread_index = uc->c_thread_index;
+ clib_spinlock_free (&uc->rx_lock);
if (CLIB_DEBUG)
clib_memset (uc, 0xFA, sizeof (*uc));
pool_put (udp_main.connections[thread_index], uc);
listener = udp_listener_get (listener_index);
udp_connection_unregister_port (clib_net_to_host_u16 (listener->c_lcl_port),
listener->c_is_ip4);
+ clib_spinlock_free (&listener->rx_lock);
pool_put (um->listener_pool, listener);
return 0;
}
vlib_buffer_push_udp (b, uc->c_lcl_port, uc->c_rmt_port, 1);
if (tc->is_ip4)
vlib_buffer_push_ip4_custom (vm, b, &uc->c_lcl_ip4, &uc->c_rmt_ip4,
- IP_PROTOCOL_UDP, 1 /* csum offload */ ,
- 0 /* is_df */ );
+ IP_PROTOCOL_UDP, 1 /* csum offload */,
+ 0 /* is_df */, uc->c_dscp);
else
vlib_buffer_push_ip6 (vm, b, &uc->c_lcl_ip6, &uc->c_rmt_ip6,
IP_PROTOCOL_UDP);
udp_connection_register_port (vm, lcl_port, rmt->is_ip4);
/* We don't poll main thread if we have workers */
- if (vlib_num_workers ())
- thread_index = 1;
+ thread_index = transport_cl_thread ();
uc = udp_connection_alloc (thread_index);
ip_copy (&uc->c_rmt_ip, &rmt->ip, rmt->is_ip4);
uc->c_is_ip4 = rmt->is_ip4;
uc->c_proto = TRANSPORT_PROTO_UDP;
uc->c_fib_index = rmt->fib_index;
+ uc->c_dscp = rmt->dscp;
uc->mss = rmt->mss ? rmt->mss : udp_default_mtu (um, uc->c_is_ip4);
uc->flags |= UDP_CONN_F_OWNS_PORT;
if (rmt->transport_flags & TRANSPORT_CFG_F_CONNECTED)
- uc->flags |= UDP_CONN_F_CONNECTED;
+ {
+ uc->flags |= UDP_CONN_F_CONNECTED;
+ }
else
- uc->c_flags |= TRANSPORT_CONNECTION_F_CLESS;
+ {
+ clib_spinlock_init (&uc->rx_lock);
+ uc->c_flags |= TRANSPORT_CONNECTION_F_CLESS;
+ }
return uc->c_c_index;
}
u32 thread_index;
/* We don't poll main thread if we have workers */
- thread_index = vlib_num_workers ()? 1 : 0;
+ thread_index = transport_cl_thread ();
uc = udp_connection_get (conn_index, thread_index);
if (!uc)
return 0;
};
/* *INDENT-ON* */
-int
-udpc_connection_open (transport_endpoint_cfg_t * rmt)
-{
- udp_connection_t *uc;
- /* Reproduce the logic of udp_open_connection to find the correct thread */
- u32 thread_index = vlib_num_workers ()? 1 : vlib_get_main ()->thread_index;
- u32 uc_index;
- uc_index = udp_open_connection (rmt);
- if (uc_index == (u32) ~ 0)
- return -1;
- uc = udp_connection_get (uc_index, thread_index);
- uc->flags |= UDP_CONN_F_CONNECTED;
- return uc_index;
-}
-
-u32
-udpc_connection_listen (u32 session_index, transport_endpoint_t * lcl)
-{
- udp_connection_t *listener;
- u32 li_index;
- li_index = udp_session_bind (session_index, lcl);
- if (li_index == (u32) ~ 0)
- return -1;
- listener = udp_listener_get (li_index);
- listener->flags |= UDP_CONN_F_CONNECTED;
- /* Fake udp listener, i.e., make sure session layer adds a udp instead of
- * udpc listener to the lookup table */
- ((session_endpoint_cfg_t *) lcl)->transport_proto = TRANSPORT_PROTO_UDP;
- return li_index;
-}
-
-/* *INDENT-OFF* */
-static const transport_proto_vft_t udpc_proto = {
- .start_listen = udpc_connection_listen,
- .stop_listen = udp_session_unbind,
- .connect = udpc_connection_open,
- .push_header = udp_push_header,
- .get_connection = udp_session_get,
- .get_listener = udp_session_get_listener,
- .get_half_open = udp_session_get_half_open,
- .close = udp_session_close,
- .cleanup = udp_session_cleanup,
- .send_params = udp_session_send_params,
- .format_connection = format_udp_session,
- .format_half_open = format_udp_half_open_session,
- .format_listener = format_udp_listener_session,
- .transport_options = {
- .name = "udpc",
- .short_name = "U",
- .tx_type = TRANSPORT_TX_DGRAM,
- .service_type = TRANSPORT_SERVICE_VC,
- .half_open_has_fifos = 1
- },
-};
-/* *INDENT-ON* */
-
static clib_error_t *
udp_init (vlib_main_t * vm)
{
FIB_PROTOCOL_IP4, ip4_lookup_node.index);
transport_register_protocol (TRANSPORT_PROTO_UDP, &udp_proto,
FIB_PROTOCOL_IP6, ip6_lookup_node.index);
- transport_register_protocol (TRANSPORT_PROTO_UDPC, &udpc_proto,
- FIB_PROTOCOL_IP4, ip4_lookup_node.index);
- transport_register_protocol (TRANSPORT_PROTO_UDPC, &udpc_proto,
- FIB_PROTOCOL_IP6, ip6_lookup_node.index);
/*
* Initialize data structures