aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/memif/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/memif/socket.c')
-rw-r--r--src/plugins/memif/socket.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/plugins/memif/socket.c b/src/plugins/memif/socket.c
index 39ff99e3d8d..cefbb863c7a 100644
--- a/src/plugins/memif/socket.c
+++ b/src/plugins/memif/socket.c
@@ -408,6 +408,7 @@ memif_msg_receive_disconnect (memif_if_t * mif, memif_msg_t * msg)
static clib_error_t *
memif_msg_receive (memif_if_t ** mifp, clib_socket_t * sock, clib_file_t * uf)
{
+ memif_main_t *mm = &memif_main;
memif_msg_t msg = { 0 };
clib_error_t *err = 0;
int fd = -1;
@@ -416,15 +417,16 @@ memif_msg_receive (memif_if_t ** mifp, clib_socket_t * sock, clib_file_t * uf)
err = clib_socket_recvmsg (sock, &msg, sizeof (memif_msg_t), &fd, 1);
if (err)
- return err;
+ goto error;
if (mif == 0 && msg.type != MEMIF_MSG_TYPE_INIT)
{
memif_socket_close (&sock);
- return clib_error_return (0, "unexpected message received");
+ err = clib_error_return (0, "unexpected message received");
+ goto error;
}
- DBG ("Message type %u received", msg.type);
+ vlib_log_debug (mm->log_class, "Message type %u received", msg.type);
/* process the message based on its type */
switch (msg.type)
{
@@ -433,9 +435,9 @@ memif_msg_receive (memif_if_t ** mifp, clib_socket_t * sock, clib_file_t * uf)
case MEMIF_MSG_TYPE_HELLO:
if ((err = memif_msg_receive_hello (mif, &msg)))
- return err;
+ goto error;
if ((err = memif_init_regions_and_queues (mif)))
- return err;
+ goto error;
memif_msg_enq_init (mif);
/* *INDENT-OFF* */
vec_foreach_index (i, mif->regions)
@@ -450,7 +452,7 @@ memif_msg_receive (memif_if_t ** mifp, clib_socket_t * sock, clib_file_t * uf)
case MEMIF_MSG_TYPE_INIT:
if ((err = memif_msg_receive_init (mifp, &msg, sock, uf->private_data)))
- return err;
+ goto error;
mif = *mifp;
vec_reset_length (uf->description);
uf->description = format (uf->description, "%U ctl",
@@ -460,41 +462,45 @@ memif_msg_receive (memif_if_t ** mifp, clib_socket_t * sock, clib_file_t * uf)
case MEMIF_MSG_TYPE_ADD_REGION:
if ((err = memif_msg_receive_add_region (mif, &msg, fd)))
- return err;
+ goto error;
memif_msg_enq_ack (mif);
break;
case MEMIF_MSG_TYPE_ADD_RING:
if ((err = memif_msg_receive_add_ring (mif, &msg, fd)))
- return err;
+ goto error;
memif_msg_enq_ack (mif);
break;
case MEMIF_MSG_TYPE_CONNECT:
if ((err = memif_msg_receive_connect (mif, &msg)))
- return err;
+ goto error;
memif_msg_enq_connected (mif);
break;
case MEMIF_MSG_TYPE_CONNECTED:
if ((err = memif_msg_receive_connected (mif, &msg)))
- return err;
+ goto error;
break;
case MEMIF_MSG_TYPE_DISCONNECT:
if ((err = memif_msg_receive_disconnect (mif, &msg)))
- return err;
+ goto error;
break;
default:
err = clib_error_return (0, "unknown message type (0x%x)", msg.type);
- return err;
+ goto error;
}
if (clib_fifo_elts (mif->msg_queue))
clib_file_set_data_available_to_write (&file_main,
mif->sock->private_data, 1);
return 0;
+
+error:
+ vlib_log_err (mm->log_class, "%U", format_clib_error, err);
+ return err;
}
clib_error_t *
@@ -633,7 +639,8 @@ memif_master_conn_fd_error (clib_file_t * uf)
}
}
- clib_warning ("Error on unknown file descriptor %d", uf->file_descriptor);
+ vlib_log_warn (mm->log_class, "Error on unknown file descriptor %d",
+ uf->file_descriptor);
memif_file_del (uf);
return 0;
}
@@ -676,7 +683,7 @@ memif_conn_fd_accept_ready (clib_file_t * uf)
return 0;
error:
- clib_error_report (err);
+ vlib_log_err (mm->log_class, "%U", format_clib_error, err);
clib_mem_free (client);
return err;
}