git: 1c933f464fdb - main - unix: Be consistent about error handling for unconnected sockets

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 06 Jan 2025 22:56:59 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=1c933f464fdbb630f9663751f04c29cdcda38902

commit 1c933f464fdbb630f9663751f04c29cdcda38902
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-01-06 22:55:38 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-01-06 22:56:34 +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
---
 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 7af73a1d344b..3d7e5bcc5ad0 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1796,7 +1796,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;