summaryrefslogtreecommitdiff
path: root/net-misc/iputils/files/iputils-20210722-fix-no-ipv6-ping.patch
blob: 61f9f5c03fd6dd56088f47e8e5936612347e9bb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
https://github.com/iputils/iputils/commit/79d713eab6181e219bf932b404706f6f59ff2539.patch
https://bugs.gentoo.org/818022

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>
--- 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);