git: 9c440e552c4c - stable/15 - sctp: fix NOINET build

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Tue, 19 May 2026 10:19:09 UTC
The branch stable/15 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=9c440e552c4cc252fe150b5f0edef9b8cd75a72f

commit 9c440e552c4cc252fe150b5f0edef9b8cd75a72f
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2026-02-27 07:51:29 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-05-19 08:41:41 +0000

    sctp: fix NOINET build
    
    Reported by:            ngie
    Fixes:                  454212b9718b ("sctp: fix so_proto when peeling off a socket")
    
    (cherry picked from commit 6bd97e9e01ff159eef49b2521fdbe67d5db10d95)
---
 sys/netinet/sctp_syscalls.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/sys/netinet/sctp_syscalls.c b/sys/netinet/sctp_syscalls.c
index 79c1dfb21495..da7d0556a809 100644
--- a/sys/netinet/sctp_syscalls.c
+++ b/sys/netinet/sctp_syscalls.c
@@ -30,6 +30,8 @@
 
 #include <sys/cdefs.h>
 #include "opt_capsicum.h"
+#include "opt_inet.h"
+#include "opt_inet6.h"
 #include "opt_sctp.h"
 #include "opt_ktrace.h"
 
@@ -78,6 +80,9 @@
 #include <netinet/sctp.h>
 #include <netinet/sctp_pcb.h>
 #include <netinet/sctp_var.h>
+#ifdef INET6
+#include <netinet6/sctp6_var.h>
+#endif
 #include <netinet/sctp_os_bsd.h>
 #include <netinet/sctp_peeloff.h>
 
@@ -174,7 +179,21 @@ sys_sctp_peeloff(struct thread *td, struct sctp_peeloff_args *uap)
 	td->td_retval[0] = fd;
 
 	CURVNET_SET(head->so_vnet);
-	so = sopeeloff(head, &sctp_stream_protosw);
+	switch (head->so_proto->pr_domain->dom_family) {
+#ifdef INET
+	case AF_INET:
+		so = sopeeloff(head, &sctp_stream_protosw);
+		break;
+#endif
+#ifdef INET6
+	case AF_INET6:
+		so = sopeeloff(head, &sctp6_stream_protosw);
+		break;
+#endif
+	default:
+		error = EOPNOTSUPP;
+		goto noconnection;
+	}
 	if (so == NULL) {
 		error = ENOMEM;
 		goto noconnection;