FreeBSD Bugzilla – Attachment 221094 Details for
Bug 251725
sbin/ping: tries to use IPv6 on INET6-less kernels
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix ping when the kernel lacks INET6 support
pr251725.diff (text/plain), 1.75 KB, created by
Alan Somers
on 2020-12-29 22:31:06 UTC
(
hide
)
Description:
Fix ping when the kernel lacks INET6 support
Filename:
MIME Type:
Creator:
Alan Somers
Created:
2020-12-29 22:31:06 UTC
Size:
1.75 KB
patch
obsolete
>commit bff952809489fc09971fd79b3ab3f820ed21fb9b >Author: Alan Somers <asomers@gmail.com> >Date: Tue Dec 29 15:26:08 2020 -0700 > > 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: TODO > MFC with: 368045 > >diff --git a/sbin/ping/main.c b/sbin/ping/main.c >index 5d28a2b4a5cd..62840606e45f 100644 >--- a/sbin/ping/main.c >+++ b/sbin/ping/main.c >@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); > > #include <sys/types.h> > #include <sys/socket.h> >+#include <sys/sysctl.h> > > #include <arpa/inet.h> > #include <netdb.h> >@@ -126,15 +127,31 @@ main(int argc, char *argv[]) > else if (ipv4) > hints.ai_family = AF_INET; > else { >- struct addrinfo *res; >- >- memset(&hints, 0, sizeof(hints)); >- hints.ai_socktype = SOCK_RAW; >- hints.ai_family = AF_UNSPEC; >- getaddrinfo(argv[argc - 1], NULL, &hints, &res); >- if (res != NULL) { >- hints.ai_family = res[0].ai_family; >- freeaddrinfo(res); >+ int inet_enabled = 0; >+ int inet6_enabled = 0; >+ size_t len = sizeof(int); >+ >+ /* Ignore sysctlbyname errors */ >+ sysctlbyname("kern.features.inet", &inet_enabled, &len, >+ NULL, 0); >+ sysctlbyname("kern.features.inet6", &inet6_enabled, &len, >+ NULL, 0); >+ >+ if (!inet6_enabled) >+ hints.ai_family = AF_INET; >+ else if (!inet_enabled) >+ hints.ai_family = AF_INET6; >+ else { >+ struct addrinfo *res; >+ >+ memset(&hints, 0, sizeof(hints)); >+ hints.ai_socktype = SOCK_RAW; >+ hints.ai_family = AF_UNSPEC; >+ getaddrinfo(argv[argc - 1], NULL, &hints, &res); >+ if (res != NULL) { >+ hints.ai_family = res[0].ai_family; >+ freeaddrinfo(res); >+ } > } > } > #elif defined(INET)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 251725
:
221094
|
221097