aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/ip/punt.c4
-rw-r--r--src/vnet/ip/punt.h6
-rw-r--r--src/vnet/ip/punt_node.c23
3 files changed, 22 insertions, 11 deletions
diff --git a/src/vnet/ip/punt.c b/src/vnet/ip/punt.c
index a979803bc1c..a3c7ecaf8a1 100644
--- a/src/vnet/ip/punt.c
+++ b/src/vnet/ip/punt.c
@@ -763,6 +763,7 @@ ip_punt_init (vlib_main_t * vm)
{
clib_error_t *error = NULL;
punt_main_t *pm = &punt_main;
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
pm->is_configured = false;
pm->interface_output_node =
@@ -773,6 +774,9 @@ ip_punt_init (vlib_main_t * vm)
pm->hdl = vlib_punt_client_register ("ip-punt");
+ vec_validate_aligned (pm->thread_data, tm->n_vlib_mains,
+ CLIB_CACHE_LINE_BYTES);
+
return (error);
}
diff --git a/src/vnet/ip/punt.h b/src/vnet/ip/punt.h
index 8835f3eb9d9..33124846ba6 100644
--- a/src/vnet/ip/punt.h
+++ b/src/vnet/ip/punt.h
@@ -111,6 +111,11 @@ typedef struct punt_client_db_t_
void *clients_by_ip_proto;
} punt_client_db_t;
+typedef struct punt_thread_data_t_
+{
+ struct iovec *iovecs;
+} punt_thread_data_t;
+
typedef struct
{
int socket_fd;
@@ -122,6 +127,7 @@ typedef struct
vlib_node_t *interface_output_node;
u32 *ready_fds;
u32 *rx_buffers;
+ punt_thread_data_t *thread_data;
vlib_punt_hdl_t hdl;
} punt_main_t;
diff --git a/src/vnet/ip/punt_node.c b/src/vnet/ip/punt_node.c
index 32a0884d86b..65237aaaa0e 100644
--- a/src/vnet/ip/punt_node.c
+++ b/src/vnet/ip/punt_node.c
@@ -248,13 +248,15 @@ punt_socket_inline (vlib_main_t * vm,
punt_type_t pt, ip_address_family_t af)
{
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;
- u32 node_index = AF_IP4 == af ? udp4_punt_socket_node.index :
- udp6_punt_socket_node.index;
+ punt_thread_data_t *ptd = &pm->thread_data[thread_index];
+ u32 node_index = (AF_IP4 == af ?
+ udp4_punt_socket_node.index :
+ udp6_punt_socket_node.index);
for (i = 0; i < n_packets; i++)
{
@@ -332,20 +334,19 @@ 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;
@@ -362,7 +363,7 @@ 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;
@@ -374,8 +375,8 @@ 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)