Bug 251725 - sbin/ping: tries to use IPv6 on INET6-less kernels
Summary: sbin/ping: tries to use IPv6 on INET6-less kernels
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Alan Somers
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2020-12-10 12:10 UTC by Jan Beich
Modified: 2021-01-01 17:38 UTC (History)
1 user (show)

See Also:


Attachments
Fix ping when the kernel lacks INET6 support (1.75 KB, patch)
2020-12-29 22:31 UTC, Alan Somers
no flags Details | Diff
Fix ping when the kernel lacks INET6 support, v2 (1.45 KB, patch)
2020-12-30 02:35 UTC, Jan Beich
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2020-12-10 12:10:31 UTC
Regressed by base r368045. Affects "nooption INET6" in kernel config. Compared to other userland tools ping(8) seems to abort when a host has both IPv4 and IPv6 address(es) but one of those is not supported by running kernel.

$ ping localhost
ping: socket ssend: Address family not supported by protocol family

$ ping freebsd.org
ping: socket ssend: Address family not supported by protocol family

$ sysctl kern.conftxt  | fgrep INET
options INET

$ getaddrinfo localhost
dgram inet6 udp ::1 0
stream inet6 tcp ::1 0
seqpacket inet6 sctp ::1 0
dgram inet udp 127.0.0.1 0
stream inet tcp 127.0.0.1 0
seqpacket inet sctp 127.0.0.1 0

$ getaddrinfo freebsd.org
dgram inet6 udp 2610:1c1:1:606c::50:15 0
stream inet6 tcp 2610:1c1:1:606c::50:15 0
seqpacket inet6 sctp 2610:1c1:1:606c::50:15 0
dgram inet udp 96.47.72.84 0
stream inet tcp 96.47.72.84 0
seqpacket inet sctp 96.47.72.84 0

$ fetch http://freebsd.org
freebsd.org           24 kB   97 kBps    01s
Comment 1 Alan Somers freebsd_committer freebsd_triage 2020-12-10 13:54:03 UTC
Good catch.  I'll fix it.  In the meantime, you can use "ping -4"
Comment 2 Alan Somers freebsd_committer freebsd_triage 2020-12-29 22:31:06 UTC
Created attachment 221094 [details]
Fix ping when the kernel lacks INET6 support

jbeich, could you please review and test this patch?
Comment 3 Jan Beich freebsd_committer freebsd_triage 2020-12-30 02:35:44 UTC
Created attachment 221097 [details]
Fix ping when the kernel lacks INET6 support, v2

Please, use git-format-patch(1) to facilitate amending patches.

(In reply to Alan Somers from comment #2)
> review

Use feature_present(3) instead of poking kern.features.* directly. I don't know much about base/ style otherwise.

> test

Works for me.
Comment 4 Alan Somers freebsd_committer freebsd_triage 2021-01-01 17:25:35 UTC
Thanks for the feature_present change.  That does look better now.
Comment 5 commit-hook freebsd_committer freebsd_triage 2021-01-01 17:28:18 UTC
A commit in branch main references this bug:

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

commit b586c66baf4824d175d051b3f5b06588c9aa2bc8
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2021-01-01 17:25:49 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2021-01-01 17:25:49 +0000

    ping: fix ping when the kernel was built without INET6

    If the kernel was built without INET6, default to ICMP.  Or, if it was
    built without INET, default to ICMPv6.

    PR:             251725
    Reported by:    jbeich
    Reviewed by:    jbeich
    Tested by:      jbeich
    MFC with:       368045

 sbin/ping/main.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
Comment 6 Alan Somers freebsd_committer freebsd_triage 2021-01-01 17:38:37 UTC
Fixed.  No plans to MFC.