git: 8373644ee2c8 - stable/14 - unix: Be consistent about error handling for unconnected sockets

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 20 Jan 2025 00:27:58 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=8373644ee2c848bab47d87d24b31d673e6515bce

commit 8373644ee2c848bab47d87d24b31d673e6515bce
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-01-06 22:55:38 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-01-20 00:26:27 +0000

    unix: Be consistent about error handling for unconnected sockets
    
    SOCK_STREAM and SOCK_SEQPACKET sockets should get the same treatment
    here.
    
    PR:             176420
    MFC after:      2 weeks
    
    (cherry picked from commit 1c933f464fdbb630f9663751f04c29cdcda38902)
---
 sys/kern/uipc_usrreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 78469adcd84d..80ac5cc0b775 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1779,7 +1779,7 @@ uipc_ctloutput(struct socket *so, struct sockopt *sopt)
 			if (unp->unp_flags & UNP_HAVEPC)
 				xu = unp->unp_peercred;
 			else {
-				if (so->so_type == SOCK_STREAM)
+				if (so->so_proto->pr_flags & PR_CONNREQUIRED)
 					error = ENOTCONN;
 				else
 					error = EINVAL;