aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-03-30 05:45:23 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-03-30 05:50:17 +0200
commit8fd20ad99d24a517fa1771e1863f51a32d2fe8a4 (patch)
treed7807c04b3bf75fc4caebced39001eabaced01ed
parent8d85b6a99ebf02a65a097ac3f5cdb83cd4119bd5 (diff)
downloadpasst-8fd20ad99d24a517fa1771e1863f51a32d2fe8a4.tar
passt-8fd20ad99d24a517fa1771e1863f51a32d2fe8a4.tar.gz
passt-8fd20ad99d24a517fa1771e1863f51a32d2fe8a4.tar.bz2
passt-8fd20ad99d24a517fa1771e1863f51a32d2fe8a4.tar.lz
passt-8fd20ad99d24a517fa1771e1863f51a32d2fe8a4.tar.xz
passt-8fd20ad99d24a517fa1771e1863f51a32d2fe8a4.tar.zst
passt-8fd20ad99d24a517fa1771e1863f51a32d2fe8a4.zip
tap: Re-read from tap in tap_handler_pasta() on buffer full
read() will return zero if we pass a zero length, which makes no sense: instead, track explicitly that we exhausted the buffer, flush packets to handlers and redo. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--tap.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tap.c b/tap.c
index f6de5f1..f8222a2 100644
--- a/tap.c
+++ b/tap.c
@@ -713,9 +713,12 @@ next:
*/
static int tap_handler_pasta(struct ctx *c, const struct timespec *now)
{
- ssize_t n = 0, len;
+ ssize_t n, len;
int ret;
+redo:
+ n = 0;
+
pool_flush(pool_tap4);
pool_flush(pool_tap6);
restart:
@@ -746,7 +749,8 @@ restart:
break;
}
- n += len;
+ if ((n += len) == TAP_BUF_BYTES)
+ break;
}
if (len < 0 && errno == EINTR)
@@ -760,6 +764,9 @@ restart:
if (len > 0 || ret == EAGAIN)
return 0;
+ if (n == TAP_BUF_BYTES)
+ goto redo;
+
epoll_ctl(c->epollfd, EPOLL_CTL_DEL, c->fd_tap, NULL);
close(c->fd_tap);