aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2024-07-09 14:33:53 +0000
committerMark Johnston <markj@FreeBSD.org>2024-07-23 13:01:53 +0000
commitf5fabf3dcfb67434d13890b9143a361478e731e2 (patch)
treefb4f5931835e857328620cdcdd43a51b8814e6a0
parent030cbcc4c231be94b5ded668930e5be17cb9d3d5 (diff)
downloadsrc-f5fabf3dcfb67434d13890b9143a361478e731e2.tar.gz
src-f5fabf3dcfb67434d13890b9143a361478e731e2.zip
socket: Simplify synchronization in soreceive_stream()
Now that the socket recv I/O lock is required in order to enable receive-side KTLS, we can move a check from out of the socket buffer lock, which in turn will simplify some further refactoring. Add a __predict_false annotation while here since we already perform a lockless check before acquiring any locks. Reviewed by: gallatin, jhb MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D45922 (cherry picked from commit 30f30ccae71ce6b3bbe7b2719a3d588cb46f97ba)
-rw-r--r--sys/kern/uipc_socket.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 32a6ff14bb43..479184a87a5e 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -2560,17 +2560,15 @@ soreceive_stream(struct socket *so, struct sockaddr **psa, struct uio *uio,
error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(flags));
if (error)
return (error);
- SOCKBUF_LOCK(sb);
-
#ifdef KERN_TLS
- if (sb->sb_tls_info != NULL) {
- SOCKBUF_UNLOCK(sb);
+ if (__predict_false(sb->sb_tls_info != NULL)) {
SOCK_IO_RECV_UNLOCK(so);
return (soreceive_generic(so, psa, uio, mp0, controlp,
flagsp));
}
#endif
+ SOCKBUF_LOCK(sb);
/* Easy one, no space to copyout anything. */
if (uio->uio_resid == 0) {
error = EINVAL;