mailing list of musl libc
 help / color / mirror / Atom feed
* [musl] [PATCH] handle linux-specific errors in getaddrinfo AI_ADDRCONFIG
@ 2021-04-30 17:56 Julian Squires
  0 siblings, 0 replies; only message in thread
From: Julian Squires @ 2021-04-30 17:56 UTC (permalink / raw)
  To: musl; +Cc: Julian Squires, Bob Richmond

linux allows adding ip rules with actions such as RTN_PROHIBIT or
RTN_BLACKHOLE to the loopback interface, e.g.:

  ip -6 rule add from all iif lo lookup unspec prohibit

if the loopback interface also has ipv6 disabled:

  sysctl net/ipv6/conf/lo/disable_ipv6=1

the connect() in getaddrinfo will return EACCES or EINVAL,
respectively, and getaddrinfo will erroneously return early.

this may sound like a perverse misconfiguration, but it happens easily
on openwrt systems where ipv6 has been disabled, as openwrt's netifd
by default sets up these rules (with a custom RTN_POLICY_FAILED
action, which behaves like RTN_PROHIBIT in this case).

Signed-off-by: Julian Squires <julian@cipht.net>
Co-authored-by: Bob Richmond <robert.richmond@greenwavesystems.com>
---
 src/network/getaddrinfo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c
index efaab306..9a9c3cbc 100644
--- a/src/network/getaddrinfo.c
+++ b/src/network/getaddrinfo.c
@@ -76,6 +76,8 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
 			case EHOSTUNREACH:
 			case ENETDOWN:
 			case ENETUNREACH:
+			case EACCES:
+			case EINVAL:
 				break;
 			default:
 				return EAI_SYSTEM;
-- 
2.31.1


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

only message in thread, other threads:[~2021-04-30 17:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-30 17:56 [musl] [PATCH] handle linux-specific errors in getaddrinfo AI_ADDRCONFIG Julian Squires

mailing list of musl libc

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/musl

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 musl musl/ https://inbox.vuxu.org/musl \
		musl@inbox.vuxu.org
	public-inbox-index musl

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/musl/

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