diff options
author | Florin Coras <fcoras@cisco.com> | 2022-12-19 10:55:18 -0800 |
---|---|---|
committer | Dave Barach <vpp@barachs.net> | 2022-12-20 21:45:03 +0000 |
commit | 15952b261f92959ca14cf6679efc318c12e90de6 (patch) | |
tree | 3dfef937ffc510d5d0b8c3af15bcb1b2ce718d64 /src/vnet/udp/udp_output.c | |
parent | 8753180a80e03dd031fa7f470adbcbb4a611d1c9 (diff) |
udp: fix tx handling of non-connected sessions
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I659b9914fcfa4619a68e9807ef241f88c96b3bd0
Diffstat (limited to 'src/vnet/udp/udp_output.c')
-rw-r--r-- | src/vnet/udp/udp_output.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/src/vnet/udp/udp_output.c b/src/vnet/udp/udp_output.c index 3ab21d32270..bcebf5a790b 100644 --- a/src/vnet/udp/udp_output.c +++ b/src/vnet/udp/udp_output.c @@ -76,21 +76,6 @@ udp46_output_trace_frame (vlib_main_t *vm, vlib_node_runtime_t *node, } always_inline void -udp_output_push_ip (vlib_main_t *vm, vlib_buffer_t *b, udp_connection_t *uc, - u8 is_ip4) -{ - if (uc->c_is_ip4) - vlib_buffer_push_ip4_custom (vm, b, &uc->c_lcl_ip4, &uc->c_rmt_ip4, - IP_PROTOCOL_UDP, udp_csum_offload (uc), - 0 /* is_df */, uc->c_dscp); - else - vlib_buffer_push_ip6 (vm, b, &uc->c_lcl_ip6, &uc->c_rmt_ip6, - IP_PROTOCOL_UDP); - vnet_buffer (b)->sw_if_index[VLIB_RX] = uc->sw_if_index; - vnet_buffer (b)->sw_if_index[VLIB_TX] = uc->c_fib_index; -} - -always_inline void udp_output_handle_packet (udp_connection_t *uc0, vlib_buffer_t *b0, vlib_node_runtime_t *error_node, u16 *next0, u8 is_ip4) @@ -110,6 +95,16 @@ udp_output_handle_packet (udp_connection_t *uc0, vlib_buffer_t *b0, vnet_buffer (b0)->sw_if_index[VLIB_RX] = uc0->sw_if_index; } +always_inline udp_connection_t * +udp_output_get_connection (vlib_buffer_t *b, u32 thread_index) +{ + if (PREDICT_FALSE (vnet_buffer (b)->tcp.flags & UDP_CONN_F_LISTEN)) + return udp_listener_get (vnet_buffer (b)->tcp.connection_index); + + return udp_connection_get (vnet_buffer (b)->tcp.connection_index, + thread_index); +} + always_inline uword udp46_output_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_ip4) @@ -138,16 +133,11 @@ udp46_output_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_prefetch_buffer_header (b[3], STORE); CLIB_PREFETCH (b[3]->data, 2 * CLIB_CACHE_LINE_BYTES, STORE); - uc0 = udp_connection_get (vnet_buffer (b[0])->tcp.connection_index, - thread_index); - uc1 = udp_connection_get (vnet_buffer (b[1])->tcp.connection_index, - thread_index); + uc0 = udp_output_get_connection (b[0], thread_index); + uc1 = udp_output_get_connection (b[1], thread_index); if (PREDICT_TRUE (!uc0 + !uc1 == 0)) { - udp_output_push_ip (vm, b[0], uc0, is_ip4); - udp_output_push_ip (vm, b[1], uc1, is_ip4); - udp_output_handle_packet (uc0, b[0], node, &next[0], is_ip4); udp_output_handle_packet (uc1, b[1], node, &next[1], is_ip4); } @@ -155,7 +145,6 @@ udp46_output_inline (vlib_main_t *vm, vlib_node_runtime_t *node, { if (uc0 != 0) { - udp_output_push_ip (vm, b[0], uc0, is_ip4); udp_output_handle_packet (uc0, b[0], node, &next[0], is_ip4); } else @@ -165,7 +154,6 @@ udp46_output_inline (vlib_main_t *vm, vlib_node_runtime_t *node, } if (uc1 != 0) { - udp_output_push_ip (vm, b[1], uc1, is_ip4); udp_output_handle_packet (uc1, b[1], node, &next[1], is_ip4); } else @@ -189,12 +177,10 @@ udp46_output_inline (vlib_main_t *vm, vlib_node_runtime_t *node, CLIB_PREFETCH (b[1]->data, 2 * CLIB_CACHE_LINE_BYTES, STORE); } - uc0 = udp_connection_get (vnet_buffer (b[0])->tcp.connection_index, - thread_index); + uc0 = udp_output_get_connection (b[0], thread_index); if (PREDICT_TRUE (uc0 != 0)) { - udp_output_push_ip (vm, b[0], uc0, is_ip4); udp_output_handle_packet (uc0, b[0], node, &next[0], is_ip4); } else |