From: Vitaliy Makkoveev Subject: sosplice(): remove socket state and options checks in unsplice path To: Alexander Bluhm , tech@openbsd.org Date: Thu, 2 Jan 2025 12:18:25 +0300 In ancient times the unsplicing path was the part of splicing, so it follows these checks too. While doing sosplice() reorder, I left them to keep API as is, but now I want to remove these checks. Socket splicing is about socket buffers which have their own locks, so socket locks are not required for splicing and unsplicing, moreover socket splicing relays on sblock() on so_rcv, not the solock(). I want to move solock() down to sonsplice() and keep it only around optional sor{r,w}akeup(), so these useless checks before sounsplice() brings nothing, but requires to take solock() and stop packet processing. I performed kern/sosplice tests without any issues, so I suspect this API change will be transparent. Index: sys/kern/uipc_socket.c =================================================================== RCS file: /cvs/src/sys/kern/uipc_socket.c,v diff -u -p -r1.352 uipc_socket.c --- sys/kern/uipc_socket.c 31 Dec 2024 12:19:46 -0000 1.352 +++ sys/kern/uipc_socket.c 2 Jan 2025 09:04:18 -0000 @@ -1338,22 +1338,11 @@ sosplice(struct socket *so, int fd, off_ if ((error = sblock(&so->so_rcv, SBL_WAIT)) != 0) return (error); solock(so); - if (so->so_options & SO_ACCEPTCONN) { - error = EOPNOTSUPP; - goto out; - } - if ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) == 0 && - (so->so_proto->pr_flags & PR_CONNREQUIRED)) { - error = ENOTCONN; - goto out; - } - if (so->so_sp && so->so_sp->ssp_socket) sounsplice(so, so->so_sp->ssp_socket, 0); - out: sounlock(so); sbunlock(&so->so_rcv); - return (error); + return (0); } if (sosplice_taskq == NULL) {