Date: Thu, 29 Aug 2013 14:31:13 -0700 From: Alfred Perlstein <bright@mu.org> To: Yuri <yuri@rawbw.com>, net@FreeBSD.org Subject: Re: LOCAL_CREDS are broken ? Message-ID: <521FBDA1.4060106@mu.org> In-Reply-To: <521F9789.5000903@rawbw.com> References: <521F9789.5000903@rawbw.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/types.h> > #include <sys/socket.h> > #include <stdio.h> > #include <stdlib.h> > #include <sys/un.h> > > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?521FBDA1.4060106>