From owner-freebsd-net@FreeBSD.ORG Fri Dec 21 12:37:29 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 E0572777; Fri, 21 Dec 2012 12:37:28 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-oa0-f50.google.com (mail-oa0-f50.google.com [209.85.219.50]) by mx1.freebsd.org (Postfix) with ESMTP id 4EF998FC12; Fri, 21 Dec 2012 12:37:28 +0000 (UTC) Received: by mail-oa0-f50.google.com with SMTP id n16so4553780oag.37 for ; Fri, 21 Dec 2012 04:37:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=sdqCRhAxEylcDHRuphrrew3ErGWTr0a/H9pMqaPCwAc=; b=FM/tLioAejYY6N1Jt/ly8YsSfL+peIrHeU7aSeF1GwuBjjZk1UgFKEm1UejOztQRE+ n2Xr78HMm2balCZNIKLHaoOx2BMT8xHk5Xkj5dTyyIyiaX4II4AiW0JryyvHaHmkE0qT n7Ddqv6nZbpmiwxuTvnBci4fY+YCA/Z5z40DjBY39QWosIyWFuLa4F5a4f3lokvNDamQ 9QXeT4BUsRR1VhdqYlh3CWArtai8lh54WdwocRRGrAfDAE1gmdmqm/8x4lQhwXKKs8+M Q++7BCrjAiQ6tQPTV7uwbinvRzoSS6vthnwKYkIjbgIr/66UWy1sbhueuIDzB1JGFR+c 9VjQ== MIME-Version: 1.0 Received: by 10.182.172.74 with SMTP id ba10mr10871591obc.83.1356093442291; Fri, 21 Dec 2012 04:37:22 -0800 (PST) Received: by 10.76.143.33 with HTTP; Fri, 21 Dec 2012 04:37:22 -0800 (PST) In-Reply-To: References: Date: Fri, 21 Dec 2012 04:37:22 -0800 Message-ID: Subject: Re: Broken error handling with AF_* and socket(2) [was Re: svn commit: r243965 - in head/sys: kern sys] From: Garrett Cooper To: Kevin Lo Content-Type: text/plain; charset=ISO-8859-1 Cc: src-committers@freebsd.org, freebsd-net@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, Rick Macklem X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Dec 2012 12:37:29 -0000 (Don't know why I hit reply instead of reply-all, but oh well... I had one more reply anyhow) On Fri, Dec 21, 2012 at 4:28 AM, Garrett Cooper wrote: > On Fri, Dec 21, 2012 at 4:11 AM, Garrett Cooper wrote: >> On Thu, Dec 6, 2012 at 6:22 PM, Kevin Lo wrote: >>> Author: kevlo >>> Date: Fri Dec 7 02:22:48 2012 >>> New Revision: 243965 >>> URL: http://svnweb.freebsd.org/changeset/base/243965 >>> >>> Log: >>> - according to POSIX, make socket(2) return EAFNOSUPPORT rather than >>> EPROTONOSUPPORT if the address family is not supported. >>> - introduce pffinddomain() to find a domain by family and use it as >>> appropriate. >>> >>> Reviewed by: glebius >> >> This commit broke netgraph (and potentially more things). I fixed >> netgraph locally like so: >> >> $ git diff lib/libnetgraph/ >> diff --git a/lib/libnetgraph/sock.c b/lib/libnetgraph/sock.c >> index fca3900..5f9f563 100644 >> --- a/lib/libnetgraph/sock.c >> +++ b/lib/libnetgraph/sock.c >> @@ -71,10 +71,10 @@ NgMkSockNode(const char *name, int *csp, int *dsp) >> name = NULL; >> >> /* Create control socket; this also creates the netgraph node. >> - If we get an EPROTONOSUPPORT then the socket node type is >> + If we get an EAFNOSUPPORT then the socket node type is >> not loaded, so load it and try again. */ >> if ((cs = socket(AF_NETGRAPH, SOCK_DGRAM, NG_CONTROL)) < 0) { >> - if (errno == EPROTONOSUPPORT) { >> + if (errno == EAFNOSUPPORT) { >> if (kldload(NG_SOCKET_KLD) < 0) { >> errnosv = errno; >> if (_gNgDebugLevel >= 1) >> >> Reproing the issue was trivial using the ether.bridge example >> script setup with appropriate interfaces. >> I have the patch with the netgraph fix attached, along with other >> potential fixes that needs to be more properly tested. > > usr.sbin/mountd/mountd.c > usr.sbin/rpcbind/rpcbind.c > usr.sbin/ypserv/yp_main.c > > might be broken as well because they're calling __rpc_nconf2fd, > which just wraps socket(2) underneath it all. > At this point it might be wise to consider doing something about > the ABI because the contract has been grossly changed enough that > things that tried to make sense of sockets with EPROTONOSUPPORT are > going to have issues now on FreeBSD [potentially] in either positive > or negative cases. My fix wasn't necessarily the right answer for netgraph, et al. It was just what I needed in order to get it to function with the new socket(2) API. Thanks, -Garrett