From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 814A3A0A05; Tue, 19 Jan 2021 22:29:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02A59140F18; Tue, 19 Jan 2021 22:27:39 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mails.dpdk.org (Postfix) with ESMTP id 59A86140F18 for ; Tue, 19 Jan 2021 22:27:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611091656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ReqOdlym/Aqzew0RYVncLEPVjG8WoHYXXCtp0dGCskc=; b=az0ztaAZfm/1uFQ4M1QHaTLYcXL1pT5z1fSmMEzD/EiU6VD6oI2ww3IX5gwNIyME4d4eTo 6qAyj50CfsTi5VqgZjr0IcjgGntD49FWUjZAfh6xOhlHw1ipBjh0e/kgIKDdzqLXDXx8lC BFYFcvFQTXH+V7KjT6CqRRCCqTJUehE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-510-F6BhQjR8MOWk1ygqtYaiXQ-1; Tue, 19 Jan 2021 16:27:35 -0500 X-MC-Unique: F6BhQjR8MOWk1ygqtYaiXQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E7D88066E7; Tue, 19 Jan 2021 21:27:34 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7ECD35D9DD; Tue, 19 Jan 2021 21:27:18 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, olivier.matz@6wind.com, amorenoz@redhat.com, david.marchand@redhat.com Cc: Maxime Coquelin Date: Tue, 19 Jan 2021 22:24:48 +0100 Message-Id: <20210119212507.1043636-26-maxime.coquelin@redhat.com> In-Reply-To: <20210119212507.1043636-1-maxime.coquelin@redhat.com> References: <20210119212507.1043636-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH v2 25/44] net/virtio: make Vhost-user req sender consistent X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch makes vhost_user_write() consistent with vhost_user_read(), by passing a Vhost-user message pointer instead of a buffer pointer and its length, which is now calculated in the function. Signed-off-by: Maxime Coquelin --- drivers/net/virtio/virtio_user/vhost_user.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index 350eed4182..55c813333a 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -51,7 +51,7 @@ struct vhost_user_msg { (sizeof(struct vhost_user_msg) - VHOST_USER_HDR_SIZE) static int -vhost_user_write(int fd, void *buf, int len, int *fds, int fd_num) +vhost_user_write(int fd, struct vhost_user_msg *msg, int *fds, int fd_num) { int r; struct msghdr msgh; @@ -63,8 +63,8 @@ vhost_user_write(int fd, void *buf, int len, int *fds, int fd_num) memset(&msgh, 0, sizeof(msgh)); memset(control, 0, sizeof(control)); - iov.iov_base = (uint8_t *)buf; - iov.iov_len = len; + iov.iov_base = (uint8_t *)msg; + iov.iov_len = VHOST_USER_HDR_SIZE + msg->size; msgh.msg_iov = &iov; msgh.msg_iovlen = 1; @@ -259,7 +259,6 @@ vhost_user_sock(struct virtio_user_dev *dev, int has_reply_ack = 0; int fds[VHOST_MEMORY_MAX_NREGIONS]; int fd_num = 0; - int len; int vhostfd = dev->vhostfd; RTE_SET_USED(m); @@ -364,8 +363,7 @@ vhost_user_sock(struct virtio_user_dev *dev, return -1; } - len = VHOST_USER_HDR_SIZE + msg.size; - if (vhost_user_write(vhostfd, &msg, len, fds, fd_num) < 0) { + if (vhost_user_write(vhostfd, &msg, fds, fd_num) < 0) { PMD_DRV_LOG(ERR, "%s failed: %s", vhost_msg_strings[req], strerror(errno)); return -1; -- 2.29.2