tap: Return -EIO from tap_handler_passt() on inconsistent packet stream

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 <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2022-11-08 09:08:32 +01:00
parent 510dace86c
commit 198f87835d

4
tap.c
View file

@ -757,7 +757,7 @@ redo:
rem = recv(c->fd_tap, p + n, rem = recv(c->fd_tap, p + n,
(ssize_t)sizeof(uint32_t) - n, 0); (ssize_t)sizeof(uint32_t) - n, 0);
if ((n += rem) != (ssize_t)sizeof(uint32_t)) if ((n += rem) != (ssize_t)sizeof(uint32_t))
return 0; return -EIO;
} }
len = ntohl(*(uint32_t *)p); len = ntohl(*(uint32_t *)p);
@ -771,7 +771,7 @@ redo:
if (len > n) { if (len > n) {
rem = recv(c->fd_tap, p + n, len - n, 0); rem = recv(c->fd_tap, p + n, len - n, 0);
if ((n += rem) != len) if ((n += rem) != len)
return 0; return -EIO;
} }
/* Complete the partial read above before discarding a malformed /* Complete the partial read above before discarding a malformed