From owner-freebsd-net@FreeBSD.ORG Wed Sep 11 15:10:46 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 4931CC13 for ; Wed, 11 Sep 2013 15:10:46 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C88A12282 for ; Wed, 11 Sep 2013 15:10:45 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.7/8.14.7) with ESMTP id r8BFAhqs050959; Wed, 11 Sep 2013 19:10:43 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.7/8.14.7/Submit) id r8BFAgUg050958; Wed, 11 Sep 2013 19:10:42 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Wed, 11 Sep 2013 19:10:42 +0400 From: Gleb Smirnoff To: Yuri Subject: Re: LOCAL_CREDS are broken ? Message-ID: <20130911151042.GO4574@FreeBSD.org> References: <521F9789.5000903@rawbw.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <521F9789.5000903@rawbw.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-net@freebsd.org 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: Wed, 11 Sep 2013 15:10:46 -0000 On Thu, Aug 29, 2013 at 11:48:41AM -0700, Yuri wrote: Y> The example below breaks with "Protocol not available" Y> But what is wrong? Isn't this the correct usage? Y> LOCAL_CREDS are only handled in kern/uipc_usrreq.c for AF_LOCAL, so it Y> isn't clear why this doesn't work. Y> Y> --- example.c --- Y> #include Y> #include Y> #include Y> #include Y> #include Y> Y> main() { Y> int sock; Y> int error; Y> int oval = 1; Y> Y> error = socket(AF_LOCAL, SOCK_SEQPACKET, 0); Y> if (error == -1) {perror("socket"); exit(-1);} Y> sock = error; Y> Y> error = setsockopt(sock, SOL_SOCKET, LOCAL_CREDS, &oval, sizeof(oval)); Y> if (error) {perror("setsockopt"); exit(-1);} Y> } Alfred is right, we should add uipc_ctloutput() as method for SOCK_SEQPACKET on local sockets. But your code actually fails because you request SOL_SOCKET level. LOCAL_CREDS is protocol level option, not socket. socket(AF_LOCAL, SOCK_DGRAM, 0); setsockopt(sock, 0, LOCAL_CREDS, &oval, sizeof(oval)); P.S. I will look at issue with SOCK_SEQPACKET. According to manual page, it should work. -- Totus tuus, Glebius.