Subject: kern/33676: socket(2) returns incorrect errno if domain is not supported
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <uwe@NetBSD.org>
List: netbsd-bugs
Date: 06/09/2006 14:30:00
>Number: 33676
>Category: kern
>Synopsis: socket(2) returns incorrect errno if domain is not supported
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jun 09 14:30:00 +0000 2006
>Originator: Valeriy E. Ushakov
>Release: current as of 2006-06-09
>Organization:
>Environment:
>Description:
socket(2) incorrectly sets errno to EPROTONOSUPPORT
if the protocol family is not supported.
To quote http://www.fefe.de/libowfat/changes-0.23.txt
work around freebsd 5.4 brokenness (if you don't have IPv6 in the
kernel, socket(PF_INET6,SOCK_STREAM,0) returns EPROTONOSUPPORT
instead of EPFNOSUPPORT, which basically says "yeah, I know IPv6,
but TCP? never heard of it")
SUS says <http://www.opengroup.org/onlinepubs/007908799/xns/socket.html>
that socket(2) should return EAFNOSUPPORT in that case.
There's a complication in that POSIX doesn't have
PF_* values (it uses AF_* instead). We do have PF_*
so returning EPFNOSUPPORT would be a logical choice,
but as it's != EAFNOSUPPORT, it seems impossible to be
both posixly correct and internally consistent.
>How-To-Repeat:
Try to start in-tree postfix on a custom kernel w/out IPv6 support.
potfix is compiled with IPv6 support enabled, so it checks if IPv6
support is present in the kernel by creating a PF_INET6 socket
it expects EAFNOSUPPORT to indicate lack IPv6 support.
It gets EPROTONOSUPPORT instead and treats it as a fatal error.
>Fix: