From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH] tap: Revert recently added checks in tap_handler_passt()
Date: Wed, 16 Nov 2022 14:53:26 +0100 [thread overview]
Message-ID: <20221116135326.247953-1-sbrivio@redhat.com> (raw)
This reverts commit 198f87835dc4 ("tap: Return -EIO from
tap_handler_passt() on inconsistent packet stream") and commit
510dace86ccf ("tap: Keep stream consistent if qemu length descriptor
spans two recv() calls").
I can hit occasional failures in perf/passt_tcp tests where we seem
to be getting excess data at the end of a recv(), and for some reason
I couldn't figure out yet, if we just ignore it, subsequent recv()
calls from qemu return correct data. If we close the connection, qemu
can't talk to us anymore, of course.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
tap.c | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/tap.c b/tap.c
index b7ac996..d26af58 100644
--- a/tap.c
+++ b/tap.c
@@ -747,31 +747,19 @@ redo:
return -ECONNRESET;
}
- while (n > 0) {
- ssize_t len;
-
- /* Force receiving at least a complete length descriptor to
- * avoid an inconsistent stream.
- */
- if (n < (ssize_t)sizeof(uint32_t)) {
- rem = recv(c->fd_tap, p + n,
- (ssize_t)sizeof(uint32_t) - n, 0);
- if ((n += rem) != (ssize_t)sizeof(uint32_t))
- return -EIO;
- }
-
- len = ntohl(*(uint32_t *)p);
+ while (n > (ssize_t)sizeof(uint32_t)) {
+ ssize_t len = ntohl(*(uint32_t *)p);
p += sizeof(uint32_t);
n -= sizeof(uint32_t);
/* At most one packet might not fit in a single read, and this
- * also needs to be blocking.
+ * needs to be blocking.
*/
if (len > n) {
rem = recv(c->fd_tap, p + n, len - n, 0);
if ((n += rem) != len)
- return -EIO;
+ return 0;
}
/* Complete the partial read above before discarding a malformed
--
@@ -747,31 +747,19 @@ redo:
return -ECONNRESET;
}
- while (n > 0) {
- ssize_t len;
-
- /* Force receiving at least a complete length descriptor to
- * avoid an inconsistent stream.
- */
- if (n < (ssize_t)sizeof(uint32_t)) {
- rem = recv(c->fd_tap, p + n,
- (ssize_t)sizeof(uint32_t) - n, 0);
- if ((n += rem) != (ssize_t)sizeof(uint32_t))
- return -EIO;
- }
-
- len = ntohl(*(uint32_t *)p);
+ while (n > (ssize_t)sizeof(uint32_t)) {
+ ssize_t len = ntohl(*(uint32_t *)p);
p += sizeof(uint32_t);
n -= sizeof(uint32_t);
/* At most one packet might not fit in a single read, and this
- * also needs to be blocking.
+ * needs to be blocking.
*/
if (len > n) {
rem = recv(c->fd_tap, p + n, len - n, 0);
if ((n += rem) != len)
- return -EIO;
+ return 0;
}
/* Complete the partial read above before discarding a malformed
--
2.35.1
reply other threads:[~2022-11-16 13:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221116135326.247953-1-sbrivio@redhat.com \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).