summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2023-03-13 11:07:40 -0700
committerSteven Luong <sluong@cisco.com>2023-03-13 11:11:29 -0700
commita361a3951c5cc825fcb4e94c41255e2074261769 (patch)
treed5b35db447e0b91af9731d95a36ed65ab7c7d206 /src/vnet
parent0638619e059d3ec9088e5a530e7f1b236d25b595 (diff)
udp: Use udp_output_get_connection instead of udp_connection_get
udp_output_get_connection handles correctly if the connection is a listener whereas udp_connection_get does not which may lead to a crash. Type: fix Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: I40b57287a8686820d29872cae2cfd6ae27a57c26
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/udp/udp_output.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/vnet/udp/udp_output.c b/src/vnet/udp/udp_output.c
index 2d995136e19..22b94141365 100644
--- a/src/vnet/udp/udp_output.c
+++ b/src/vnet/udp/udp_output.c
@@ -51,6 +51,16 @@ format_udp_tx_trace (u8 *s, va_list *args)
return s;
}
+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);
+}
+
static void
udp46_output_trace_frame (vlib_main_t *vm, vlib_node_runtime_t *node,
u32 *to_next, u32 n_bufs)
@@ -67,8 +77,7 @@ udp46_output_trace_frame (vlib_main_t *vm, vlib_node_runtime_t *node,
if (!(b->flags & VLIB_BUFFER_IS_TRACED))
continue;
uh = vlib_buffer_get_current (b);
- uc = udp_connection_get (vnet_buffer (b)->tcp.connection_index,
- vm->thread_index);
+ uc = udp_output_get_connection (b, vm->thread_index);
t = vlib_add_trace (vm, node, b, sizeof (*t));
clib_memcpy_fast (&t->udp_header, uh, sizeof (t->udp_header));
clib_memcpy_fast (&t->udp_connection, uc, sizeof (t->udp_connection));
@@ -95,16 +104,6 @@ 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)