ping: Remove 'unsupported IPv6' warning on disabled IPv6

Resolves: #2152511
This commit is contained in:
Jan Macku 2023-05-03 15:54:37 +02:00
parent 8d4b9abd63
commit 66fbfa457b
2 changed files with 60 additions and 5 deletions

View File

@ -0,0 +1,51 @@
From 79d713eab6181e219bf932b404706f6f59ff2539 Mon Sep 17 00:00:00 2001
From: Byron Stanoszek <gandalf@winds.org>
Date: Thu, 16 Sep 2021 23:38:54 +0200
Subject: [PATCH] ping: Remove 'unsupported IPv6' warning on disabled IPv6
Regression was introduced in d141cb6 as introduced condition
if ((errno == EAFNOSUPPORT && socktype == AF_INET6) || options & F_VERBOSE || requisite)
was wrong, it should have been:
if ((errno == EAFNOSUPPORT && family == AF_INET6 && requisite) || options & F_VERBOSE)
but bug was hidden as `family == AF_INET6' was always false until
otherwise correct fix 904cdb6 ("ping: AF_INET6 is address family not
socket type [lgtm scan]") propagated the error.
Tested on kernel booted with ipv6.disable=1 (disabling via sysctl, i.e.
sysctl -w net.ipv6.conf.all.disable_ipv6=1; sysctl -w net.ipv6.conf.default.disable_ipv6=1
does not trigger the issue as it exit with "socket: Address family not
supported by protocol" - errno EADDRNOTAVAIL).
Fixes: d141cb6 ("ping: work with older kernels that don't support ping sockets")
Closes: https://github.com/iputils/iputils/issues/293
Closes: https://github.com/iputils/iputils/pull/370
Reported-by: lekto <lekto@o2.pl>
Reviewed-by: Andrew Clayton <andrew@digital-domain.net>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Byron Stanoszek <gandalf@winds.org>
[ pvorel: create commit from Byron's patch on the issue, do analysis and wrote commit message ]
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
ping/ping.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ping/ping.c b/ping/ping.c
index 6fcb44f2..0655bf4a 100644
--- a/ping/ping.c
+++ b/ping/ping.c
@@ -150,8 +150,8 @@ static void create_socket(struct ping_rts *rts, socket_st *sock, int family,
/* Report error related to disabled IPv6 only when IPv6 also failed or in
* verbose mode. Report other errors always.
*/
- if ((errno == EAFNOSUPPORT && family == AF_INET6) ||
- rts->opt_verbose || requisite)
+ if ((errno == EAFNOSUPPORT && family == AF_INET6 && requisite) ||
+ rts->opt_verbose)
error(0, errno, "socket");
if (requisite)
exit(2);

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: 8%{?dist} Release: 9%{?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+
@ -18,6 +18,10 @@ Source3: ninfod.service
Source4: bsd.txt Source4: bsd.txt
Source5: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt Source5: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
# Upstream patches
Patch001: 001-ping-remove-unsupported-IPv6-warning-on-disabled-IPv6.patch
# Downstream-only patches
Patch100: 100-iputils-ifenslave.patch Patch100: 100-iputils-ifenslave.patch
Patch101: 101-iputils-ifenslave-CWE-170.patch Patch101: 101-iputils-ifenslave-CWE-170.patch
Patch102: 102-iputils-ifenslave-CWE-170-2.patch Patch102: 102-iputils-ifenslave-CWE-170-2.patch
@ -55,10 +59,7 @@ Queries.
%prep %prep
%setup -q -a 1 -n %{name}-%{version} %setup -q -a 1 -n %{name}-%{version}
cp %{SOURCE4} %{SOURCE5} . cp %{SOURCE4} %{SOURCE5} .
%autopatch -p1
%patch100 -p1
%patch101 -p1
%patch102 -p1
%build %build
%meson -DBUILD_TFTPD=false %meson -DBUILD_TFTPD=false
@ -129,6 +130,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 May 03 2023 Jan Macku <jamacku@redhat.com> - 20210202-9
- ping: Remove 'unsupported IPv6' warning on disabled IPv6 (rhbz#2152511)
* Fri Nov 25 2022 Jan Macku <jamacku@redhat.com> - 20210202-8 * Fri Nov 25 2022 Jan Macku <jamacku@redhat.com> - 20210202-8
- Build iputils and ifenslave with correct flags (rhbz#2144509) - Build iputils and ifenslave with correct flags (rhbz#2144509)