mailing list of musl libc
 help / color / Atom feed
* getaddrinfo/AI_ADDRCONFIG with ipv6 disabled
@ 2019-12-05  2:44 Bob Richmond
  0 siblings, 0 replies; only message in thread
From: Bob Richmond @ 2019-12-05  2:44 UTC (permalink / raw)
  To: musl


[-- Attachment #1: Type: text/plain, Size: 1054 bytes --]

connect() to the IPv6 loopback address can fail with EACCES on Linux if 
IPv6 is disabled on the lo interface, and causes getaddrinfo to fail 
without returning IPv4 addresses. It should be treated as if IPv6 is 
disabled.

echo 1 >/proc/sys/net/ipv6/conf/lo/disable_ipv6

struct addrinfo hints, *res = NULL;
hints.ai_family = PF_UNSPEC;
hints.ai_flags = AI_ADDRCONFIG;
getaddrinfo("192.168.1.1", "80", &hints, &res);

strace:
======start=======
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP) = 14
connect(14, {sa_family=AF_INET, sin_port=htons(65535), 
sin_addr=inet_addr("127.0.0.1")}, 16) = 0
close(14)                         = 0 

socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP) = 14 

connect(14, {sa_family=AF_INET6, sin6_port=htons(65535), 
inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=htonl(0), 
sin6_scope_id=0}, 28) = -1 EACCES (Permission denied)
close(14)                         = 0
writev(2, [{iov_base="[warn] getaddrinfo: Permission denied\n", 
iov_len=38}, {iov_base=NULL, iov_len=0}], 2) = 38
======end=========

[-- Attachment #2: musl-getaddrinfo-ipv6-eacces.patch --]
[-- Type: text/x-patch, Size: 304 bytes --]

--- musl-1.1.24/src/network/getaddrinfo.c	2019-10-13 14:58:27.000000000 -0700
+++ musl-1.1.24/src/network/getaddrinfo.c	2019-12-04 14:52:11.003784091 -0800
@@ -76,6 +76,7 @@
 			case EHOSTUNREACH:
 			case ENETDOWN:
 			case ENETUNREACH:
+			case EACCES:
 				break;
 			default:
 				return EAI_SYSTEM;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-05  2:44 getaddrinfo/AI_ADDRCONFIG with ipv6 disabled Bob Richmond

mailing list of musl libc

Archives are clonable: git clone --mirror http://inbox.vuxu.org/musl

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git