MCPcopy Create free account
hub / github.com/F-Stack/f-stack / read_vhost_message

Function read_vhost_message

dpdk/lib/vhost/vhost_user.c:2877–2915  ·  view source on GitHub ↗

return bytes# of read on success or negative val on failure. */

Source from the content-addressed store, hash-verified

2875
2876/* return bytes# of read on success or negative val on failure. */
2877static int
2878read_vhost_message(struct virtio_net *dev, int sockfd, struct vhu_msg_context *ctx)
2879{
2880 int ret;
2881
2882 ret = read_fd_message(dev->ifname, sockfd, (char *)&ctx->msg, VHOST_USER_HDR_SIZE,
2883 ctx->fds, VHOST_MEMORY_MAX_NREGIONS, &ctx->fd_num);
2884 if (ret <= 0)
2885 goto out;
2886
2887 if (ret != VHOST_USER_HDR_SIZE) {
2888 VHOST_LOG_CONFIG(dev->ifname, ERR, "Unexpected header size read\n");
2889 ret = -1;
2890 goto out;
2891 }
2892
2893 if (ctx->msg.size) {
2894 if (ctx->msg.size > sizeof(ctx->msg.payload)) {
2895 VHOST_LOG_CONFIG(dev->ifname, ERR, "invalid msg size: %d\n",
2896 ctx->msg.size);
2897 ret = -1;
2898 goto out;
2899 }
2900 ret = read(sockfd, &ctx->msg.payload, ctx->msg.size);
2901 if (ret <= 0)
2902 goto out;
2903 if (ret != (int)ctx->msg.size) {
2904 VHOST_LOG_CONFIG(dev->ifname, ERR, "read control message failed\n");
2905 ret = -1;
2906 goto out;
2907 }
2908 }
2909
2910out:
2911 if (ret <= 0)
2912 close_msg_fds(ctx);
2913
2914 return ret;
2915}
2916
2917static int
2918send_vhost_message(struct virtio_net *dev, int sockfd, struct vhu_msg_context *ctx)

Calls 3

read_fd_messageFunction · 0.85
close_msg_fdsFunction · 0.85
readFunction · 0.50

Tested by

no test coverage detected