49 lines
1.7 KiB
Diff
49 lines
1.7 KiB
Diff
From 18f14be80466ddc8fb17a400be82764a779c8dcd Mon Sep 17 00:00:00 2001
|
|
From: Sami Kerola <kerolasa@iki.fi>
|
|
Date: Wed, 31 Jul 2019 21:28:12 +0100
|
|
Subject: [PATCH] arping: revert partially
|
|
- fix sent vs received packages return value
|
|
- fix arping's exit code for -U/A
|
|
|
|
Commit 84ca65ca980315c73f929fed8b6f16bbd698c3a0 caused regression. The
|
|
arping -D needs return value evaluation that was the earlier default, in
|
|
other cases the new return value should be correct.
|
|
|
|
Addresses1: https://github.com/iputils/iputils/issues/209
|
|
See-also1: https://github.com/void-linux/void-packages/issues/13304
|
|
Addresses2: https://github.com/iputils/iputils/issues/247
|
|
See-also2:https://github.com/iputils/iputils/commit/68f12fc4a0dbef4ae4c404da24040d22c5a14339
|
|
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
---
|
|
arping.c | 10 ++++++++--
|
|
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/arping.c b/arping.c
|
|
index 57114bb..78c8b86 100644
|
|
--- a/arping.c
|
|
+++ b/arping.c
|
|
@@ -797,7 +797,13 @@ static int event_loop(struct run_state *ctl)
|
|
close(tfd);
|
|
freeifaddrs(ctl->ifa0);
|
|
rc |= finish(ctl);
|
|
- rc |= (ctl->sent != ctl->received);
|
|
+ if (ctl->unsolicited)
|
|
+ /* nothing */;
|
|
+ else if (ctl->dad && ctl->quit_on_reply)
|
|
+ /* Duplicate address detection mode return value */
|
|
+ rc |= !(ctl->brd_sent != ctl->received);
|
|
+ else
|
|
+ rc |= (ctl->sent != ctl->received);
|
|
return rc;
|
|
}
|
|
|
|
@@ -942,7 +948,7 @@ int main(int argc, char **argv)
|
|
}
|
|
memset(&saddr, 0, sizeof(saddr));
|
|
saddr.sin_family = AF_INET;
|
|
- if (ctl.source || ctl.gsrc.s_addr) {
|
|
+ if (!ctl.unsolicited && (ctl.source || ctl.gsrc.s_addr)) {
|
|
saddr.sin_addr = ctl.gsrc;
|
|
if (bind(probe_fd, (struct sockaddr *)&saddr, sizeof(saddr)) == -1)
|
|
error(2, errno, "bind");
|