Skip to content

Commit

Permalink
arping: Optimize loop checking
Browse files Browse the repository at this point in the history
4db1de6 introduced regression for -A and -U, which behave like -c1
(.i.e. sending only single packet). Fixing it to compare also count
(as it was done in 67e070d before the rewrite).

Also, ctl->unsolicited does not change, therefore it's enough be checked
only once (before while loop).

Fixes: 4db1de6 ("arping: Fix 1s delay on exit for unsolicited arpings")
Reported-by: David Bond <dbond@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
pevik committed May 24, 2024
1 parent 4db1de6 commit ab08333
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,7 +776,10 @@ static int event_loop(struct run_state *ctl)
pfds[POLLFD_SOCKET].events = POLLIN | POLLERR | POLLHUP;
send_pack(ctl);

while (!(exit_loop || ctl->unsolicited)) {
if ((ctl->sent == ctl->count) && ctl->unsolicited)
goto exit;

while (!exit_loop) {
int ret;
size_t i;

Expand Down Expand Up @@ -840,6 +843,7 @@ static int event_loop(struct run_state *ctl)
}
}
}
exit:
close(sfd);
close(tfd);
freeifaddrs(ctl->ifa0);
Expand Down

0 comments on commit ab08333

Please sign in to comment.