summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/memif/memif.c36
-rw-r--r--src/plugins/memif/private.h38
-rw-r--r--src/plugins/memif/socket.c56
3 files changed, 66 insertions, 64 deletions
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c
index 4c387b92f81..8fec409a16d 100644
--- a/src/plugins/memif/memif.c
+++ b/src/plugins/memif/memif.c
@@ -52,10 +52,10 @@ memif_eth_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 flags)
static void
memif_queue_intfd_close (memif_queue_t * mq)
{
- if (mq->int_unix_file_index != ~0)
+ if (mq->int_clib_file_index != ~0)
{
- memif_file_del_by_index (mq->int_unix_file_index);
- mq->int_unix_file_index = ~0;
+ memif_file_del_by_index (mq->int_clib_file_index);
+ mq->int_clib_file_index = ~0;
mq->int_fd = -1;
}
else if (mq->int_fd > -1)
@@ -94,13 +94,13 @@ memif_disconnect (memif_if_t * mif, clib_error_t * err)
vnet_hw_interface_set_flags (vnm, mif->hw_if_index, 0);
/* close connection socket */
- if (mif->conn_unix_file_index != ~0)
+ if (mif->conn_clib_file_index != ~0)
{
memif_socket_file_t *msf = vec_elt_at_index (mm->socket_files,
mif->socket_file_index);
hash_unset (msf->dev_instance_by_fd, mif->conn_fd);
- memif_file_del_by_index (mif->conn_unix_file_index);
- mif->conn_unix_file_index = ~0;
+ memif_file_del_by_index (mif->conn_clib_file_index);
+ mif->conn_clib_file_index = ~0;
}
else if (mif->conn_fd > -1)
close (mif->conn_fd);
@@ -145,7 +145,7 @@ memif_disconnect (memif_if_t * mif, clib_error_t * err)
}
static clib_error_t *
-memif_int_fd_read_ready (unix_file_t * uf)
+memif_int_fd_read_ready (clib_file_t * uf)
{
memif_main_t *mm = &memif_main;
vnet_main_t *vnm = vnet_get_main ();
@@ -173,7 +173,7 @@ clib_error_t *
memif_connect (memif_if_t * mif)
{
vnet_main_t *vnm = vnet_get_main ();
- unix_file_t template = { 0 };
+ clib_file_t template = { 0 };
memif_region_t *mr;
int i;
@@ -219,7 +219,7 @@ memif_connect (memif_if_t * mif)
{
template.file_descriptor = mq->int_fd;
template.private_data = (mif->dev_instance << 16) | (i & 0xFFFF);
- memif_file_add (&mq->int_unix_file_index, &template);
+ memif_file_add (&mq->int_clib_file_index, &template);
}
vnet_hw_interface_assign_rx_thread (vnm, mif->hw_if_index, i, ~0);
rv = vnet_hw_interface_set_rx_mode (vnm, mif->hw_if_index, i,
@@ -330,7 +330,7 @@ memif_init_regions_and_queues (memif_if_t * mif)
memif_queue_t *mq = vec_elt_at_index (mif->tx_queues, i);
if ((mq->int_fd = eventfd (0, EFD_NONBLOCK)) < 0)
return clib_error_return_unix (0, "eventfd[tx queue %u]", i);
- mq->int_unix_file_index = ~0;
+ mq->int_clib_file_index = ~0;
mq->ring = memif_get_ring (mif, MEMIF_RING_S2M, i);
mq->log2_ring_size = mif->cfg.log2_ring_size;
mq->region = 0;
@@ -346,7 +346,7 @@ memif_init_regions_and_queues (memif_if_t * mif)
memif_queue_t *mq = vec_elt_at_index (mif->rx_queues, i);
if ((mq->int_fd = eventfd (0, EFD_NONBLOCK)) < 0)
return clib_error_return_unix (0, "eventfd[rx queue %u]", i);
- mq->int_unix_file_index = ~0;
+ mq->int_clib_file_index = ~0;
mq->ring = memif_get_ring (mif, MEMIF_RING_M2S, i);
mq->log2_ring_size = mif->cfg.log2_ring_size;
mq->region = 0;
@@ -432,7 +432,7 @@ memif_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
(sockfd, (struct sockaddr *) &sun,
sizeof (struct sockaddr_un)) == 0)
{
- unix_file_t t = { 0 };
+ clib_file_t t = { 0 };
mif->conn_fd = sockfd;
t.read_function = memif_slave_conn_fd_read_ready;
@@ -440,7 +440,7 @@ memif_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
t.error_function = memif_slave_conn_fd_error;
t.file_descriptor = mif->conn_fd;
t.private_data = mif->dev_instance;
- memif_file_add (&mif->conn_unix_file_index, &t);
+ memif_file_add (&mif->conn_clib_file_index, &t);
hash_set (msf->dev_instance_by_fd, mif->conn_fd, mif->dev_instance);
mif->flags |= MEMIF_IF_FLAG_CONNECTING;
@@ -507,7 +507,7 @@ memif_delete_if (vlib_main_t * vm, memif_if_t * mif)
if (msf->is_listener)
{
uword *x;
- memif_file_del_by_index (msf->unix_file_index);
+ memif_file_del_by_index (msf->clib_file_index);
vec_foreach (x, msf->pending_file_indices)
{
memif_file_del_by_index (*x);
@@ -639,7 +639,7 @@ memif_create_if (vlib_main_t * vm, memif_create_if_args_t * args)
mif->socket_file_index = msf - mm->socket_files;
mif->id = args->id;
mif->sw_if_index = mif->hw_if_index = mif->per_interface_next_index = ~0;
- mif->conn_unix_file_index = ~0;
+ mif->conn_clib_file_index = ~0;
mif->conn_fd = -1;
mif->mode = args->mode;
if (args->secret)
@@ -737,12 +737,12 @@ memif_create_if (vlib_main_t * vm, memif_create_if_args_t * args)
goto error;
}
- msf->unix_file_index = ~0;
- unix_file_t template = { 0 };
+ msf->clib_file_index = ~0;
+ clib_file_t template = { 0 };
template.read_function = memif_conn_fd_accept_ready;
template.file_descriptor = msf->fd;
template.private_data = mif->socket_file_index;
- memif_file_add (&msf->unix_file_index, &template);
+ memif_file_add (&msf->clib_file_index, &template);
}
msf->ref_cnt++;
diff --git a/src/plugins/memif/private.h b/src/plugins/memif/private.h
index b5f2f8ff55f..912ec59abd2 100644
--- a/src/plugins/memif/private.h
+++ b/src/plugins/memif/private.h
@@ -41,34 +41,34 @@
#if MEMIF_DEBUG == 1
#define memif_file_add(a, b) do { \
ASSERT (*a == ~0); \
- *a = unix_file_add (&unix_main, b); \
- clib_warning ("unix_file_add fd %d private_data %u idx %u", \
+ *a = clib_file_add (&file_main, b); \
+ clib_warning ("clib_file_add fd %d private_data %u idx %u", \
(b)->file_descriptor, (b)->private_data, *a); \
} while (0)
#define memif_file_del(a) do { \
- clib_warning ("unix_file_del idx %u",a - unix_main.file_pool); \
- unix_file_del (&unix_main, a); \
+ clib_warning ("clib_file_del idx %u",a - file_main.file_pool); \
+ clib_file_del (&file_main, a); \
} while (0)
#define memif_file_del_by_index(a) do { \
- clib_warning ("unix_file_del idx %u", a); \
- unix_file_del_by_index (&unix_main, a); \
+ clib_warning ("clib_file_del idx %u", a); \
+ clib_file_del_by_index (&file_main, a); \
} while (0)
#else
#define memif_file_add(a, b) do { \
ASSERT (*a == ~0); \
- *a = unix_file_add (&unix_main, b); \
+ *a = clib_file_add (&file_main, b); \
} while (0)
-#define memif_file_del(a) unix_file_del(&unix_main, a)
-#define memif_file_del_by_index(a) unix_file_del_by_index(&unix_main, a)
+#define memif_file_del(a) clib_file_del(&file_main, a)
+#define memif_file_del_by_index(a) clib_file_del_by_index(&file_main, a)
#endif
typedef struct
{
u8 *filename;
int fd;
- uword unix_file_index;
+ uword clib_file_index;
uword *pending_file_indices;
int ref_cnt;
int is_listener;
@@ -106,7 +106,7 @@ typedef struct
/* interrupts */
int int_fd;
- uword int_unix_file_index;
+ uword int_clib_file_index;
u64 int_count;
} memif_queue_t;
@@ -140,7 +140,7 @@ typedef struct
/* socket connection */
uword socket_file_index;
int conn_fd;
- uword conn_unix_file_index;
+ uword conn_clib_file_index;
memif_msg_fifo_elt_t *msg_queue;
u8 *secret;
@@ -241,13 +241,13 @@ clib_error_t *memif_connect (memif_if_t * mif);
void memif_disconnect (memif_if_t * mif, clib_error_t * err);
/* socket.c */
-clib_error_t *memif_conn_fd_accept_ready (unix_file_t * uf);
-clib_error_t *memif_master_conn_fd_read_ready (unix_file_t * uf);
-clib_error_t *memif_slave_conn_fd_read_ready (unix_file_t * uf);
-clib_error_t *memif_master_conn_fd_write_ready (unix_file_t * uf);
-clib_error_t *memif_slave_conn_fd_write_ready (unix_file_t * uf);
-clib_error_t *memif_master_conn_fd_error (unix_file_t * uf);
-clib_error_t *memif_slave_conn_fd_error (unix_file_t * uf);
+clib_error_t *memif_conn_fd_accept_ready (clib_file_t * uf);
+clib_error_t *memif_master_conn_fd_read_ready (clib_file_t * uf);
+clib_error_t *memif_slave_conn_fd_read_ready (clib_file_t * uf);
+clib_error_t *memif_master_conn_fd_write_ready (clib_file_t * uf);
+clib_error_t *memif_slave_conn_fd_write_ready (clib_file_t * uf);
+clib_error_t *memif_master_conn_fd_error (clib_file_t * uf);
+clib_error_t *memif_slave_conn_fd_error (clib_file_t * uf);
clib_error_t *memif_msg_send_disconnect (memif_if_t * mif,
clib_error_t * err);
u8 *format_memif_device_name (u8 * s, va_list * args);
diff --git a/src/plugins/memif/socket.c b/src/plugins/memif/socket.c
index 79ae07bef15..1abc0f119aa 100644
--- a/src/plugins/memif/socket.c
+++ b/src/plugins/memif/socket.c
@@ -246,7 +246,7 @@ memif_msg_receive_hello (memif_if_t * mif, memif_msg_t * msg)
static clib_error_t *
memif_msg_receive_init (memif_if_t ** mifp, memif_msg_t * msg,
- unix_file_t * uf)
+ clib_file_t * uf)
{
memif_main_t *mm = &memif_main;
memif_socket_file_t *msf =
@@ -258,7 +258,7 @@ memif_msg_receive_init (memif_if_t ** mifp, memif_msg_t * msg,
if (i->version != MEMIF_VERSION)
{
- memif_file_del_by_index (uf - unix_main.file_pool);
+ memif_file_del_by_index (uf - file_main.file_pool);
return clib_error_return (0, "unsupported version");
}
@@ -291,7 +291,7 @@ memif_msg_receive_init (memif_if_t ** mifp, memif_msg_t * msg,
}
mif->conn_fd = uf->file_descriptor;
- mif->conn_unix_file_index = uf - unix_main.file_pool;
+ mif->conn_clib_file_index = uf - file_main.file_pool;
hash_set (msf->dev_instance_by_fd, mif->conn_fd, mif->dev_instance);
mif->remote_name = memif_str2vec (i->name, sizeof (i->name));
*mifp = mif;
@@ -316,7 +316,7 @@ memif_msg_receive_init (memif_if_t ** mifp, memif_msg_t * msg,
error:
tmp.conn_fd = uf->file_descriptor;
memif_msg_send_disconnect (&tmp, err);
- memif_file_del_by_index (uf - unix_main.file_pool);
+ memif_file_del_by_index (uf - file_main.file_pool);
return err;
}
@@ -377,7 +377,7 @@ memif_msg_receive_add_ring (memif_if_t * mif, memif_msg_t * msg, int fd)
}
mq->int_fd = fd;
- mq->int_unix_file_index = ~0;
+ mq->int_clib_file_index = ~0;
mq->log2_ring_size = ar->log2_ring_size;
mq->region = ar->region;
mq->offset = ar->offset;
@@ -422,7 +422,7 @@ memif_msg_receive_disconnect (memif_if_t * mif, memif_msg_t * msg)
}
static clib_error_t *
-memif_msg_receive (memif_if_t ** mifp, unix_file_t * uf)
+memif_msg_receive (memif_if_t ** mifp, clib_file_t * uf)
{
char ctl[CMSG_SPACE (sizeof (int)) +
CMSG_SPACE (sizeof (struct ucred))] = { 0 };
@@ -544,20 +544,21 @@ memif_msg_receive (memif_if_t ** mifp, unix_file_t * uf)
return err;
}
- if (clib_fifo_elts (mif->msg_queue) && mif->conn_unix_file_index != ~0)
- unix_file_set_data_available_to_write (mif->conn_unix_file_index, 1);
+ if (clib_fifo_elts (mif->msg_queue) && mif->conn_clib_file_index != ~0)
+ clib_file_set_data_available_to_write (&file_main,
+ mif->conn_clib_file_index, 1);
return 0;
}
clib_error_t *
-memif_master_conn_fd_read_ready (unix_file_t * uf)
+memif_master_conn_fd_read_ready (clib_file_t * uf)
{
memif_main_t *mm = &memif_main;
memif_socket_file_t *msf =
pool_elt_at_index (mm->socket_files, uf->private_data);
uword *p;
memif_if_t *mif = 0;
- uword conn_unix_file_index = ~0;
+ uword conn_clib_file_index = ~0;
clib_error_t *err = 0;
p = hash_get (msf->dev_instance_by_fd, uf->file_descriptor);
@@ -570,13 +571,13 @@ memif_master_conn_fd_read_ready (unix_file_t * uf)
/* This is new connection, remove index from pending vector */
int i;
vec_foreach_index (i, msf->pending_file_indices)
- if (msf->pending_file_indices[i] == uf - unix_main.file_pool)
+ if (msf->pending_file_indices[i] == uf - file_main.file_pool)
{
- conn_unix_file_index = msf->pending_file_indices[i];
+ conn_clib_file_index = msf->pending_file_indices[i];
vec_del1 (msf->pending_file_indices, i);
break;
}
- ASSERT (conn_unix_file_index != ~0);
+ ASSERT (conn_clib_file_index != ~0);
}
err = memif_msg_receive (&mif, uf);
if (err)
@@ -588,7 +589,7 @@ memif_master_conn_fd_read_ready (unix_file_t * uf)
}
clib_error_t *
-memif_slave_conn_fd_read_ready (unix_file_t * uf)
+memif_slave_conn_fd_read_ready (clib_file_t * uf)
{
memif_main_t *mm = &memif_main;
clib_error_t *err;
@@ -603,17 +604,18 @@ memif_slave_conn_fd_read_ready (unix_file_t * uf)
}
static clib_error_t *
-memif_conn_fd_write_ready (unix_file_t * uf, memif_if_t * mif)
+memif_conn_fd_write_ready (clib_file_t * uf, memif_if_t * mif)
{
memif_msg_fifo_elt_t *e;
clib_fifo_sub2 (mif->msg_queue, e);
- unix_file_set_data_available_to_write (mif->conn_unix_file_index, 0);
+ clib_file_set_data_available_to_write (&file_main,
+ mif->conn_clib_file_index, 0);
memif_msg_send (mif->conn_fd, &e->msg, e->fd);
return 0;
}
clib_error_t *
-memif_master_conn_fd_write_ready (unix_file_t * uf)
+memif_master_conn_fd_write_ready (clib_file_t * uf)
{
memif_main_t *mm = &memif_main;
memif_socket_file_t *msf =
@@ -630,7 +632,7 @@ memif_master_conn_fd_write_ready (unix_file_t * uf)
}
clib_error_t *
-memif_slave_conn_fd_write_ready (unix_file_t * uf)
+memif_slave_conn_fd_write_ready (clib_file_t * uf)
{
memif_main_t *mm = &memif_main;
memif_if_t *mif = vec_elt_at_index (mm->interfaces, uf->private_data);
@@ -638,7 +640,7 @@ memif_slave_conn_fd_write_ready (unix_file_t * uf)
}
clib_error_t *
-memif_slave_conn_fd_error (unix_file_t * uf)
+memif_slave_conn_fd_error (clib_file_t * uf)
{
memif_main_t *mm = &memif_main;
memif_if_t *mif = vec_elt_at_index (mm->interfaces, uf->private_data);
@@ -652,7 +654,7 @@ memif_slave_conn_fd_error (unix_file_t * uf)
}
clib_error_t *
-memif_master_conn_fd_error (unix_file_t * uf)
+memif_master_conn_fd_error (clib_file_t * uf)
{
memif_main_t *mm = &memif_main;
memif_socket_file_t *msf =
@@ -674,7 +676,7 @@ memif_master_conn_fd_error (unix_file_t * uf)
{
int i;
vec_foreach_index (i, msf->pending_file_indices)
- if (msf->pending_file_indices[i] == uf - unix_main.file_pool)
+ if (msf->pending_file_indices[i] == uf - file_main.file_pool)
{
vec_del1 (msf->pending_file_indices, i);
memif_file_del (uf);
@@ -689,7 +691,7 @@ memif_master_conn_fd_error (unix_file_t * uf)
clib_error_t *
-memif_conn_fd_accept_ready (unix_file_t * uf)
+memif_conn_fd_accept_ready (clib_file_t * uf)
{
memif_main_t *mm = &memif_main;
memif_socket_file_t *msf =
@@ -697,8 +699,8 @@ memif_conn_fd_accept_ready (unix_file_t * uf)
int addr_len;
struct sockaddr_un client;
int conn_fd;
- unix_file_t template = { 0 };
- uword unix_file_index = ~0;
+ clib_file_t template = { 0 };
+ uword clib_file_index = ~0;
clib_error_t *err;
@@ -715,16 +717,16 @@ memif_conn_fd_accept_ready (unix_file_t * uf)
template.file_descriptor = conn_fd;
template.private_data = uf->private_data;
- memif_file_add (&unix_file_index, &template);
+ memif_file_add (&clib_file_index, &template);
err = memif_msg_enq_hello (conn_fd);
if (err)
{
clib_error_report (err);
- memif_file_del_by_index (unix_file_index);
+ memif_file_del_by_index (clib_file_index);
}
else
- vec_add1 (msf->pending_file_indices, unix_file_index);
+ vec_add1 (msf->pending_file_indices, clib_file_index);
return 0;
}