/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Copyright (c) 2016-2019 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
#include <vnet/dpo/load_balance.h>
#include <vnet/fib/ip4_fib.h>
+udp_main_t udp_main;
+
udp_connection_t *
udp_connection_alloc (u32 thread_index)
{
listener->c_proto = TRANSPORT_PROTO_UDP;
listener->c_s_index = session_index;
listener->c_fib_index = lcl->fib_index;
+ listener->owns_port = 1;
clib_spinlock_init (&listener->rx_lock);
node_index = lcl->is_ip4 ? udp4_input_node.index : udp6_input_node.index;
uc = udp_connection_get (connection_index, thread_index);
if (uc)
{
- udp_unregister_dst_port (vm, clib_net_to_host_u16 (uc->c_lcl_port),
- uc->c_is_ip4);
+ if (uc->owns_port || !uc->is_connected)
+ udp_unregister_dst_port (vm, clib_net_to_host_u16 (uc->c_lcl_port),
+ uc->c_is_ip4);
session_transport_delete_notify (&uc->connection);
udp_connection_free (uc);
}
uc->c_is_ip4 = rmt->is_ip4;
uc->c_proto = TRANSPORT_PROTO_UDP;
uc->c_fib_index = rmt->fib_index;
+ uc->owns_port = 1;
return uc->c_c_index;
}
/* *INDENT-OFF* */
const static transport_proto_vft_t udp_proto = {
- .bind = udp_session_bind,
- .open = udp_open_connection,
- .unbind = udp_session_unbind,
+ .start_listen = udp_session_bind,
+ .connect = udp_open_connection,
+ .stop_listen = udp_session_unbind,
.push_header = udp_push_header,
.get_connection = udp_session_get,
.get_listener = udp_session_get_listener,
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);
- uc = udp_connection_get (uc_index, vlib_get_thread_index ());
+ uc = udp_connection_get (uc_index, thread_index);
uc->is_connected = 1;
return uc_index;
}
/* *INDENT-OFF* */
const static transport_proto_vft_t udpc_proto = {
- .bind = udpc_connection_listen,
- .open = udpc_connection_open,
- .unbind = udp_session_unbind,
+ .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,
.format_connection = format_udp_session,
.format_half_open = format_udp_half_open_session,
.format_listener = format_udp_listener_session,
- .tx_type = TRANSPORT_TX_DEQUEUE,
+ .tx_type = TRANSPORT_TX_DGRAM,
.service_type = TRANSPORT_SERVICE_CL,
};
/* *INDENT-ON* */