From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id A6BE35A026B; Tue, 8 Nov 2022 09:54:19 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 2/2] tap: Return -EIO from tap_handler_passt() on inconsistent packet stream Date: Tue, 8 Nov 2022 09:54:19 +0100 Message-Id: <20221108085419.3220900-3-sbrivio@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221108085419.3220900-1-sbrivio@redhat.com> References: <20221108085419.3220900-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: FMWDFIY3KDNKMYANVTTWEHKNNZ3SW324 X-Message-ID-Hash: FMWDFIY3KDNKMYANVTTWEHKNNZ3SW324 X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: <> Archived-At: List-Archive: <> List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: While it's important to fail in that case, it makes little sense to fail quietly: it's better to tell qemu explicitly that something went wrong and that we won't recover, by closing the socket. Signed-off-by: Stefano Brivio --- tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tap.c b/tap.c index 11ac732..abeff25 100644 --- a/tap.c +++ b/tap.c @@ -757,7 +757,7 @@ redo: rem = recv(c->fd_tap, p + n, (ssize_t)sizeof(uint32_t) - n, 0); if ((n += rem) != (ssize_t)sizeof(uint32_t)) - return 0; + return -EIO; } len = ntohl(*(uint32_t *)p); @@ -771,7 +771,7 @@ redo: if (len > n) { rem = recv(c->fd_tap, p + n, len - n, 0); if ((n += rem) != len) - return 0; + return -EIO; } /* Complete the partial read above before discarding a malformed -- 2.35.1