Skip to content

Commit

Permalink
arping: Fix unsolicited ARP regressions on -c > 1
Browse files Browse the repository at this point in the history
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 iputils#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: iputils#536
Reported-by: David Bond <dbond@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
pevik committed May 27, 2024
1 parent 4db1de6 commit 7913ad0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion arping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -840,6 +846,7 @@ static int event_loop(struct run_state *ctl)
}
}
}

close(sfd);
close(tfd);
freeifaddrs(ctl->ifa0);
Expand Down

0 comments on commit 7913ad0

Please sign in to comment.