From a760ddd03db4801f566cd4780f3be47bcfaab2bf Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Wed, 28 Aug 2024 13:19:28 +0200 Subject: [PATCH] arping: exit 0 if running in deadline mode and we see replies Resolves: RHEL-27718 --- 004-arping-fix-typo-in-error-checking.patch | 33 ++++++++++ ...-running-in-deadline-mode-and-we-see.patch | 62 +++++++++++++++++++ iputils.spec | 5 +- 3 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 004-arping-fix-typo-in-error-checking.patch create mode 100644 005-arping-exit-0-if-running-in-deadline-mode-and-we-see.patch diff --git a/004-arping-fix-typo-in-error-checking.patch b/004-arping-fix-typo-in-error-checking.patch new file mode 100644 index 0000000..58a6755 --- /dev/null +++ b/004-arping-fix-typo-in-error-checking.patch @@ -0,0 +1,33 @@ +From 357b788e667bdd51b66bbc0cc88cf82ae3169455 Mon Sep 17 00:00:00 2001 +From: Noah Meyerhans +Date: Wed, 16 Feb 2022 22:25:30 -0800 +Subject: [PATCH 1/2] arping: fix typo in error checking + +When attempting to check the return value of timerfd_create(), we were +not checking the value of the variable containing the return value. + +Fixes: e594ca5 ("arping: use additional timerfd to control when timeout happens") + +Reviewed-by: Petr Vorel +Signed-off-by: Noah Meyerhans +(cherry picked from commit 8a6a2ce3cd0cdf69f0551a3a1e598a191561d18e) +--- + arping.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arping.c b/arping.c +index ee9da1d..8059517 100644 +--- a/arping.c ++++ b/arping.c +@@ -733,7 +733,7 @@ static int event_loop(struct run_state *ctl) + + /* timeout timerfd */ + timeoutfd = timerfd_create(CLOCK_MONOTONIC, 0); +- if (tfd == -1) { ++ if (timeoutfd == -1) { + error(0, errno, "timerfd_create failed"); + return 1; + } +-- +2.46.0 + diff --git a/005-arping-exit-0-if-running-in-deadline-mode-and-we-see.patch b/005-arping-exit-0-if-running-in-deadline-mode-and-we-see.patch new file mode 100644 index 0000000..8fe2ba9 --- /dev/null +++ b/005-arping-exit-0-if-running-in-deadline-mode-and-we-see.patch @@ -0,0 +1,62 @@ +From bf2900d716397734136ec3014a591281504aa00b Mon Sep 17 00:00:00 2001 +From: Noah Meyerhans +Date: Wed, 16 Feb 2022 22:27:49 -0800 +Subject: [PATCH 2/2] arping: exit 0 if running in deadline mode and we see + replies + +The arping behavior when running in deadline mode without a packet +count (-w without -c) should match that of ping: any replies indicate +that the host is up and should result in a zero (success) exit status. + +Fixes: https://github.com/iputils/iputils/issues/392 +Closes: https://github.com/iputils/iputils/pull/395 + +Reviewed-by: Petr Vorel +Signed-off-by: Noah Meyerhans +(cherry picked from commit 854873bdd28fcdd9cc3fe0c2d29c083a07d07a86) +--- + arping.c | 2 ++ + doc/arping.xml | 14 +++++++------- + 2 files changed, 9 insertions(+), 7 deletions(-) + +diff --git a/arping.c b/arping.c +index 8059517..6f94e90 100644 +--- a/arping.c ++++ b/arping.c +@@ -828,6 +828,8 @@ static int event_loop(struct run_state *ctl) + else if (ctl->dad && ctl->quit_on_reply) + /* Duplicate address detection mode return value */ + rc |= !(ctl->brd_sent != ctl->received); ++ else if (ctl->timeout && !(ctl->count > 0)) ++ rc |= !(ctl->received > 0); + else + rc |= (ctl->sent != ctl->received); + return rc; +diff --git a/doc/arping.xml b/doc/arping.xml +index 711718f..9adbc0c 100644 +--- a/doc/arping.xml ++++ b/doc/arping.xml +@@ -202,13 +202,13 @@ xml:id="man.arping"> + + Specify a timeout, in seconds, before + arping exits regardless of how many +- packets have been sent or received. In this case +- arping does not stop after +- count packet are sent, it +- waits either for +- deadline expire or until +- count probes are +- answered. ++ packets have been sent or received. If any replies are ++ received, exit with status 0, otherwise status 1. When ++ combined with the count ++ option, exit with status 0 if count replies are received before the ++ deadline expiration, otherwise status 1. ++ + + + +-- +2.46.0 + diff --git a/iputils.spec b/iputils.spec index 4c2910b..92791fc 100644 --- a/iputils.spec +++ b/iputils.spec @@ -22,6 +22,8 @@ Source5: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt Patch001: 001-ping-remove-unsupported-IPv6-warning-on-disabled-IPv6.patch Patch002: 002-arping-Fix-1s-delay-on-exit-for-unsolicited-arpings.patch Patch003: 003-arping-Fix-unsolicited-ARP-regressions-on-c-1.patch +Patch004: 004-arping-fix-typo-in-error-checking.patch +Patch005: 005-arping-exit-0-if-running-in-deadline-mode-and-we-see.patch # Downstream-only patches Patch100: 100-iputils-ifenslave.patch @@ -133,7 +135,8 @@ install -cp ifenslave.8 ${RPM_BUILD_ROOT}%{_mandir}/man8/ %changelog * Wed Aug 28 2024 Jan Macku - 20210202-10 -- arping: Fix 1s delay on exit for unsolicited arpings +- arping: Fix 1s delay on exit for unsolicited arpings (RHEL-34110) +- arping: exit 0 if running in deadline mode and we see replies (RHEL-27718) * Wed May 03 2023 Jan Macku - 20210202-9 - ping: Remove 'unsupported IPv6' warning on disabled IPv6 (rhbz#2152511)