arping: Fix 1s delay on exit for unsolicited arpings

Resolves: RHEL-34110
This commit is contained in:
Jan Macku 2024-08-28 13:06:49 +02:00
parent 66fbfa457b
commit a59c87b700
4 changed files with 109 additions and 21 deletions

22
.gitignore vendored
View File

@ -1,21 +1,3 @@
iputils-s20100418.tar.bz2
ifenslave.tar.gz
/iputils-s20101006.tar.bz2
/ifenslave.tar.gz /ifenslave.tar.gz
/iputils-s20121011.tar.bz2 /iputils-*
/iputils-s20121106.tar.bz2
/iputils-s20121112.tar.bz2
/iputils-s20121121.tar.bz2
/iputils-s20121125.tar.bz2
/iputils-s20121205.tar.bz2
/iputils-s20121207.tar.bz2
/iputils-s20121221.tar.bz2
/iputils-s20140519.tar.gz
/iputils-s20150815.tar.gz
/iputils-s20160308.tar.gz
/iputils-s20161105.tar.gz
/iputils-s20180629.tar.gz
/iputils-s20190324.tar.gz
/iputils-s20190515.tar.gz
/iputils-s20200821.tar.gz
/iputils-20210202.tar.gz

View File

@ -0,0 +1,40 @@
From a1890739e9d5953897cec43c59d5fea922384d5b Mon Sep 17 00:00:00 2001
From: Petr Vorel <pvorel@suse.cz>
Date: Wed, 22 May 2024 07:05:14 +0200
Subject: [PATCH 1/2] arping: Fix 1s delay on exit for unsolicited arpings
Commit 67e070d introduced 1s poll() delay for unsolicited arpings,
when using -U or -A, e.g.:
# arping -A -c1 -I eth0 [IP address of eth0 interface]
# arping -U -c1 -I eth0 [IP address of eth0 interface]
Restore correct condition.
Fixes: 67e070d ("arping: use signalfd() and timerfd() rather than signals")
Fixes: https://github.com/iputils/iputils/issues/536
Closes: https://github.com/iputils/iputils/pull/541
Reported-by: <Curtis Taylor cjebpub@gmail.com>
Suggested-by: <Curtis Taylor cjebpub@gmail.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
(cherry picked from commit 4db1de672559804bebcb7073d231924339ca8cd8)
---
arping.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arping.c b/arping.c
index 53fdbb4..8929f8f 100644
--- a/arping.c
+++ b/arping.c
@@ -749,7 +749,7 @@ static int event_loop(struct run_state *ctl)
pfds[POLLFD_SOCKET].events = POLLIN | POLLERR | POLLHUP;
send_pack(ctl);
- while (!exit_loop) {
+ while (!(exit_loop || ctl->unsolicited)) {
int ret;
size_t i;
--
2.46.0

View File

@ -0,0 +1,61 @@
From 5564dd9f224a7354a55c8f57ac0da9c2e58b18e5 Mon Sep 17 00:00:00 2001
From: Petr Vorel <pvorel@suse.cz>
Date: Fri, 24 May 2024 00:05:53 +0200
Subject: [PATCH 2/2] arping: Fix unsolicited ARP regressions on -c > 1
4db1de6 tried to fix a regression 1 sec delay due poll() for unsolicited
ARP, .i.e. -A and -U (introduced in 67e070d, reported as issue #536).
But skipping the while loop entirely introduced another regression for
-A and -U, which behave like -c1 (sending *always* only a single packet).
Fixing it by checking in while loop and comparing also count (as it was
done in 67e070d before the rewrite).
NOTE: use exit_loop with continue instead of simple break to keep things
consistent.
Fixes: 4db1de6 ("arping: Fix 1s delay on exit for unsolicited arpings")
Fixes: 67e070d ("arping: use signalfd() and timerfd() rather than signals")
Fixes: https://github.com/iputils/iputils/issues/536
Closes: https://github.com/iputils/iputils/pull/543
Reported-by: David Bond <dbond@suse.com>
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
(cherry picked from commit 5de892d15eea467775420c4fd641df229f024259)
---
arping.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/arping.c b/arping.c
index 8929f8f..ee9da1d 100644
--- a/arping.c
+++ b/arping.c
@@ -749,10 +749,15 @@ static int event_loop(struct run_state *ctl)
pfds[POLLFD_SOCKET].events = POLLIN | POLLERR | POLLHUP;
send_pack(ctl);
- while (!(exit_loop || ctl->unsolicited)) {
+ while (!exit_loop) {
int ret;
size_t i;
+ if ((ctl->sent == ctl->count) && ctl->unsolicited) {
+ exit_loop = 1;
+ continue;
+ }
+
ret = poll(pfds, POLLFD_COUNT, -1);
if (ret <= 0) {
if (errno == EAGAIN)
@@ -813,6 +818,7 @@ static int event_loop(struct run_state *ctl)
}
}
}
+
close(sfd);
close(tfd);
freeifaddrs(ctl->ifa0);
--
2.46.0

View File

@ -3,7 +3,7 @@
Summary: Network monitoring tools including ping Summary: Network monitoring tools including ping
Name: iputils Name: iputils
Version: 20210202 Version: 20210202
Release: 9%{?dist} Release: 10%{?dist}
# some parts are under the original BSD (ping.c) # some parts are under the original BSD (ping.c)
# some are under GPLv2+ (tracepath.c) # some are under GPLv2+ (tracepath.c)
License: BSD and GPLv2+ License: BSD and GPLv2+
@ -20,6 +20,8 @@ Source5: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
# Upstream patches # Upstream patches
Patch001: 001-ping-remove-unsupported-IPv6-warning-on-disabled-IPv6.patch 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
# Downstream-only patches # Downstream-only patches
Patch100: 100-iputils-ifenslave.patch Patch100: 100-iputils-ifenslave.patch
@ -130,6 +132,9 @@ install -cp ifenslave.8 ${RPM_BUILD_ROOT}%{_mandir}/man8/
%attr(644,root,root) %{_mandir}/man8/ninfod.8.gz %attr(644,root,root) %{_mandir}/man8/ninfod.8.gz
%changelog %changelog
* Wed Aug 28 2024 Jan Macku <jamacku@redhat.com> - 20210202-10
- arping: Fix 1s delay on exit for unsolicited arpings
* Wed May 03 2023 Jan Macku <jamacku@redhat.com> - 20210202-9 * Wed May 03 2023 Jan Macku <jamacku@redhat.com> - 20210202-9
- ping: Remove 'unsupported IPv6' warning on disabled IPv6 (rhbz#2152511) - ping: Remove 'unsupported IPv6' warning on disabled IPv6 (rhbz#2152511)