X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Fvhost%2Fvhost_user.c;h=1d390677fa4c2a16675742b48fdd1a62d0c8687a;hb=af74f7db384ed149fe42b21dbd7975f8a54ef227;hp=723c6890c33424f94ad752b55144a1a5220f0035;hpb=04c27cb673b983ce2580731c0afc4b0e815fd658;p=dpdk.git diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 723c6890c3..1d390677fa 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -1602,6 +1602,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev, int numa_node = SOCKET_ID_ANY; void *addr; + if (validate_msg_fds(dev, ctx, 0) != 0) + return RTE_VHOST_MSG_RESULT_ERR; + if (ctx->msg.size != sizeof(ctx->msg.payload.inflight)) { VHOST_LOG_CONFIG(ERR, "(%s) invalid get_inflight_fd message size is %d\n", dev->ifname, ctx->msg.size); @@ -1699,6 +1702,9 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, int fd, i; int numa_node = SOCKET_ID_ANY; + if (validate_msg_fds(dev, ctx, 1) != 0) + return RTE_VHOST_MSG_RESULT_ERR; + fd = ctx->fds[0]; if (ctx->msg.size != sizeof(ctx->msg.payload.inflight) || fd < 0) { VHOST_LOG_CONFIG(ERR, "(%s) invalid set_inflight_fd message size is %d,fd is %d\n", @@ -2883,6 +2889,9 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, case VHOST_USER_SET_VRING_ADDR: vring_idx = ctx->msg.payload.addr.index; break; + case VHOST_USER_SET_INFLIGHT_FD: + vring_idx = ctx->msg.payload.inflight.num_queues - 1; + break; default: return 0; } @@ -3023,8 +3032,8 @@ vhost_user_msg_handler(int vid, int fd) handled = false; if (dev->extern_ops.pre_msg_handle) { - ret = (*dev->extern_ops.pre_msg_handle)(dev->vid, - (void *)&ctx.msg); + RTE_BUILD_BUG_ON(offsetof(struct vhu_msg_context, msg) != 0); + ret = (*dev->extern_ops.pre_msg_handle)(dev->vid, &ctx); switch (ret) { case RTE_VHOST_MSG_RESULT_REPLY: send_vhost_reply(dev, fd, &ctx); @@ -3069,8 +3078,8 @@ vhost_user_msg_handler(int vid, int fd) skip_to_post_handle: if (ret != RTE_VHOST_MSG_RESULT_ERR && dev->extern_ops.post_msg_handle) { - ret = (*dev->extern_ops.post_msg_handle)(dev->vid, - (void *)&ctx.msg); + RTE_BUILD_BUG_ON(offsetof(struct vhu_msg_context, msg) != 0); + ret = (*dev->extern_ops.post_msg_handle)(dev->vid, &ctx); switch (ret) { case RTE_VHOST_MSG_RESULT_REPLY: send_vhost_reply(dev, fd, &ctx);