From 7913ad04c74f966f393463a1630e1b3171d77349 Mon Sep 17 00:00:00 2001 From: Petr Vorel Date: Fri, 24 May 2024 00:05:53 +0200 Subject: [PATCH] arping: Fix unsolicited ARP regressions on -c > 1 4db1de6 tried to fix a regression 1 sec delay due poll() for unsolicited ARP, .i.e. -A and -U (introduced in 67e070d, reported as issue #536). But skipping the while loop entirely introduced another regression for -A and -U, which behave like -c1 (sending *always* only a single packet). Fixing it by checking in while loop and comparing also count (as it was done in 67e070d before the rewrite). Fixes: 4db1de6 ("arping: Fix 1s delay on exit for unsolicited arpings") Fixes: 67e070d ("arping: use signalfd() and timerfd() rather than signals") Fixes: https://github.com/iputils/iputils/issues/536 Reported-by: David Bond Signed-off-by: Petr Vorel --- arping.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arping.c b/arping.c index c806999a..8a998876 100644 --- a/arping.c +++ b/arping.c @@ -776,10 +776,16 @@ static int event_loop(struct run_state *ctl) pfds[POLLFD_SOCKET].events = POLLIN | POLLERR | POLLHUP; send_pack(ctl); - while (!(exit_loop || ctl->unsolicited)) { + while (!exit_loop) { int ret; size_t i; + + if ((ctl->sent == ctl->count) && ctl->unsolicited) { + exit_loop = 1; + continue; + } + ret = poll(pfds, POLLFD_COUNT, -1); if (ret <= 0) { if (errno == EAGAIN) @@ -840,6 +846,7 @@ static int event_loop(struct run_state *ctl) } } } + close(sfd); close(tfd); freeifaddrs(ctl->ifa0);