From owner-freebsd-net@FreeBSD.ORG Fri Dec 7 02:32:11 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 088B82B6; Fri, 7 Dec 2012 02:32:11 +0000 (UTC) (envelope-from mike@karels.net) Received: from mail.karels.net (unknown [IPv6:2001:470:c004:1::5]) by mx1.freebsd.org (Postfix) with ESMTP id BE7338FC0C; Fri, 7 Dec 2012 02:32:10 +0000 (UTC) Received: from mail.karels.net (localhost [127.0.0.1]) by mail.karels.net (8.14.5/8.14.5) with ESMTP id qB72W5ji039704; Thu, 6 Dec 2012 20:32:07 -0600 (CST) (envelope-from mike@karels.net) Message-Id: <201212070232.qB72W5ji039704@mail.karels.net> To: Gleb Smirnoff From: Mike Karels Subject: Re: Review request: fix return value of socket(2) on no family found In-reply-to: Your message of Thu, 06 Dec 2012 20:48:49 +0400. <20121206164849.GE48639@FreeBSD.org> Date: Thu, 06 Dec 2012 20:32:05 -0600 Cc: freebsd-net@freebsd.org, Kevin Lo X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: mike@karels.net List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Dec 2012 02:32:11 -0000 > 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