Bug 277592

Summary: On machines without IPv6, ping uses IPv6
Product: Base System Reporter: ml
Component: binAssignee: Dag-Erling Smørgrav <des>
Status: Closed FIXED    
Severity: Affects Some People CC: des
Priority: --- Flags: des: mfc-stable14+
des: mfc-stable13+
Version: 13.3-RELEASE   
Hardware: Any   
OS: Any   
URL: https://reviews.freebsd.org/D44304

Description ml 2024-03-09 09:33:21 UTC
On a 13.3 machine with a kernel compiled without "options INET6":


> % host www.google.it
www.google.it has address 216.58.204.227
www.google.it has IPv6 address 2a00:1450:4002:415::2003
% ping www.google.it
ping: socket ssend: Address family not supported by protocol family
% ping -4 www.google.it
PING www.google.it (216.58.204.227): 56 data bytes
64 bytes from 216.58.204.227: icmp_seq=0 ttl=117 time=13.422 ms
64 bytes from 216.58.204.227: icmp_seq=1 ttl=117 time=15.746 ms
^C 

On every other release (including 13.2 and 14.0):
% host www.google.it
www.google.it has address 216.58.204.227
www.google.it has IPv6 address 2a00:1450:4002:415::2003
% ping www.google.it
PING www.google.it (216.58.204.227): 56 data bytes
64 bytes from 216.58.204.227: icmp_seq=0 ttl=117 time=19.679 ms
64 bytes from 216.58.204.227: icmp_seq=1 ttl=117 time=28.819 ms
^C

I tried with and without 'ipv6_activate_all_interfaces="NO"' in rc.conf.
Comment 1 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2024-03-11 14:27:45 UTC
What does `sysctl kern.features | grep inet` say?
Comment 2 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2024-03-11 14:56:11 UTC
Confirmed on stable/13
Comment 3 ml 2024-03-11 16:05:08 UTC
(In reply to Dag-Erling Smørgrav from comment #1)

# sysctl kern.features | grep inet
kern.features.inet: 1
Comment 4 ml 2024-03-11 16:10:44 UTC
I can confirm it works again after applying D44304.
Thanks a lot.
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-03-12 19:41:05 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=b53ae8a8333d730bb977276c511743b98c881423

commit b53ae8a8333d730bb977276c511743b98c881423
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-03-12 19:40:36 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-03-12 19:40:36 +0000

    ping: Fix protocol selection with NOINET6 kernel.

    A missing else caused the correct resolver hint (AF_INET) to be
    overwritten with AF_UNSPEC when the kernel supports IPv4 but not
    IPv6.

    MFC after:      3 days
    PR:             277592
    Sponsored by:   NetApp, Inc.
    Sponsored by:   Klara, Inc.
    Reviewed by:    allanjude
    Differential Revision:  https://reviews.freebsd.org/D44304

 sbin/ping/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-03-17 15:27:18 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4187a7dbbe793cffaef2399b42aa557f21aa750b

commit 4187a7dbbe793cffaef2399b42aa557f21aa750b
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-03-12 19:40:36 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-03-17 14:37:59 +0000

    ping: Fix protocol selection with NOINET6 kernel.

    A missing else caused the correct resolver hint (AF_INET) to be
    overwritten with AF_UNSPEC when the kernel supports IPv4 but not
    IPv6.

    MFC after:      3 days
    PR:             277592
    Sponsored by:   NetApp, Inc.
    Sponsored by:   Klara, Inc.
    Reviewed by:    allanjude
    Differential Revision:  https://reviews.freebsd.org/D44304

    (cherry picked from commit b53ae8a8333d730bb977276c511743b98c881423)

 sbin/ping/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-03-17 15:27:20 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=c3f4736f049cc469f081a5879097e391a56c728b

commit c3f4736f049cc469f081a5879097e391a56c728b
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-03-12 19:40:36 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-03-17 14:38:12 +0000

    ping: Fix protocol selection with NOINET6 kernel.

    A missing else caused the correct resolver hint (AF_INET) to be
    overwritten with AF_UNSPEC when the kernel supports IPv4 but not
    IPv6.

    MFC after:      3 days
    PR:             277592
    Sponsored by:   NetApp, Inc.
    Sponsored by:   Klara, Inc.
    Reviewed by:    allanjude
    Differential Revision:  https://reviews.freebsd.org/D44304

    (cherry picked from commit b53ae8a8333d730bb977276c511743b98c881423)

 sbin/ping/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)