Re: Level for Unix-domain socket options
On Thu, Aug 05, 2021 at 22:55:12 +0200, Rhialto wrote: > On Thu 05 Aug 2021 at 13:22:55 +, nia wrote: > > The unix(4) man page incorrectly states: > > > > "A UNIX-domain socket supports two socket-level options for use with > > setsockopt(2) and getsockopt(2): [...]" > > > > In reality, the protocol level when using these socket options > > must be 0, which is a magic number not really documented anywhere > > except the test suite. > > and getsockopt(2) says > > DESCRIPTION > getsockopt(), setsockopt() and getsockopt2() manipulate the options > associated with a socket. Options may exist at multiple protocol levels; > they are always present at the uppermost "socket" level. > > which I interpret to mean that even if you use SOL_SOCKET for these > options, it should work. Do I read that as intended? Was that perhaps an artifact of an old implementation? POSIX says The getsockopt() function shall fail if: [EINVAL] The specified option is invalid at the specified socket level. [ENOPROTOOPT] The option is not supported by the protocol. while our man page only has [ENOPROTOOPT] The option is unknown at the level indicated. which might actually be problematic, but I will leave the exegetic exercise to someone more skilled. -uwe
Re: Level for Unix-domain socket options
On Thu 05 Aug 2021 at 13:22:55 +, nia wrote: > The unix(4) man page incorrectly states: > > "A UNIX-domain socket supports two socket-level options for use with > setsockopt(2) and getsockopt(2): [...]" > > In reality, the protocol level when using these socket options > must be 0, which is a magic number not really documented anywhere > except the test suite. and getsockopt(2) says DESCRIPTION getsockopt(), setsockopt() and getsockopt2() manipulate the options associated with a socket. Options may exist at multiple protocol levels; they are always present at the uppermost "socket" level. which I interpret to mean that even if you use SOL_SOCKET for these options, it should work. Do I read that as intended? I understand from the above that it is not true for these options. Perhaps it should be fixed so that the options work for both SOL_LOCAL and SOL_SOCKET level: compatible with both (at least some) practice and documentation. -Olaf. -- ___ "Buying carbon credits is a bit like a serial killer paying someone else to \X/ have kids to make his activity cost neutral." -The BOFHfalu.nl@rhialto signature.asc Description: PGP signature
Re: Level for Unix-domain socket options
> "A UNIX-domain socket supports two SOL_LOCAL level options for use .." > shouldn't this be something like "only supports SOL_LOCAL level"? if > not, what the "two" part now? The "two" applies to "options". "...supports two (multi-word adjective) options...". However, if this confused mrg, it probably will confuse plenty of other people. Maybe "...supports two options, at level SOL_LOCAL, for..."? /~\ The ASCII Mouse \ / Ribbon Campaign X Against HTMLmo...@rodents-montreal.org / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
re: Level for Unix-domain socket options
i like it. > Index: sys/sys/un.h > === > RCS file: /cvsroot/src/sys/sys/un.h,v > retrieving revision 1.59 > diff -u -r1.59 un.h > --- sys/sys/un.h 6 Nov 2020 14:50:13 - 1.59 > +++ sys/sys/un.h 5 Aug 2021 13:19:20 - > @@ -56,6 +56,7 @@ > * Socket options for UNIX IPC domain. > */ > #if defined(_NETBSD_SOURCE) > +#define SOL_LOCAL0 /* options level for get/setsockopt */ > #define LOCAL_OCREDS0x0001 /* pass credentials to receiver > */ > #define LOCAL_CONNWAIT 0x0002 /* connects block until > accepted */ > #define LOCAL_PEEREID 0x0003 /* get peer identification */ please fix the space/tab issue here. > Index: share/man/man4/unix.4 > === > RCS file: /cvsroot/src/share/man/man4/unix.4,v > retrieving revision 1.26 > diff -u -r1.26 unix.4 > --- share/man/man4/unix.4 3 Jul 2017 21:30:58 - 1.26 > +++ share/man/man4/unix.4 5 Aug 2021 13:19:16 - > @@ -173,8 +173,8 @@ > when the destination socket is closed. > .Pp > A UNIX-domain socket supports two > -.Tn socket-level > -options for use with > +.Dv SOL_LOCAL > +level options for use with > .Xr setsockopt 2 > and > .Xr getsockopt 2 : now reads: "A UNIX-domain socket supports two SOL_LOCAL level options for use .." shouldn't this be something like "only supports SOL_LOCAL level"? if not, what the "two" part now? thanks. .mrg.
Re: Level for Unix-domain socket options
> On Aug 5, 2021, at 6:22 AM, nia wrote: > > I think we should: > > (a) introduce SOL_LOCAL to sys/un.h as an alias for 0, as in FreeBSD > (b) document it > (c) update all in-tree users of Unix-domain socket options to use > SOL_LOCAL instead of hardcoding 0 > Agreed. Patch looks good to me. -- thorpej