From owner-freebsd-net@FreeBSD.ORG Thu Aug 29 21:31:21 2013 Return-Path: Delivered-To: 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 B6B1E944 for ; Thu, 29 Aug 2013 21:31:21 +0000 (UTC) (envelope-from bright@mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id A4F5F2AF7 for ; Thu, 29 Aug 2013 21:31:21 +0000 (UTC) Received: from Alfreds-MacBook-Pro-9.local (c-67-180-208-218.hsd1.ca.comcast.net [67.180.208.218]) by elvis.mu.org (Postfix) with ESMTPSA id 259B91A3DAF; Thu, 29 Aug 2013 14:31:14 -0700 (PDT) Message-ID: <521FBDA1.4060106@mu.org> Date: Thu, 29 Aug 2013 14:31:13 -0700 From: Alfred Perlstein User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Yuri , net@FreeBSD.org Subject: Re: LOCAL_CREDS are broken ? References: <521F9789.5000903@rawbw.com> In-Reply-To: <521F9789.5000903@rawbw.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: Thu, 29 Aug 2013 21:31:21 -0000 On 8/29/13 11:48 AM, Yuri wrote: > The example below breaks with "Protocol not available" > But what is wrong? Isn't this the correct usage? > LOCAL_CREDS are only handled in kern/uipc_usrreq.c for AF_LOCAL, so it > isn't clear why this doesn't work. > > Yuri > > > > --- example.c --- > #include > #include > #include > #include > #include > > main() { > int sock; > int error; > int oval = 1; > > error = socket(AF_LOCAL, SOCK_SEQPACKET, 0); > if (error == -1) {perror("socket"); exit(-1);} > sock = error; > > error = setsockopt(sock, SOL_SOCKET, LOCAL_CREDS, &oval, sizeof(oval)); > if (error) {perror("setsockopt"); exit(-1);} > } > Looks like SOCK_SEQPACKET doesn't support LOCAL_CREDS because its protosw doesn't contain the entry for: .pr_ctloutput = &uipc_ctloutput, Have a look at src/sys/kern/uipc_usrreq.c at around lines 280-332: > static struct protosw localsw[] = { > { > .pr_type = SOCK_STREAM, > .pr_domain = &localdomain, > .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_RIGHTS, > .pr_ctloutput = &uipc_ctloutput, > .pr_usrreqs = &uipc_usrreqs_stream > }, > { > .pr_type = SOCK_DGRAM, > .pr_domain = &localdomain, > .pr_flags = PR_ATOMIC|PR_ADDR|PR_RIGHTS, > .pr_ctloutput = &uipc_ctloutput, > .pr_usrreqs = &uipc_usrreqs_dgram > }, > { > .pr_type = SOCK_SEQPACKET, > .pr_domain = &localdomain, > > /* > * XXXRW: For now, PR_ADDR because soreceive will bump into them > * due to our use of sbappendaddr. A new sbappend variants is > needed > * that supports both atomic record writes and control data. > */ > .pr_flags = PR_ADDR|PR_ATOMIC|PR_CONNREQUIRED|PR_WANTRCVD| > PR_RIGHTS, > .pr_usrreqs = &uipc_usrreqs_seqpacket, > }, > }; I wonder if this is just a bug/missing code!? -Alfred > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" > -- Alfred Perlstein