Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Dec 2012 20:32:05 -0600
From:      Mike Karels <mike@karels.net>
To:        Gleb Smirnoff <glebius@freebsd.org>
Cc:        freebsd-net@freebsd.org, Kevin Lo <kevlo@kevlo.org>
Subject:   Re: Review request: fix return value of socket(2) on no family found
Message-ID:  <201212070232.qB72W5ji039704@mail.karels.net>
In-Reply-To: Your message of Thu, 06 Dec 2012 20:48:49 %2B0400. <20121206164849.GE48639@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> On Thu, Dec 06, 2012 at 02:39:11PM +0800, Kevin Lo wrote:
> K> Here's the patch mostly from NetBSD to make socket(2) return EAFNOSUPPORT
> K> rather than EPROTONOSUPPORT if the family cannot be found.
> K> 
> K> http://people.freebsd.org/~kevlo/patch-socket
> K> 
> K> The man page documents the behavior specified in POSIX.1-2008:
> K> 
> K> http://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html
> K> 
> K> For reference, Linux, NetBSD, and OS X return EAFNOSUPPORT for this.

> IMO, the proposed change is correct.

I'd have to disagree.  EAFNOSUPPORT means "Address family not supported by
protocol family".  However, the socket syscall does not take an address
family parameter.  It takes a protocol family, a socket type, and an
optional protocol.  EPFNOSUPPORT would be the correct error if the protocol
family is not supported.  I don't remember if I missed this when POSIX
was being balloted, or if my objection was unsuccessful.

That said, I will say that consistency across systems and with the standard
is a useful thing, so I'll reluctantly agree with the change to the errno.

However, the proposed text for socket(2) doesn't make sense:

+The address family (domain) is not supported or the
+specified domain is not supported by this protocol family.

The domain is the protocol family.  This could reasonably say just
"The protocol family (domain) is not supported."  It might further
say "This specific error value may not be accurate, but is specified
by POSIX.1-2008."

		Mike



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212070232.qB72W5ji039704>