From owner-freebsd-net@FreeBSD.ORG Wed Sep 11 18:23:16 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id EE9D3101 for ; Wed, 11 Sep 2013 18:23:16 +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 78D3E2E1F for ; Wed, 11 Sep 2013 18:23:15 +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 r8BINDiF051824; Wed, 11 Sep 2013 22:23:13 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.7/8.14.7/Submit) id r8BINDlF051823; Wed, 11 Sep 2013 22:23:13 +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 22:23:12 +0400 From: Gleb Smirnoff To: Yuri Subject: Re: LOCAL_CREDS are broken ? Message-ID: <20130911182312.GU4574@FreeBSD.org> References: <521F9789.5000903@rawbw.com> <20130911151042.GO4574@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130911151042.GO4574@FreeBSD.org> 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 18:23:17 -0000 On Wed, Sep 11, 2013 at 07:10:42PM +0400, Gleb Smirnoff wrote: T> On Thu, Aug 29, 2013 at 11:48:41AM -0700, Yuri wrote: T> Y> The example below breaks with "Protocol not available" T> Y> But what is wrong? Isn't this the correct usage? T> Y> LOCAL_CREDS are only handled in kern/uipc_usrreq.c for AF_LOCAL, so it T> Y> isn't clear why this doesn't work. T> Y> T> Y> --- example.c --- T> Y> #include T> Y> #include T> Y> #include T> Y> #include T> Y> #include T> Y> T> Y> main() { T> Y> int sock; T> Y> int error; T> Y> int oval = 1; T> Y> T> Y> error = socket(AF_LOCAL, SOCK_SEQPACKET, 0); T> Y> if (error == -1) {perror("socket"); exit(-1);} T> Y> sock = error; T> Y> T> Y> error = setsockopt(sock, SOL_SOCKET, LOCAL_CREDS, &oval, sizeof(oval)); T> Y> if (error) {perror("setsockopt"); exit(-1);} T> Y> } T> T> Alfred is right, we should add uipc_ctloutput() as method for T> SOCK_SEQPACKET on local sockets. T> T> But your code actually fails because you request SOL_SOCKET T> level. T> T> LOCAL_CREDS is protocol level option, not socket. T> T> socket(AF_LOCAL, SOCK_DGRAM, 0); T> setsockopt(sock, 0, LOCAL_CREDS, &oval, sizeof(oval)); T> T> P.S. I will look at issue with SOCK_SEQPACKET. T> According to manual page, it should work. I've fixed that in head. -- Totus tuus, Glebius.