From 4a688662014439c1d14c12a83192612e60c0be9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Thu, 27 Jun 2019 14:17:26 +0000 Subject: [PATCH] Try to get all packets from mud MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- src/bind.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bind.c b/src/bind.c index a690b07..bcf6dee 100644 --- a/src/bind.c +++ b/src/bind.c @@ -314,11 +314,18 @@ gt_bind(int argc, char **argv) } } - if (FD_ISSET(mud_fd, &rfds)) { - const int r = mud_recv(mud, buf, sizeof(buf)); + if (FD_ISSET(mud_fd, &rfds)) { + int n = 1000; - if (r > 0 && ip_is_valid(buf, r)) - tun_write(tun_fd, buf, (size_t)r); + while (n--) { + const int r = mud_recv(mud, buf, sizeof(buf)); + + if (r <= 0) + break; + + if (ip_is_valid(buf, r)) + tun_write(tun_fd, buf, (size_t)r); + } } if (FD_ISSET(tun_fd, &rfds) && !mud_send_wait(mud)) {