Re: Fix socketpair(2) handling of unix datagram sockets using cloexec/nonblock
On 07/16 05:05, Philip Guenther wrote: > On Thu, Jul 16, 2015 at 4:54 PM, Jeremy Evans wrote: > > Fix socketpair(2) on Unix datagram sockets that use SOCK_CLOEXEC or > > SOCK_NONBLOCK. > > > > This fixes a failure in the ruby test suite. > > > > OK? > > No, that'll have false positives on SOCK_RAW sockets. You need to > mask things, perhaps a diff like this: This works and is definitely more correct. OK jeremy@ Thanks, Jeremy > > --- sys/socket.h21 Jan 2015 02:23:14 - 1.87 > +++ sys/socket.h17 Jul 2015 00:03:48 - > @@ -68,6 +68,9 @@ typedef __sa_family_t sa_family_t;/* so > #defineSOCK_RAW3 /* raw-protocol interface */ > #defineSOCK_RDM4 /* reliably-delivered message > */ > #defineSOCK_SEQPACKET 5 /* sequenced packet stream */ > +#ifdef _KERNEL > +#defineSOCK_TYPE_MASK 0x000F /* mask that covers the above > */ > +#endif > > /* > * Socket creation flags > Index: kern/uipc_syscalls.c > === > RCS file: /data/src/openbsd/src/sys/kern/uipc_syscalls.c,v > retrieving revision 1.102 > diff -u -p -r1.102 uipc_syscalls.c > --- kern/uipc_syscalls.c21 May 2015 13:35:15 - 1.102 > +++ kern/uipc_syscalls.c17 Jul 2015 00:04:02 - > @@ -403,7 +403,7 @@ sys_socketpair(struct proc *p, void *v, > } > if ((error = soconnect2(so1, so2)) != 0) > goto free4; > - if (SCARG(uap, type) == SOCK_DGRAM) { > + if ((SCARG(uap, type) & SOCK_TYPE_MASK) == SOCK_DGRAM) { > /* > * Datagram socket connection is asymmetric. > */
Re: Fix socketpair(2) handling of unix datagram sockets using cloexec/nonblock
On Thu, Jul 16, 2015 at 4:54 PM, Jeremy Evans wrote: > Fix socketpair(2) on Unix datagram sockets that use SOCK_CLOEXEC or > SOCK_NONBLOCK. > > This fixes a failure in the ruby test suite. > > OK? No, that'll have false positives on SOCK_RAW sockets. You need to mask things, perhaps a diff like this: --- sys/socket.h21 Jan 2015 02:23:14 - 1.87 +++ sys/socket.h17 Jul 2015 00:03:48 - @@ -68,6 +68,9 @@ typedef __sa_family_t sa_family_t;/* so #defineSOCK_RAW3 /* raw-protocol interface */ #defineSOCK_RDM4 /* reliably-delivered message */ #defineSOCK_SEQPACKET 5 /* sequenced packet stream */ +#ifdef _KERNEL +#defineSOCK_TYPE_MASK 0x000F /* mask that covers the above */ +#endif /* * Socket creation flags Index: kern/uipc_syscalls.c === RCS file: /data/src/openbsd/src/sys/kern/uipc_syscalls.c,v retrieving revision 1.102 diff -u -p -r1.102 uipc_syscalls.c --- kern/uipc_syscalls.c21 May 2015 13:35:15 - 1.102 +++ kern/uipc_syscalls.c17 Jul 2015 00:04:02 - @@ -403,7 +403,7 @@ sys_socketpair(struct proc *p, void *v, } if ((error = soconnect2(so1, so2)) != 0) goto free4; - if (SCARG(uap, type) == SOCK_DGRAM) { + if ((SCARG(uap, type) & SOCK_TYPE_MASK) == SOCK_DGRAM) { /* * Datagram socket connection is asymmetric. */
Fix socketpair(2) handling of unix datagram sockets using cloexec/nonblock
Fix socketpair(2) on Unix datagram sockets that use SOCK_CLOEXEC or SOCK_NONBLOCK. This fixes a failure in the ruby test suite. OK? Thanks, Jeremy Index: kern/uipc_syscalls.c === RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v retrieving revision 1.97 diff -u -p -r1.97 uipc_syscalls.c --- kern/uipc_syscalls.c13 Dec 2014 21:05:33 - 1.97 +++ kern/uipc_syscalls.c16 Jul 2015 23:29:40 - @@ -406,7 +406,7 @@ sys_socketpair(struct proc *p, void *v, } if ((error = soconnect2(so1, so2)) != 0) goto free4; - if (SCARG(uap, type) == SOCK_DGRAM) { + if (SCARG(uap, type) & SOCK_DGRAM) { /* * Datagram socket connection is asymmetric. */