#define foreach_memif_tx_func_error \
_(NO_FREE_SLOTS, "no free tx slots") \
_(TRUNC_PACKET, "packet > buffer size -- truncated in tx ring") \
-_(PENDING_MSGS, "pending msgs in tx ring")
+_(PENDING_MSGS, "pending msgs in tx ring") \
+_(NO_TX_QUEUES, "no tx queues")
typedef enum
{
u8 tx_queues = vec_len (mif->tx_queues);
memif_queue_t *mq;
+ if (PREDICT_FALSE (tx_queues == 0))
+ {
+ vlib_error_count (vm, node->node_index, MEMIF_TX_ERROR_NO_TX_QUEUES,
+ n_left);
+ goto error;
+ }
+
if (tx_queues < vec_len (vlib_mains))
{
qid = thread_index % tx_queues;
n_left);
}
- vlib_buffer_free (vm, vlib_frame_args (frame), frame->n_vectors);
if ((ring->flags & MEMIF_RING_FLAG_MASK_INT) == 0 && mq->int_fd > -1)
{
u64 b = 1;
mq->int_count++;
}
+error:
+ vlib_buffer_free (vm, vlib_frame_args (frame), frame->n_vectors);
+
return frame->n_vectors;
}
vl_api_memif_delete_reply_t *rmp;
vnet_hw_interface_t *hi =
vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
- memif_if_t *mif = pool_elt_at_index (mm->interfaces, hi->dev_instance);
+ memif_if_t *mif;
int rv = 0;
if (hi == NULL || memif_device_class.index != hi->dev_class_index)
rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
else
- rv = memif_delete_if (vm, mif);
+ {
+ mif = pool_elt_at_index (mm->interfaces, hi->dev_instance);
+ rv = memif_delete_if (vm, mif);
+ }
REPLY_MACRO (VL_API_MEMIF_DELETE_REPLY);
}
h->max_region = MEMIF_MAX_REGION;
h->max_log2_ring_size = MEMIF_MAX_LOG2_RING_SIZE;
s = format (0, "VPP %s%c", VPP_BUILD_VER, 0);
- strncpy ((char *) h->name, (char *) s, sizeof (h->name));
+ strncpy ((char *) h->name, (char *) s, sizeof (h->name) - 1);
vec_free (s);
return memif_msg_send (fd, &msg, -1);
}
i->id = mif->id;
i->mode = mif->mode;
s = format (0, "VPP %s%c", VPP_BUILD_VER, 0);
- strncpy ((char *) i->name, (char *) s, sizeof (i->name));
+ strncpy ((char *) i->name, (char *) s, sizeof (i->name) - 1);
if (mif->secret)
- strncpy ((char *) i->secret, (char *) mif->secret, sizeof (i->secret));
+ strncpy ((char *) i->secret, (char *) mif->secret,
+ sizeof (i->secret) - 1);
vec_free (s);
}
e->msg.type = MEMIF_MSG_TYPE_CONNECT;
e->fd = -1;
s = format (0, "%U%c", format_memif_device_name, mif->dev_instance, 0);
- strncpy ((char *) c->if_name, (char *) s, sizeof (c->if_name));
+ strncpy ((char *) c->if_name, (char *) s, sizeof (c->if_name) - 1);
vec_free (s);
}
e->msg.type = MEMIF_MSG_TYPE_CONNECTED;
e->fd = -1;
s = format (0, "%U%c", format_memif_device_name, mif->dev_instance, 0);
- strncpy ((char *) c->if_name, (char *) s, sizeof (c->if_name));
+ strncpy ((char *) c->if_name, (char *) s, sizeof (c->if_name) - 1);
vec_free (s);
}
memif_msg_disconnect_t *d = &msg.disconnect;
d->code = err->code;
- strncpy ((char *) d->string, (char *) err->what, sizeof (d->string));
+ strncpy ((char *) d->string, (char *) err->what, sizeof (d->string) - 1);
return memif_msg_send (mif->conn_fd, &msg, -1);
}