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>
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
pevik committed May 29, 2024
1 parent 4db1de6 commit c46adae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion arping.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,13 @@ 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)
break;

ret = poll(pfds, POLLFD_COUNT, -1);
if (ret <= 0) {
if (errno == EAGAIN)
Expand Down Expand Up @@ -840,6 +843,7 @@ static int event_loop(struct run_state *ctl)
}
}
}

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

0 comments on commit c46adae

Please sign in to comment.