Index: sys/amd64/conf/GENERIC =================================================================== --- sys/amd64/conf/GENERIC +++ sys/amd64/conf/GENERIC @@ -35,7 +35,7 @@ options TCP_BLACKBOX # Enhanced TCP event logging options TCP_HHOOK # hhook(9) framework for TCP options TCP_RFC7413 # TCP Fast Open -options SCTP # Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Index: sys/amd64/conf/MINIMAL =================================================================== --- sys/amd64/conf/MINIMAL +++ sys/amd64/conf/MINIMAL @@ -44,7 +44,7 @@ options INET # InterNETworking options INET6 # IPv6 communications protocols options TCP_OFFLOAD # TCP offload -options SCTP # Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Index: sys/arm/conf/std.armv6 =================================================================== --- sys/arm/conf/std.armv6 +++ sys/arm/conf/std.armv6 @@ -12,7 +12,7 @@ options TCP_HHOOK # hhook(9) framework for TCP device crypto # core crypto support options IPSEC_SUPPORT # Allow kldload of ipsec and tcpmd5 -options SCTP # Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Index: sys/arm/conf/std.armv7 =================================================================== --- sys/arm/conf/std.armv7 +++ sys/arm/conf/std.armv7 @@ -12,7 +12,7 @@ options TCP_HHOOK # hhook(9) framework for TCP device crypto # core crypto support options IPSEC_SUPPORT # Allow kldload of ipsec and tcpmd5 -options SCTP # Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Index: sys/arm64/conf/GENERIC =================================================================== --- sys/arm64/conf/GENERIC +++ sys/arm64/conf/GENERIC @@ -33,7 +33,7 @@ options TCP_HHOOK # hhook(9) framework for TCP options TCP_OFFLOAD # TCP offload options TCP_RFC7413 # TCP Fast Open -options SCTP # Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Index: sys/conf/NOTES =================================================================== --- sys/conf/NOTES +++ sys/conf/NOTES @@ -685,7 +685,12 @@ # the V6 and V4.. since an association can span # both a V6 and V4 address at the SAME time :-) # +# The SCTP_SUPPORT option does not enable SCTP, but provides the necessary +# support for loading SCTP as a loadable kernel module. +# options SCTP +options SCTP_SUPPORT + # There are bunches of options: # this one turns on all sorts of # nastily printing that you can @@ -698,6 +703,7 @@ # bits and prints.. which makes the code run # faster.. if you are not debugging don't use. options SCTP_DEBUG + # # All that options after that turn on specific types of # logging. You can monitor CWND growth, flight size @@ -721,7 +727,6 @@ options SCTP_LTRACE_CHUNKS options SCTP_LTRACE_ERRORS - # altq(9). Enable the base part of the hooks with the ALTQ option. # Individual disciplines must be built into the base system and can not be # loaded as modules at this point. ALTQ requires a stable TSC so if yours is Index: sys/conf/options =================================================================== --- sys/conf/options +++ sys/conf/options @@ -467,6 +467,7 @@ # SCTP # SCTP opt_sctp.h +SCTP_SUPPORT opt_sctp.h SCTP_DEBUG opt_sctp.h # Enable debug printfs SCTP_LOCK_LOGGING opt_sctp.h # Log to KTR lock activity SCTP_MBUF_LOGGING opt_sctp.h # Log to KTR general mbuf aloc/free Index: sys/i386/conf/GENERIC =================================================================== --- sys/i386/conf/GENERIC +++ sys/i386/conf/GENERIC @@ -34,7 +34,7 @@ options IPSEC_SUPPORT # Allow kldload of ipsec and tcpmd5 options TCP_HHOOK # hhook(9) framework for TCP options TCP_OFFLOAD # TCP offload -options SCTP # Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Index: sys/i386/conf/MINIMAL =================================================================== --- sys/i386/conf/MINIMAL +++ sys/i386/conf/MINIMAL @@ -45,7 +45,7 @@ options INET # InterNETworking options INET6 # IPv6 communications protocols options TCP_OFFLOAD # TCP offload -options SCTP # Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Index: sys/kern/uipc_socket.c =================================================================== --- sys/kern/uipc_socket.c +++ sys/kern/uipc_socket.c @@ -692,7 +692,7 @@ return (so); } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) /* * Socket part of sctp_peeloff(). Detach a new socket from an * association. The new socket is returned with a reference. Index: sys/mips/conf/ERL =================================================================== --- sys/mips/conf/ERL +++ sys/mips/conf/ERL @@ -55,7 +55,7 @@ options INET6 # IPv6 communications protocols options IPSEC # IP (v4/v6) security options TCP_HHOOK # hhook(9) framework for TCP -options SCTP # Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Index: sys/mips/conf/OCTEON1 =================================================================== --- sys/mips/conf/OCTEON1 +++ sys/mips/conf/OCTEON1 @@ -55,7 +55,7 @@ options INET # InterNETworking options INET6 # IPv6 communications protocols options TCP_HHOOK # hhook(9) framework for TCP -options SCTP # Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Index: sys/modules/sctp/Makefile =================================================================== --- /dev/null +++ sys/modules/sctp/Makefile @@ -0,0 +1,29 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/sys/netinet +.PATH: ${SRCTOP}/sys/netinet6 + +KMOD= sctp +SRCS= sctp_asconf.c \ + sctp_auth.c \ + sctp_bsd_addr.c \ + sctp_cc_functions.c \ + sctp_crc32.c \ + sctp_indata.c \ + sctp_input.c \ + sctp_kdtrace.c \ + sctp_output.c \ + sctp_pcb.c \ + sctp_peeloff.c \ + sctp_ss_functions.c \ + sctp_syscalls.c \ + sctp_sysctl.c \ + sctp_timer.c \ + sctp_usrreq.c \ + sctp6_usrreq.c \ + sctputil.c + +SRCS+= device_if.h bus_if.h vnode_if.h +SRCS+= opt_capsicum.h opt_ktrace.h opt_inet.h opt_inet6.h opt_sctp.h + +.include Index: sys/netinet/in_proto.c =================================================================== --- sys/netinet/in_proto.c +++ sys/netinet/in_proto.c @@ -34,11 +34,10 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_mrouting.h" #include "opt_ipsec.h" #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_sctp.h" +#include "opt_mrouting.h" #include "opt_mpath.h" #include @@ -92,13 +91,6 @@ static struct pr_usrreqs nousrreqs; -#ifdef SCTP -#include -#include -#include -#include -#endif /* SCTP */ - FEATURE(inet, "Internet Protocol version 4"); extern struct domain inetdomain; @@ -145,31 +137,6 @@ .pr_drain = tcp_drain, .pr_usrreqs = &tcp_usrreqs }, -#ifdef SCTP -{ - .pr_type = SOCK_SEQPACKET, - .pr_domain = &inetdomain, - .pr_protocol = IPPROTO_SCTP, - .pr_flags = PR_WANTRCVD|PR_LASTHDR, - .pr_input = sctp_input, - .pr_ctlinput = sctp_ctlinput, - .pr_ctloutput = sctp_ctloutput, - .pr_init = sctp_init, - .pr_drain = sctp_drain, - .pr_usrreqs = &sctp_usrreqs -}, -{ - .pr_type = SOCK_STREAM, - .pr_domain = &inetdomain, - .pr_protocol = IPPROTO_SCTP, - .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LASTHDR, - .pr_input = sctp_input, - .pr_ctlinput = sctp_ctlinput, - .pr_ctloutput = sctp_ctloutput, - .pr_drain = sctp_drain, - .pr_usrreqs = &sctp_usrreqs -}, -#endif /* SCTP */ { .pr_type = SOCK_DGRAM, .pr_domain = &inetdomain, @@ -327,9 +294,6 @@ SYSCTL_NODE(_net_inet, IPPROTO_ICMP, icmp, CTLFLAG_RW, 0, "ICMP"); SYSCTL_NODE(_net_inet, IPPROTO_UDP, udp, CTLFLAG_RW, 0, "UDP"); SYSCTL_NODE(_net_inet, IPPROTO_TCP, tcp, CTLFLAG_RW, 0, "TCP"); -#ifdef SCTP -SYSCTL_NODE(_net_inet, IPPROTO_SCTP, sctp, CTLFLAG_RW, 0, "SCTP"); -#endif SYSCTL_NODE(_net_inet, IPPROTO_IGMP, igmp, CTLFLAG_RW, 0, "IGMP"); #if defined(IPSEC) || defined(IPSEC_SUPPORT) /* XXX no protocol # to use, pick something "reserved" */ Index: sys/netinet/ip_divert.c =================================================================== --- sys/netinet/ip_divert.c +++ sys/netinet/ip_divert.c @@ -69,7 +69,7 @@ #include #include #endif -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) #include #endif @@ -210,7 +210,7 @@ in_delayed_cksum(m); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP) { sctp_delayed_cksum(m, (uint32_t)(ip->ip_hl << 2)); m->m_pkthdr.csum_flags &= ~CSUM_SCTP; Index: sys/netinet/ip_output.c =================================================================== --- sys/netinet/ip_output.c +++ sys/netinet/ip_output.c @@ -87,7 +87,7 @@ #include #include -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) #include #include #endif @@ -155,7 +155,7 @@ } m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED | CSUM_IP_VALID; -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP) m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; #endif @@ -186,7 +186,7 @@ CSUM_DATA_VALID | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP) m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; #endif @@ -741,7 +741,7 @@ goto bad; } } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP & ~ifp->if_hwassist) { m = mb_unmapped_to_ext(m); if (m == NULL) { @@ -894,7 +894,7 @@ in_delayed_cksum(m0); m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m0->m_pkthdr.csum_flags & CSUM_SCTP) { m0 = mb_unmapped_to_ext(m0); if (m0 == NULL) { Index: sys/netinet/sctp_crc32.h =================================================================== --- sys/netinet/sctp_crc32.h +++ sys/netinet/sctp_crc32.h @@ -40,7 +40,7 @@ #if defined(_KERNEL) uint32_t sctp_calculate_cksum(struct mbuf *, uint32_t); -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) void sctp_delayed_cksum(struct mbuf *, uint32_t offset); #endif #endif /* _KERNEL */ Index: sys/netinet/sctp_crc32.c =================================================================== --- sys/netinet/sctp_crc32.c +++ sys/netinet/sctp_crc32.c @@ -38,7 +38,7 @@ #include "opt_sctp.h" #include -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) #include #include #include @@ -117,7 +117,7 @@ return (base); } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) /* * Compute and insert the SCTP checksum in network byte order for a given * mbuf chain m which contains an SCTP packet starting at offset. @@ -128,8 +128,8 @@ uint32_t checksum; checksum = sctp_calculate_cksum(m, offset); - SCTP_STAT_DECR(sctps_sendhwcrc); - SCTP_STAT_INCR(sctps_sendswcrc); + //SCTP_STAT_DECR(sctps_sendhwcrc); + //SCTP_STAT_INCR(sctps_sendswcrc); offset += offsetof(struct sctphdr, checksum); if (offset + sizeof(uint32_t) > (uint32_t)(m->m_pkthdr.len)) { Index: sys/netinet/sctp_os_bsd.h =================================================================== --- sys/netinet/sctp_os_bsd.h +++ sys/netinet/sctp_os_bsd.h @@ -45,9 +45,12 @@ #include "opt_sctp.h" #include +#include +#include #include #include #include +#include #include #include #include @@ -83,7 +86,6 @@ #include #ifdef INET6 -#include #include #include #include @@ -478,4 +480,7 @@ #define SCTP_IS_LISTENING(inp) ((inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING) != 0) +int sctp_syscalls_init(void); +int sctp_syscalls_uninit(void); + #endif Index: sys/netinet/sctp_syscalls.c =================================================================== --- sys/netinet/sctp_syscalls.c +++ sys/netinet/sctp_syscalls.c @@ -69,6 +69,8 @@ #include #endif #ifdef COMPAT_FREEBSD32 +#include +#include #include #endif @@ -78,6 +80,7 @@ #include #include +#include #include static struct syscall_helper_data sctp_syscalls[] = { @@ -88,28 +91,52 @@ SYSCALL_INIT_LAST }; -static void -sctp_syscalls_init(void *unused __unused) +#ifdef COMPAT_FREEBSD32 +static struct syscall_helper_data sctp32_syscalls[] = { + SYSCALL32_INIT_HELPER_COMPAT(sctp_peeloff), + SYSCALL32_INIT_HELPER_COMPAT(sctp_generic_sendmsg), + SYSCALL32_INIT_HELPER_COMPAT(sctp_generic_sendmsg_iov), + SYSCALL32_INIT_HELPER_COMPAT(sctp_generic_recvmsg), + SYSCALL_INIT_LAST +}; +#endif + +int +sctp_syscalls_init(void) { - int error __unused; + int error; - error = syscall_helper_register(sctp_syscalls, SY_THR_STATIC); - KASSERT((error == 0), - ("%s: syscall_helper_register failed for sctp syscalls", __func__)); + error = syscall_helper_register(sctp_syscalls, SY_THR_STATIC_KLD); + if (error != 0) + return (error); #ifdef COMPAT_FREEBSD32 - error = syscall32_helper_register(sctp_syscalls, SY_THR_STATIC); - KASSERT((error == 0), - ("%s: syscall32_helper_register failed for sctp syscalls", - __func__)); + error = syscall32_helper_register(sctp32_syscalls, SY_THR_STATIC_KLD); + if (error != 0) + return (error); #endif + return (0); +} + +int +sctp_syscalls_uninit(void) +{ + int error; + +#ifdef COMPAT_FREEBSD32 + error = syscall32_helper_unregister(sctp32_syscalls); + if (error != 0) + return (error); +#endif + error = syscall_helper_unregister(sctp_syscalls); + if (error != 0) + return (error); + return (0); } -SYSINIT(sctp_syscalls, SI_SUB_SYSCALLS, SI_ORDER_ANY, sctp_syscalls_init, NULL); /* * SCTP syscalls. * Functionality only compiled in if SCTP is defined in the kernel Makefile, * otherwise all return EOPNOTSUPP. - * XXX: We should make this loadable one day. */ int sys_sctp_peeloff(td, uap) @@ -119,7 +146,7 @@ caddr_t name; } */ *uap; { -#if (defined(INET) || defined(INET6)) && defined(SCTP) +#if defined(INET) || defined(INET6) struct file *headfp, *nfp = NULL; struct socket *head, *so; cap_rights_t rights; @@ -181,9 +208,7 @@ fdrop(headfp, td); done2: return (error); -#else /* SCTP */ - return (EOPNOTSUPP); -#endif /* SCTP */ +#endif } int @@ -199,7 +224,7 @@ int flags } */ *uap; { -#if (defined(INET) || defined(INET6)) && defined(SCTP) +#if defined(INET) || defined(INET6) struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL; struct socket *so; struct file *fp = NULL; @@ -294,9 +319,7 @@ sctp_bad2: free(to, M_SONAME); return (error); -#else /* SCTP */ - return (EOPNOTSUPP); -#endif /* SCTP */ +#endif } int @@ -312,7 +335,7 @@ int flags } */ *uap; { -#if (defined(INET) || defined(INET6)) && defined(SCTP) +#if defined(INET) || defined(INET6) struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL; struct socket *so; struct file *fp = NULL; @@ -424,9 +447,7 @@ sctp_bad2: free(to, M_SONAME); return (error); -#else /* SCTP */ - return (EOPNOTSUPP); -#endif /* SCTP */ +#endif } int @@ -442,7 +463,7 @@ int *msg_flags } */ *uap; { -#if (defined(INET) || defined(INET6)) && defined(SCTP) +#if defined(INET) || defined(INET6) uint8_t sockbufstore[256]; struct uio auio; struct iovec *iov, *tiov; @@ -572,7 +593,5 @@ fdrop(fp, td); return (error); -#else /* SCTP */ - return (EOPNOTSUPP); -#endif /* SCTP */ +#endif } Index: sys/netinet/sctp_sysctl.c =================================================================== --- sys/netinet/sctp_sysctl.c +++ sys/netinet/sctp_sysctl.c @@ -51,6 +51,9 @@ * sysctl tunable variables */ +/* XXX ifdef inet/inet6? */ +SYSCTL_NODE(_net_inet, IPPROTO_SCTP, sctp, CTLFLAG_RW, 0, "SCTP"); + void sctp_init_sysctls() { Index: sys/netinet/sctp_usrreq.c =================================================================== --- sys/netinet/sctp_usrreq.c +++ sys/netinet/sctp_usrreq.c @@ -55,15 +55,65 @@ #include #include - - extern const struct sctp_cc_functions sctp_cc_functions[]; extern const struct sctp_ss_functions sctp_ss_functions[]; -void +extern struct domain inetdomain; + +struct protosw sctp_stream_protosw = { + .pr_type = SOCK_STREAM, + .pr_domain = &inetdomain, + .pr_protocol = IPPROTO_SCTP, + .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LASTHDR, + .pr_input = sctp_input, + .pr_ctlinput = sctp_ctlinput, + .pr_ctloutput = sctp_ctloutput, + .pr_drain = sctp_drain, + .pr_usrreqs = &sctp_usrreqs, +}; + +struct protosw sctp_seqpacket_protosw = { + .pr_type = SOCK_SEQPACKET, + .pr_domain = &inetdomain, + .pr_protocol = IPPROTO_SCTP, + .pr_flags = PR_WANTRCVD|PR_LASTHDR, + .pr_input = sctp_input, + .pr_ctlinput = sctp_ctlinput, + .pr_ctloutput = sctp_ctloutput, + .pr_drain = sctp_drain, + .pr_usrreqs = &sctp_usrreqs, +}; + +static eventhandler_tag eh_tag; + +static int sctp_init(void) { u_long sb_max_adj; + int error; + + error = pf_proto_register(PF_INET, &sctp_stream_protosw); + if (error != 0) + return (error); + error = pf_proto_register(PF_INET, &sctp_seqpacket_protosw); + if (error != 0) + return (error); + error = ipproto_register(IPPROTO_SCTP); + if (error != 0) + /* XXX do we need to unwind? */ + return (error); +#ifdef INET6 + error = pf_proto_register(PF_INET6, &sctp6_stream_protosw); + if (error != 0) + return (error); + error = pf_proto_register(PF_INET6, &sctp6_seqpacket_protosw); + if (error != 0) + return (error); + error = ip6proto_register(IPPROTO_SCTP); + if (error != 0) + /* XXX do we need to unwind? */ + return (error); +#endif /* Initialize and modify the sysctled variables */ sctp_init_sysctls(); @@ -90,10 +140,72 @@ SCTP_BASE_VAR(packet_log_end) = 0; memset(&SCTP_BASE_VAR(packet_log_buffer), 0, SCTP_PACKET_LOG_SIZE); #endif - EVENTHANDLER_REGISTER(rt_addrmsg, sctp_addr_change_event_handler, - NULL, EVENTHANDLER_PRI_FIRST); + + eh_tag = EVENTHANDLER_REGISTER(rt_addrmsg, + sctp_addr_change_event_handler, NULL, EVENTHANDLER_PRI_FIRST); + + return (sctp_syscalls_init()); +} + +static int +sctp_uninit(void) +{ + int error; + + error = ipproto_unregister(IPPROTO_SCTP); + if (error != 0) + return (error); + error = pf_proto_unregister(PF_INET, IPPROTO_SCTP, SOCK_STREAM); + if (error != 0) + return (error); + error = pf_proto_unregister(PF_INET, IPPROTO_SCTP, SOCK_SEQPACKET); + if (error != 0) + return (error); +#ifdef INET6 + error = ip6proto_unregister(IPPROTO_SCTP); + if (error != 0) + return (error); + error = pf_proto_unregister(PF_INET6, IPPROTO_SCTP, SOCK_STREAM); + if (error != 0) + return (error); + error = pf_proto_unregister(PF_INET6, IPPROTO_SCTP, SOCK_SEQPACKET); + if (error != 0) + return (error); +#endif + + EVENTHANDLER_DEREGISTER(rt_addrmsg, eh_tag); + + return (sctp_syscalls_uninit()); +} + +static int +sctp_modload(struct module *module, int cmd, void *arg) +{ + int error; + + switch (cmd) { + case MOD_LOAD: + error = sctp_init(); + break; + case MOD_UNLOAD: + error = sctp_uninit(); + break; + default: + error = 0; + break; + } + return (error); } +static moduledata_t sctp_mod = { + "sctp", + &sctp_modload, + NULL, +}; + +DECLARE_MODULE(sctp, sctp_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); +MODULE_VERSION(sctp, 1); + #ifdef VIMAGE static void sctp_finish(void *unused __unused) Index: sys/netinet/sctp_var.h =================================================================== --- sys/netinet/sctp_var.h +++ sys/netinet/sctp_var.h @@ -340,7 +340,6 @@ #endif void sctp_pathmtu_adjustment(struct sctp_tcb *, uint16_t); void sctp_drain(void); -void sctp_init(void); void sctp_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *, uint8_t, uint8_t, uint16_t, uint32_t); Index: sys/netinet6/in6_proto.c =================================================================== --- sys/netinet6/in6_proto.c +++ sys/netinet6/in6_proto.c @@ -69,7 +69,6 @@ #include "opt_inet6.h" #include "opt_ipsec.h" #include "opt_ipstealth.h" -#include "opt_sctp.h" #include "opt_mpath.h" #include "opt_route.h" @@ -115,14 +114,6 @@ #include #include -#ifdef SCTP -#include -#include -#include -#include -#include -#endif /* SCTP */ - #include /* @@ -182,33 +173,6 @@ .pr_drain = tcp_drain, .pr_usrreqs = &tcp6_usrreqs, }, -#ifdef SCTP -{ - .pr_type = SOCK_SEQPACKET, - .pr_domain = &inet6domain, - .pr_protocol = IPPROTO_SCTP, - .pr_flags = PR_WANTRCVD|PR_LASTHDR, - .pr_input = sctp6_input, - .pr_ctlinput = sctp6_ctlinput, - .pr_ctloutput = sctp_ctloutput, - .pr_drain = sctp_drain, -#ifndef INET /* Do not call initialization twice. */ - .pr_init = sctp_init, -#endif - .pr_usrreqs = &sctp6_usrreqs -}, -{ - .pr_type = SOCK_STREAM, - .pr_domain = &inet6domain, - .pr_protocol = IPPROTO_SCTP, - .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LASTHDR, - .pr_input = sctp6_input, - .pr_ctlinput = sctp6_ctlinput, - .pr_ctloutput = sctp_ctloutput, - .pr_drain = sctp_drain, - .pr_usrreqs = &sctp6_usrreqs -}, -#endif /* SCTP */ { .pr_type = SOCK_DGRAM, .pr_domain = &inet6domain, @@ -432,9 +396,6 @@ SYSCTL_NODE(_net_inet6, IPPROTO_ICMPV6, icmp6, CTLFLAG_RW, 0, "ICMP6"); SYSCTL_NODE(_net_inet6, IPPROTO_UDP, udp6, CTLFLAG_RW, 0, "UDP6"); SYSCTL_NODE(_net_inet6, IPPROTO_TCP, tcp6, CTLFLAG_RW, 0, "TCP6"); -#ifdef SCTP -SYSCTL_NODE(_net_inet6, IPPROTO_SCTP, sctp6, CTLFLAG_RW, 0, "SCTP6"); -#endif #if defined(IPSEC) || defined(IPSEC_SUPPORT) SYSCTL_NODE(_net_inet6, IPPROTO_ESP, ipsec6, CTLFLAG_RW, 0, "IPSEC6"); #endif /* IPSEC */ Index: sys/netinet6/ip6_forward.c =================================================================== --- sys/netinet6/ip6_forward.c +++ sys/netinet6/ip6_forward.c @@ -352,7 +352,7 @@ CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; #endif Index: sys/netinet6/ip6_output.c =================================================================== --- sys/netinet6/ip6_output.c +++ sys/netinet6/ip6_output.c @@ -113,7 +113,7 @@ #include #include -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) #include #include #endif @@ -918,7 +918,7 @@ CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; #endif @@ -948,7 +948,7 @@ CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; #endif @@ -1015,7 +1015,7 @@ goto bad; } } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (sw_csum & CSUM_SCTP_IPV6) { sw_csum &= ~CSUM_SCTP_IPV6; m = mb_unmapped_to_ext(m); @@ -1120,7 +1120,7 @@ in6_delayed_cksum(m, plen, hlen); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) { m = mb_unmapped_to_ext(m); if (m == NULL) { Index: sys/netinet6/sctp6_usrreq.c =================================================================== --- sys/netinet6/sctp6_usrreq.c +++ sys/netinet6/sctp6_usrreq.c @@ -57,6 +57,10 @@ #include #include +SYSCTL_DECL(_net_inet6); /* XXX should be in a header */ + +SYSCTL_NODE(_net_inet6, IPPROTO_SCTP, sctp6, CTLFLAG_RW, 0, "SCTP6"); + int sctp6_input_with_port(struct mbuf **i_pak, int *offp, uint16_t port) { @@ -1152,7 +1156,7 @@ return (error); } -struct pr_usrreqs sctp6_usrreqs = { +static struct pr_usrreqs sctp6_usrreqs = { .pru_abort = sctp6_abort, .pru_accept = sctp_accept, .pru_attach = sctp6_attach, @@ -1173,4 +1177,30 @@ .pru_soreceive = sctp_soreceive }; +extern struct domain inet6domain; + +struct protosw sctp6_stream_protosw = { + .pr_type = SOCK_STREAM, + .pr_domain = &inet6domain, + .pr_protocol = IPPROTO_SCTP, + .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LASTHDR, + .pr_input = sctp6_input, + .pr_ctlinput = sctp6_ctlinput, + .pr_ctloutput = sctp_ctloutput, + .pr_drain = sctp_drain, + .pr_usrreqs = &sctp6_usrreqs, +}; + +struct protosw sctp6_seqpacket_protosw = { + .pr_type = SOCK_SEQPACKET, + .pr_domain = &inet6domain, + .pr_protocol = IPPROTO_SCTP, + .pr_flags = PR_WANTRCVD|PR_LASTHDR, + .pr_input = sctp6_input, + .pr_ctlinput = sctp6_ctlinput, + .pr_ctloutput = sctp_ctloutput, + .pr_drain = sctp_drain, + .pr_usrreqs = &sctp6_usrreqs, +}; + #endif Index: sys/netinet6/sctp6_var.h =================================================================== --- sys/netinet6/sctp6_var.h +++ sys/netinet6/sctp6_var.h @@ -40,8 +40,7 @@ #if defined(_KERNEL) -SYSCTL_DECL(_net_inet6_sctp6); -extern struct pr_usrreqs sctp6_usrreqs; +extern struct protosw sctp6_stream_protosw, sctp6_seqpacket_protosw; int sctp6_input(struct mbuf **, int *, int); int sctp6_input_with_port(struct mbuf **, int *, uint16_t); Index: sys/netipsec/ipsec_output.c =================================================================== --- sys/netipsec/ipsec_output.c +++ sys/netipsec/ipsec_output.c @@ -71,7 +71,7 @@ #ifdef INET6 #include #endif -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) #include #endif @@ -326,7 +326,7 @@ in_delayed_cksum(m); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP) { struct ip *ip = mtod(m, struct ip *); @@ -621,7 +621,7 @@ sizeof(struct ip6_hdr), sizeof(struct ip6_hdr)); m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) { sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); m->m_pkthdr.csum_flags &= ~CSUM_SCTP_IPV6; Index: sys/netpfil/pf/pf.c =================================================================== --- sys/netpfil/pf/pf.c +++ sys/netpfil/pf/pf.c @@ -40,9 +40,9 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_bpf.h" #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_bpf.h" #include "opt_pf.h" #include "opt_sctp.h" @@ -103,7 +103,7 @@ #include #endif /* INET6 */ -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) #include #endif @@ -5591,7 +5591,7 @@ in_delayed_cksum(m0); m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } -#ifdef SCTP +#if defined(SCTP) || defined(SCTP_SUPPORT) if (m0->m_pkthdr.csum_flags & CSUM_SCTP & ~ifp->if_hwassist) { sctp_delayed_cksum(m0, (uint32_t)(ip->ip_hl << 2)); m0->m_pkthdr.csum_flags &= ~CSUM_SCTP; Index: sys/powerpc/conf/GENERIC =================================================================== --- sys/powerpc/conf/GENERIC +++ sys/powerpc/conf/GENERIC @@ -41,7 +41,7 @@ options IPSEC_SUPPORT # Allow kldload of ipsec and tcpmd5 options TCP_HHOOK # hhook(9) framework for TCP options TCP_RFC7413 # TCP Fast Open -options SCTP #Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS #Berkeley Fast Filesystem options SOFTUPDATES #Enable FFS soft updates support options UFS_ACL #Support for access control lists Index: sys/powerpc/conf/GENERIC64 =================================================================== --- sys/powerpc/conf/GENERIC64 +++ sys/powerpc/conf/GENERIC64 @@ -45,7 +45,7 @@ options TCP_BLACKBOX # Enhanced TCP event logging options TCP_HHOOK # hhook(9) framework for TCP options TCP_RFC7413 # TCP Fast Open -options SCTP #Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS #Berkeley Fast Filesystem options SOFTUPDATES #Enable FFS soft updates support options UFS_ACL #Support for access control lists Index: sys/riscv/conf/GENERIC =================================================================== --- sys/riscv/conf/GENERIC +++ sys/riscv/conf/GENERIC @@ -32,7 +32,7 @@ options TCP_HHOOK # hhook(9) framework for TCP options IPSEC_SUPPORT # Allow kldload of ipsec and tcpmd5 options TCP_OFFLOAD # TCP offload -options SCTP # Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Index: sys/sparc64/conf/GENERIC =================================================================== --- sys/sparc64/conf/GENERIC +++ sys/sparc64/conf/GENERIC @@ -33,7 +33,7 @@ options INET6 # IPv6 communications protocols options IPSEC_SUPPORT # Allow kldload of ipsec and tcpmd5 options TCP_HHOOK # hhook(9) framework for TCP -options SCTP # Stream Control Transmission Protocol +options SCTP_SUPPORT # Allow kldload of SCTP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists