diff --git a/backport-arping-exit-0-if-running-in-deadline-mode-and-we-see-replies.patch b/backport-arping-exit-0-if-running-in-deadline-mode-and-we-see-replies.patch new file mode 100644 index 0000000000000000000000000000000000000000..1cd8cb0221e48c9684d8ca38a3ba39d19220e81d --- /dev/null +++ b/backport-arping-exit-0-if-running-in-deadline-mode-and-we-see-replies.patch @@ -0,0 +1,60 @@ +From 854873bdd28fcdd9cc3fe0c2d29c083a07d07a86 Mon Sep 17 00:00:00 2001 +From: Noah Meyerhans +Date: Wed, 16 Feb 2022 22:27:49 -0800 +Subject: [PATCH] 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 +--- + arping.c | 2 ++ + doc/arping.xml | 14 +++++++------- + 2 files changed, 9 insertions(+), 7 deletions(-) + +diff --git a/arping.c b/arping.c +index efe3f53..c41ec74 100644 +--- a/arping.c ++++ b/arping.c +@@ -822,6 +822,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.27.0 + diff --git a/backport-arping-fix-typo-in-error-checking.patch b/backport-arping-fix-typo-in-error-checking.patch new file mode 100644 index 0000000000000000000000000000000000000000..dc4a74c5a071d06ca3d4e39aecbbd0720d11db82 --- /dev/null +++ b/backport-arping-fix-typo-in-error-checking.patch @@ -0,0 +1,32 @@ +From 8a6a2ce3cd0cdf69f0551a3a1e598a191561d18e Mon Sep 17 00:00:00 2001 +From: Noah Meyerhans +Date: Wed, 16 Feb 2022 22:25:30 -0800 +Subject: [PATCH] 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 +--- + arping.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arping.c b/arping.c +index 53fdbb4..efe3f53 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.27.0 + diff --git a/bugfix-arping-w-does-not-take-effect.patch b/bugfix-arping-w-does-not-take-effect.patch deleted file mode 100644 index 963e323c933ef952b87b602d96196963da618afd..0000000000000000000000000000000000000000 --- a/bugfix-arping-w-does-not-take-effect.patch +++ /dev/null @@ -1,45 +0,0 @@ -From b94cd579083660bffa0e7d3c45ea0c1a4e8adaec Mon Sep 17 00:00:00 2001 -From: liuzhikang -Date: Wed, 11 Mar 2020 17:52:29 +0800 -Subject: [PATCH] arping -w does not take effect - ---- - arping.c | 11 ++++++++--- - 1 file changed, 8 insertions(+), 3 deletions(-) - -diff --git a/arping.c b/arping.c -index a002786..36986e8 100644 ---- a/arping.c -+++ b/arping.c -@@ -694,7 +694,7 @@ static int event_loop(struct run_state *ctl) - .it_value.tv_sec = ctl->timeout, - .it_value.tv_nsec = 0 - }; -- uint64_t exp, total_expires = 1; -+ uint64_t exp, total_expires = 0; - - unsigned char packet[4096]; - struct sockaddr_storage from; -@@ -781,12 +781,17 @@ static int event_loop(struct run_state *ctl) - break; - case POLLFD_TIMER: - s = read(tfd, &exp, sizeof(uint64_t)); -+ total_expires++; - if (s != sizeof(uint64_t)) { - error(0, errno, "could not read timerfd"); -+ if (ctl->timeout > 0 && ((total_expires * ctl->interval) > (uint64_t)ctl->timeout)) { -+ exit_loop = 1; -+ } - continue; - } -- total_expires += exp; -- if (0 < ctl->count && (uint64_t)ctl->count < total_expires) { -+ if ((ctl->count > 0 && (total_expires >= (uint64_t)ctl->count)) || -+ (ctl->timeout > 0 && (total_expires * ctl->interval) > (uint64_t)ctl->timeout)|| -+ (ctl->quit_on_reply)) { - exit_loop = 1; - continue; - } --- -2.27.0 - diff --git a/iputils.spec b/iputils.spec index 03e054ced011d348762ac62748287d78683a31e4..70df2cce9e51e862cf4431f52080e78fce5e716b 100644 --- a/iputils.spec +++ b/iputils.spec @@ -1,6 +1,6 @@ Name: iputils Version: 20210722 -Release: 1 +Release: 2 Summary: Network monitoring tools including ping License: BSD and GPLv2+ URL: https://github.com/iputils/iputils @@ -13,8 +13,9 @@ Source4: bsd.txt Source5: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt Patch0000: iputils-ifenslave.patch -Patch0001: bugfix-arping-w-does-not-take-effect.patch -Patch0002: iputils-ifenslave-CWE-170.patch +Patch0001: iputils-ifenslave-CWE-170.patch +Patch0002: backport-arping-exit-0-if-running-in-deadline-mode-and-we-see-replies.patch +Patch0003: backport-arping-fix-typo-in-error-checking.patch BuildRequires: gcc meson libidn2-devel openssl-devel libcap-devel libxslt BuildRequires: docbook5-style-xsl systemd iproute glibc-kernheaders gettext @@ -113,6 +114,12 @@ install -cp ifenslave.8 ${RPM_BUILD_ROOT}%{_mandir}/man8/ %{_unitdir}/ninfod.service %changelog +* Fri Feb 18 2021 xinghe - 20210722-2 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:fix arping -w command return error + * Tue Dec 07 2021 xihaochen - 20210722-1 - Type:requirements - ID:NA