diff options
author | Neale Ranns <nranns@cisco.com> | 2019-07-10 01:47:15 -0700 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2019-07-11 20:03:19 +0000 |
commit | 13a6ddf353261fd0439646b71c832f4f44c9de71 (patch) | |
tree | 17aacb3301d188a30cc5a6d4572ffa167e62b40d | |
parent | f699d128bf83726ac13629ef0979a21af8149fc1 (diff) |
ip: Punt node does not free iovecs
Type: fix
Fixes: f7a55ad74c
Change-Id: Ic3474e746887f880a8f6246bebc399715bac8e80
Signed-off-by: Neale Ranns <nranns@cisco.com>
-rw-r--r-- | src/vnet/ip/punt.c | 22 | ||||
-rw-r--r-- | src/vnet/ip/punt.h | 6 |
2 files changed, 19 insertions, 9 deletions
diff --git a/src/vnet/ip/punt.c b/src/vnet/ip/punt.c index 743df1fef0b..705711795cc 100644 --- a/src/vnet/ip/punt.c +++ b/src/vnet/ip/punt.c @@ -317,11 +317,12 @@ udp46_punt_socket_inline (vlib_main_t * vm, vlib_frame_t * frame, bool is_ip4) { u32 *buffers = vlib_frame_vector_args (frame); + u32 thread_index = vm->thread_index; uword n_packets = frame->n_vectors; - struct iovec *iovecs = 0; punt_main_t *pm = &punt_main; int i; + punt_thread_data_t *ptd = &pm->thread_data[thread_index]; u32 node_index = is_ip4 ? udp4_punt_socket_node.index : udp6_punt_socket_node.index; @@ -375,20 +376,19 @@ udp46_punt_socket_inline (vlib_main_t * vm, clib_memcpy_fast (&t->client, c, sizeof (t->client)); } - /* Re-set iovecs if present. */ - if (iovecs) - _vec_len (iovecs) = 0; + /* Re-set iovecs */ + vec_reset_length (ptd->iovecs); /* Add packet descriptor */ packetdesc.sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX]; packetdesc.action = 0; - vec_add2 (iovecs, iov, 1); + vec_add2 (ptd->iovecs, iov, 1); iov->iov_base = &packetdesc; iov->iov_len = sizeof (packetdesc); /** VLIB buffer chain -> Unix iovec(s). */ vlib_buffer_advance (b, -(sizeof (ethernet_header_t))); - vec_add2 (iovecs, iov, 1); + vec_add2 (ptd->iovecs, iov, 1); iov->iov_base = b->data + b->current_data; iov->iov_len = l = b->current_length; @@ -409,7 +409,7 @@ udp46_punt_socket_inline (vlib_main_t * vm, t->is_midchain = 1; } - vec_add2 (iovecs, iov, 1); + vec_add2 (ptd->iovecs, iov, 1); iov->iov_base = b->data + b->current_data; iov->iov_len = b->current_length; @@ -421,8 +421,8 @@ udp46_punt_socket_inline (vlib_main_t * vm, struct msghdr msg = { .msg_name = caddr, .msg_namelen = sizeof (*caddr), - .msg_iov = iovecs, - .msg_iovlen = vec_len (iovecs), + .msg_iov = ptd->iovecs, + .msg_iovlen = vec_len (ptd->iovecs), }; if (sendmsg (pm->socket_fd, &msg, 0) < (ssize_t) l) @@ -1062,6 +1062,7 @@ clib_error_t * ip_punt_init (vlib_main_t * vm) { punt_main_t *pm = &punt_main; + vlib_thread_main_t *tm = vlib_get_thread_main (); pm->clients_by_dst_port6 = sparse_vec_new (sizeof (pm->clients_by_dst_port6[0]), @@ -1074,6 +1075,9 @@ ip_punt_init (vlib_main_t * vm) pm->interface_output_node = vlib_get_node_by_name (vm, (u8 *) "interface-output"); + + vec_validate_aligned (pm->thread_data, tm->n_vlib_mains, + CLIB_CACHE_LINE_BYTES); return 0; } diff --git a/src/vnet/ip/punt.h b/src/vnet/ip/punt.h index 0518b2b91ef..2d7a0f84665 100644 --- a/src/vnet/ip/punt.h +++ b/src/vnet/ip/punt.h @@ -69,6 +69,11 @@ typedef struct struct sockaddr_un caddr; } punt_client_t; +typedef struct punt_thread_data_t_ +{ + struct iovec *iovecs; +} punt_thread_data_t; + typedef struct { int socket_fd; @@ -80,6 +85,7 @@ typedef struct vlib_node_t *interface_output_node; u32 *ready_fds; u32 *rx_buffers; + punt_thread_data_t *thread_data; } punt_main_t; extern punt_main_t punt_main; |