Skip to contentSkip to conversation

rte_vhost: do not treat empty socket message as error

PATCH Applied Vitaliy Mysak 3 participants 3 messages Jan 30, 2020 – Feb 5, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rte_vhost: do not treat empty socket message as error

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.

---
 lib/librte_vhost/socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/librte_vhost/socket.c +2 -1
index 9740fb340..0cac3ce8e 100644
@@ -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;
 	}
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw

[PATCH] rte_vhost: do not treat empty socket message as error

s/rte_vhost:/vhost:/

Quoted 9 lines · Vitaliy Mysak

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")
Quoted 5 lines
---
 lib/librte_vhost/socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Thanks,
Tiwei

#2 lore raw
In reply to Vitaliy Mysak
Quoted 7 lines · Vitaliy Mysak

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.

Quoted 7 lines

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

---
 lib/librte_vhost/socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Applied to dpdk-next-virtio tree.

Thanks,
Maxime