From nobody Tue Sep 3 14:55:05 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WypZK4xdsz5TMnx; Tue, 03 Sep 2024 14:55:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WypZK2j19z4x8C; Tue, 3 Sep 2024 14:55:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725375305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uE+pTMTRWV2jmbH9nIW3i5cuch+dbmMwnTmpti1J6aM=; b=RjmiQzWHc003su48XwF8SAqJkzUfO069koHy44RPnxpLfPKf8C8uxLCaekkCjm7YJabB0O DUw0XQ1265QnAE3X6o2fcjJ/H/26hmwcV5Px3QV7SFI40gpC5zo7jhIThBaM7wSxd0vmYM GSycD4abvb9lSUbAmYnWw9ODWwvVXl5/1BCK5tlhYQbt1ckZSklYYeZdFthPPufp6R1Pfl 2HApVClSCs1eOvu4ffzx/WCYxV5avD1MvCy0sYCCO6vlFVbsY2QqIkyxkSSBL8NqHVQxix Kp2Ly2nCqpkDZxU6s/EwBL/7JrmlcsFbn7dOK52WMJa1c45AX1AIQHs+Epq9Jg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725375305; a=rsa-sha256; cv=none; b=U5K8xnI+8cYLfRYJ10AbS1sIzsVWOxJZYmzeZLnrafRKt0ZD3Civ7AWa94LMdZwfA9sH1m XaatadDiDBkmYrzZpYHTF4vOlgJRSKkd7Y+9TUPCqPnhdu2l9mnGa7e+gxd7HkOkq7qti4 94AcowUQmbYVz4+jaflBMGqCHV3sPAX/zlqlIgtgKCIeAwE/9Sj4sZ1+AiO+IdQZ3y0Fhd z8ixzcsQIjRS2flY7SR+HalWVgDxmTPXSs97RWAx0LCf+WR1WkX/f6oVOpGGXq0keZlqWi HX41/2i0MLMxWQACCXKgrba3YAEUnduVSOP3gpQXlwJWbIFIV42VYfkT4KIYsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725375305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uE+pTMTRWV2jmbH9nIW3i5cuch+dbmMwnTmpti1J6aM=; b=r63jS7yz2N+8qIXS3aAkFrn4K3EaBwfRKeIzGO/LrkeqeD34Eii6QyKjpU/ChC6V92uYjl JbkoMGEqSUKB6NsXAuzOv7MSOTro8Qg8j+UTY1pGknWvPbq9v2RVqput1sMRqXVZxBOaOq BskDFJ7dNeh4eHsDSbEvlKgAGYJdjSQDPyM895Hy+8V+eSDY7nqWaRKH+OFaV+xy9zbzH3 T8XNcbYFkafvho6EY/1m9maa44d3J7/JzOJRbA7JMK0tdI6MzKWpZpK0wJI4FqxshTH1pL v5ntRkmkW6fN26bdZQ+KyNskoy2LXAIko/O0C/D6yQPzT4RdFQYFLE9AZ/k0BA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WypZK2Gzjzllg; Tue, 3 Sep 2024 14:55:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 483Et5jt070774; Tue, 3 Sep 2024 14:55:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 483Et5kp070771; Tue, 3 Sep 2024 14:55:05 GMT (envelope-from git) Date: Tue, 3 Sep 2024 14:55:05 GMT Message-Id: <202409031455.483Et5kp070771@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 0480918c0904 - stable/14 - socket: Split up soreceive_generic() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 0480918c09042ce6a71733a53a562152af035564 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0480918c09042ce6a71733a53a562152af035564 commit 0480918c09042ce6a71733a53a562152af035564 Author: Mark Johnston AuthorDate: 2024-08-19 14:20:19 +0000 Commit: Mark Johnston CommitDate: 2024-09-03 14:54:43 +0000 socket: Split up soreceive_generic() Factor out the bits that run with the sock I/O lock held into a separate function. No functional change intended. Reviewed by: gallatin, glebius MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D46304 (cherry picked from commit 0a68f644dca19670686007071479f919a56ea37f) --- sys/kern/uipc_socket.c | 61 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 8a688e41ee88..99073121d7de 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2016,11 +2016,11 @@ sockbuf_pushsync(struct sockbuf *sb, struct mbuf *nextrecord) * mbuf **mp0 for use in returning the chain. The uio is then used only for * the count in uio_resid. */ -int -soreceive_generic(struct socket *so, struct sockaddr **psa, struct uio *uio, - struct mbuf **mp0, struct mbuf **controlp, int *flagsp) +static int +soreceive_generic_locked(struct socket *so, struct sockaddr **psa, + struct uio *uio, struct mbuf **mp, struct mbuf **controlp, int *flagsp) { - struct mbuf *m, **mp; + struct mbuf *m; int flags, error, offset; ssize_t len; struct protosw *pr = so->so_proto; @@ -2029,30 +2029,15 @@ soreceive_generic(struct socket *so, struct sockaddr **psa, struct uio *uio, ssize_t orig_resid = uio->uio_resid; bool report_real_len = false; - mp = mp0; - if (psa != NULL) - *psa = NULL; - if (controlp != NULL) - *controlp = NULL; + SOCK_IO_RECV_ASSERT_LOCKED(so); + + error = 0; if (flagsp != NULL) { report_real_len = *flagsp & MSG_TRUNC; *flagsp &= ~MSG_TRUNC; flags = *flagsp &~ MSG_EOR; } else flags = 0; - if (flags & MSG_OOB) - return (soreceive_rcvoob(so, uio, flags)); - if (mp != NULL) - *mp = NULL; - if ((pr->pr_flags & PR_WANTRCVD) && (so->so_state & SS_ISCONFIRMING) - && uio->uio_resid) { - VNET_SO_ASSERT(so); - pr->pr_rcvd(so, 0); - } - - error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(flags)); - if (error) - return (error); restart: SOCKBUF_LOCK(&so->so_rcv); @@ -2510,6 +2495,38 @@ dontblock: if (flagsp != NULL) *flagsp |= flags; release: + return (error); +} + +int +soreceive_generic(struct socket *so, struct sockaddr **psa, struct uio *uio, + struct mbuf **mp, struct mbuf **controlp, int *flagsp) +{ + int error, flags; + + if (psa != NULL) + *psa = NULL; + if (controlp != NULL) + *controlp = NULL; + if (flagsp != NULL) { + flags = *flagsp; + if ((flags & MSG_OOB) != 0) + return (soreceive_rcvoob(so, uio, flags)); + } else { + flags = 0; + } + if (mp != NULL) + *mp = NULL; + if ((so->so_proto->pr_flags & PR_WANTRCVD) && + (so->so_state & SS_ISCONFIRMING) && uio->uio_resid) { + VNET_SO_ASSERT(so); + so->so_proto->pr_rcvd(so, 0); + } + + error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(flags)); + if (error) + return (error); + error = soreceive_generic_locked(so, psa, uio, mp, controlp, flagsp); SOCK_IO_RECV_UNLOCK(so); return (error); }