From 66fbfa457b97a146e6832073ed827cb5e535341c Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Wed, 3 May 2023 15:54:37 +0200 Subject: [PATCH] ping: Remove 'unsupported IPv6' warning on disabled IPv6 Resolves: #2152511 --- ...ported-IPv6-warning-on-disabled-IPv6.patch | 51 +++++++++++++++++++ iputils.spec | 14 +++-- 2 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 001-ping-remove-unsupported-IPv6-warning-on-disabled-IPv6.patch diff --git a/001-ping-remove-unsupported-IPv6-warning-on-disabled-IPv6.patch b/001-ping-remove-unsupported-IPv6-warning-on-disabled-IPv6.patch new file mode 100644 index 0000000..486acdc --- /dev/null +++ b/001-ping-remove-unsupported-IPv6-warning-on-disabled-IPv6.patch @@ -0,0 +1,51 @@ +From 79d713eab6181e219bf932b404706f6f59ff2539 Mon Sep 17 00:00:00 2001 +From: Byron Stanoszek +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 +Reviewed-by: Andrew Clayton +Reviewed-by: Petr Vorel +Signed-off-by: Byron Stanoszek +[ pvorel: create commit from Byron's patch on the issue, do analysis and wrote commit message ] +Signed-off-by: Petr Vorel +--- + 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); diff --git a/iputils.spec b/iputils.spec index eb9dd86..f41dad4 100644 --- a/iputils.spec +++ b/iputils.spec @@ -3,7 +3,7 @@ Summary: Network monitoring tools including ping Name: iputils Version: 20210202 -Release: 8%{?dist} +Release: 9%{?dist} # some parts are under the original BSD (ping.c) # some are under GPLv2+ (tracepath.c) License: BSD and GPLv2+ @@ -18,6 +18,10 @@ Source3: ninfod.service Source4: bsd.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 Patch101: 101-iputils-ifenslave-CWE-170.patch Patch102: 102-iputils-ifenslave-CWE-170-2.patch @@ -55,10 +59,7 @@ Queries. %prep %setup -q -a 1 -n %{name}-%{version} cp %{SOURCE4} %{SOURCE5} . - -%patch100 -p1 -%patch101 -p1 -%patch102 -p1 +%autopatch -p1 %build %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 %changelog +* Wed May 03 2023 Jan Macku - 20210202-9 +- ping: Remove 'unsupported IPv6' warning on disabled IPv6 (rhbz#2152511) + * Fri Nov 25 2022 Jan Macku - 20210202-8 - Build iputils and ifenslave with correct flags (rhbz#2144509)