rte_vhost: do not treat empty socket message as error
diff mbox series

Message ID 20200130080540.7616-1-vitaliy.mysak@intel.com
State Accepted, archived
Delegated to: Maxime Coquelin
Headers show
Series
  • rte_vhost: do not treat empty socket message as error
Related show

Checks

Context Check Description
ci/Intel-compilation fail apply issues
ci/iol-testing success Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Vitaliy Mysak Jan. 30, 2020, 8:05 a.m. UTC
According to recvmsg() specification, 0 is a valid
return code when client is disconnecting.
Therefore, it should not be reported as error, unless there
are other dependencies that require message to not be empty.
But there are none, since the next immediate caller of recvmsg()
reports "vhost peer closed" info (not error) when message is empty.

This patch changes return code check for recvmsg() so that
misleading error message is not printed when the code is 0.

Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
---
 lib/librte_vhost/socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Tiwei Bie Feb. 5, 2020, 5:08 a.m. UTC | #1
[PATCH] rte_vhost: do not treat empty socket message as error

s/rte_vhost:/vhost:/

On Thu, Jan 30, 2020 at 09:05:39AM +0100, Vitaliy Mysak wrote:
> According to recvmsg() specification, 0 is a valid
> return code when client is disconnecting.
> Therefore, it should not be reported as error, unless there
> are other dependencies that require message to not be empty.
> But there are none, since the next immediate caller of recvmsg()
> reports "vhost peer closed" info (not error) when message is empty.
> 
> This patch changes return code check for recvmsg() so that
> misleading error message is not printed when the code is 0.

Fixes: 8f972312b8f4 ("vhost: support vhost-user")
Cc: stable@dpdk.org

> 
> Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
> ---
>  lib/librte_vhost/socket.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>

Thanks,
Tiwei
Maxime Coquelin Feb. 5, 2020, 9:47 a.m. UTC | #2
On 1/30/20 9:05 AM, Vitaliy Mysak wrote:
> According to recvmsg() specification, 0 is a valid
> return code when client is disconnecting.
> Therefore, it should not be reported as error, unless there
> are other dependencies that require message to not be empty.
> But there are none, since the next immediate caller of recvmsg()
> reports "vhost peer closed" info (not error) when message is empty.
> 
> This patch changes return code check for recvmsg() so that
> misleading error message is not printed when the code is 0.
> 
> Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
> ---
>  lib/librte_vhost/socket.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied to dpdk-next-virtio tree.

Thanks,
Maxime

Patch
diff mbox series

diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
index 9740fb340..0cac3ce8e 100644
--- a/lib/librte_vhost/socket.c
+++ b/lib/librte_vhost/socket.c
@@ -127,7 +127,8 @@  read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
 
 	ret = recvmsg(sockfd, &msgh, 0);
 	if (ret <= 0) {
-		VHOST_LOG_CONFIG(ERR, "recvmsg failed\n");
+		if (ret)
+			VHOST_LOG_CONFIG(ERR, "recvmsg failed\n");
 		return ret;
 	}