!35 fix arping -w command return error
From: @xinghe_1 Reviewed-by: @zengwefeng Signed-off-by: @zengwefeng
This commit is contained in:
commit
be4d6c9479
@ -0,0 +1,60 @@
|
||||
From 854873bdd28fcdd9cc3fe0c2d29c083a07d07a86 Mon Sep 17 00:00:00 2001
|
||||
From: Noah Meyerhans <noahm@debian.org>
|
||||
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 <petr.vorel@gmail.com>
|
||||
Signed-off-by: Noah Meyerhans <noahm@debian.org>
|
||||
---
|
||||
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">
|
||||
<listitem>
|
||||
<para>Specify a timeout, in seconds, before
|
||||
<command>arping</command> exits regardless of how many
|
||||
- packets have been sent or received. In this case
|
||||
- <command>arping</command> does not stop after
|
||||
- <emphasis remap='I'>count</emphasis> packet are sent, it
|
||||
- waits either for
|
||||
- <emphasis remap='I'>deadline</emphasis> expire or until
|
||||
- <emphasis remap='I'>count</emphasis> probes are
|
||||
- answered.</para>
|
||||
+ packets have been sent or received. If any replies are
|
||||
+ received, exit with status 0, otherwise status 1. When
|
||||
+ combined with the <emphasis remap="I">count</emphasis>
|
||||
+ option, exit with status 0 if <emphasis
|
||||
+ remap="I">count</emphasis> replies are received before the
|
||||
+ deadline expiration, otherwise status 1.
|
||||
+ </para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
--
|
||||
2.27.0
|
||||
|
||||
32
backport-arping-fix-typo-in-error-checking.patch
Normal file
32
backport-arping-fix-typo-in-error-checking.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 8a6a2ce3cd0cdf69f0551a3a1e598a191561d18e Mon Sep 17 00:00:00 2001
|
||||
From: Noah Meyerhans <noahm@debian.org>
|
||||
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 <petr.vorel@gmail.com>
|
||||
Signed-off-by: Noah Meyerhans <noahm@debian.org>
|
||||
---
|
||||
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
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
From b94cd579083660bffa0e7d3c45ea0c1a4e8adaec Mon Sep 17 00:00:00 2001
|
||||
From: liuzhikang <liuzhikang3@huawei.com>
|
||||
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
|
||||
|
||||
Binary file not shown.
14
iputils.spec
14
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,13 @@ install -cp ifenslave.8 ${RPM_BUILD_ROOT}%{_mandir}/man8/
|
||||
%{_unitdir}/ninfod.service
|
||||
|
||||
%changelog
|
||||
* Fri Feb 18 2021 xinghe <xinghe2@h-partners.com> - 20210722-2
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:fix arping -w command return error
|
||||
remove old tar package
|
||||
|
||||
* Tue Dec 07 2021 xihaochen <xihaochen@huawei.com> - 20210722-1
|
||||
- Type:requirements
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user