Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151881372
D21997.id63186.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
28 KB
Referenced Files
None
Subscribers
None
D21997.id63186.diff
View Options
Index: sys/conf/NOTES
===================================================================
--- sys/conf/NOTES
+++ sys/conf/NOTES
@@ -684,8 +684,11 @@
# dual stacked and so far we have not torn apart
# the V6 and V4.. since an association can span
# both a V6 and V4 address at the SAME time :-)
+# XXX
#
options SCTP
+options SCTP_SUPPORT
+
# There are bunches of options:
# this one turns on all sorts of
# nastily printing that you can
@@ -698,6 +701,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 +725,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 opt_sctp.h
SCTP_DEBUG opt_sctp.h # Enable debug printfs
+SCTP_SUPPORT opt_sctp.h # XXX
SCTP_LOCK_LOGGING opt_sctp.h # Log to KTR lock activity
SCTP_MBUF_LOGGING opt_sctp.h # Log to KTR general mbuf aloc/free
SCTP_MBCNT_LOGGING opt_sctp.h # Log to KTR mbcnt activity
Index: sys/dev/xen/netback/netback.c
===================================================================
--- sys/dev/xen/netback/netback.c
+++ sys/dev/xen/netback/netback.c
@@ -46,8 +46,6 @@
#include "opt_inet.h"
#include "opt_inet6.h"
-#include "opt_sctp.h"
-
#include <sys/param.h>
#include <sys/kernel.h>
Index: sys/kern/uipc_socket.c
===================================================================
--- sys/kern/uipc_socket.c
+++ sys/kern/uipc_socket.c
@@ -692,7 +692,7 @@
return (so);
}
-#ifdef SCTP
+#ifdef SCTP_SUPPORT
/*
* Socket part of sctp_peeloff(). Detach a new socket from an
* association. The new socket is returned with a reference.
Index: sys/modules/pf/Makefile
===================================================================
--- sys/modules/pf/Makefile
+++ sys/modules/pf/Makefile
@@ -6,7 +6,7 @@
SRCS= pf.c pf_if.c pf_lb.c pf_osfp.c pf_ioctl.c pf_norm.c pf_table.c \
pf_ruleset.c in4_cksum.c \
bus_if.h device_if.h \
- opt_pf.h opt_inet.h opt_inet6.h opt_bpf.h opt_global.h
+ opt_pf.h opt_inet.h opt_inet6.h opt_bpf.h opt_sctp.h opt_global.h
.if !defined(KERNBUILDDIR)
# pflog can be loaded as a module, have the additional checks turned on
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 <bsd.kmod.mk>
Index: sys/net/route.c
===================================================================
--- sys/net/route.c
+++ sys/net/route.c
@@ -38,10 +38,9 @@
#include "opt_inet.h"
#include "opt_inet6.h"
-#include "opt_route.h"
-#include "opt_sctp.h"
#include "opt_mrouting.h"
#include "opt_mpath.h"
+#include "opt_route.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -90,13 +89,6 @@
#define RT_NUMFIBS 1
#endif
-#if defined(INET) || defined(INET6)
-#ifdef SCTP
-extern void sctp_addr_change(struct ifaddr *ifa, int cmd);
-#endif /* SCTP */
-#endif
-
-
/* This is read-only.. */
u_int rt_numfibs = RT_NUMFIBS;
SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RDTUN, &rt_numfibs, 0, "");
@@ -140,6 +132,8 @@
VNET_DEFINE_STATIC(uma_zone_t, rtzone); /* Routing table UMA zone. */
#define V_rtzone VNET(rtzone)
+EVENTHANDLER_LIST_DEFINE(rt_addrmsg);
+
static int rtrequest1_fib_change(struct rib_head *, struct rt_addrinfo *,
struct rtentry **, u_int);
static void rt_setmetrics(const struct rt_addrinfo *, struct rtentry *);
@@ -2225,20 +2219,10 @@
KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE,
("unexpected cmd %d", cmd));
-
KASSERT(fibnum == RT_ALL_FIBS || (fibnum >= 0 && fibnum < rt_numfibs),
("%s: fib out of range 0 <=%d<%d", __func__, fibnum, rt_numfibs));
-#if defined(INET) || defined(INET6)
-#ifdef SCTP
- /*
- * notify the SCTP stack
- * this will only get called when an address is added/deleted
- * XXX pass the ifaddr struct instead if ifa->ifa_addr...
- */
- sctp_addr_change(ifa, cmd);
-#endif /* SCTP */
-#endif
+ EVENTHANDLER_DIRECT_INVOKE(rt_addrmsg, ifa, cmd);
return (rtsock_addrmsg(cmd, ifa, fibnum));
}
Index: sys/netinet/in_kdtrace.c
===================================================================
--- sys/netinet/in_kdtrace.c
+++ sys/netinet/in_kdtrace.c
@@ -31,16 +31,11 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "opt_sctp.h"
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sdt.h>
SDT_PROVIDER_DEFINE(ip);
-#ifdef SCTP
-SDT_PROVIDER_DEFINE(sctp);
-#endif
SDT_PROVIDER_DEFINE(tcp);
SDT_PROVIDER_DEFINE(udp);
SDT_PROVIDER_DEFINE(udplite);
@@ -61,30 +56,6 @@
"struct ip *", "ipv4info_t *",
"struct ip6_hdr *", "ipv6info_t *");
-#ifdef SCTP
-SDT_PROBE_DEFINE5_XLATE(sctp, , , receive,
- "void *", "pktinfo_t *",
- "struct sctp_tcb *", "csinfo_t *",
- "struct mbuf *", "ipinfo_t *",
- "struct sctp_tcb *", "sctpsinfo_t *" ,
- "struct sctphdr *", "sctpinfo_t *");
-
-SDT_PROBE_DEFINE5_XLATE(sctp, , , send,
- "void *", "pktinfo_t *",
- "struct sctp_tcb *", "csinfo_t *",
- "uint8_t *", "ipinfo_t *",
- "struct sctp_tcb *", "sctpsinfo_t *" ,
- "struct sctphdr *", "sctpinfo_t *");
-
-SDT_PROBE_DEFINE6_XLATE(sctp, , , state__change,
- "void *", "void *",
- "struct sctp_tcb *", "csinfo_t *",
- "void *", "void *",
- "struct sctp_tcb *", "sctpsinfo_t *",
- "void *", "void *",
- "int", "sctplsinfo_t *");
-#endif
-
SDT_PROBE_DEFINE5_XLATE(tcp, , , accept__established,
"void *", "pktinfo_t *",
"struct tcpcb *", "csinfo_t *",
Index: sys/netinet/in_proto.c
===================================================================
--- sys/netinet/in_proto.c
+++ sys/netinet/in_proto.c
@@ -34,11 +34,10 @@
#include <sys/cdefs.h>
__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 <sys/param.h>
@@ -92,13 +91,6 @@
static struct pr_usrreqs nousrreqs;
-#ifdef SCTP
-#include <netinet/in_pcb.h>
-#include <netinet/sctp_pcb.h>
-#include <netinet/sctp.h>
-#include <netinet/sctp_var.h>
-#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 <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#endif
-#ifdef SCTP
+#if defined(SCTP) || defined(SCTP_SUPPORT)
#include <netinet/sctp_crc32.h>
#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 <netinet/udp.h>
#include <netinet/udp_var.h>
-#ifdef SCTP
+#if defined(SCTP) || defined(SCTP_SUPPORT)
#include <netinet/sctp.h>
#include <netinet/sctp_crc32.h>
#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_bsd_addr.h
===================================================================
--- sys/netinet/sctp_bsd_addr.h
+++ sys/netinet/sctp_bsd_addr.h
@@ -59,7 +59,7 @@
#endif
-void sctp_addr_change(struct ifaddr *ifa, int cmd);
+void sctp_addr_change(void *dummy, struct ifaddr *ifa, int cmd);
void sctp_add_or_del_interfaces(int (*pred) (struct ifnet *), int add);
Index: sys/netinet/sctp_bsd_addr.c
===================================================================
--- sys/netinet/sctp_bsd_addr.c
+++ sys/netinet/sctp_bsd_addr.c
@@ -290,7 +290,7 @@
}
void
-sctp_addr_change(struct ifaddr *ifa, int cmd)
+sctp_addr_change(void *arg __unused, struct ifaddr *ifa, int cmd)
{
uint32_t ifa_flags = 0;
@@ -359,7 +359,8 @@
}
void
- sctp_add_or_del_interfaces(int (*pred) (struct ifnet *), int add){
+sctp_add_or_del_interfaces(int (*pred) (struct ifnet *), int add)
+{
struct ifnet *ifn;
struct ifaddr *ifa;
@@ -369,7 +370,7 @@
continue;
}
CK_STAILQ_FOREACH(ifa, &ifn->if_addrhead, ifa_link) {
- sctp_addr_change(ifa, add ? RTM_ADD : RTM_DELETE);
+ sctp_addr_change(NULL, ifa, add ? RTM_ADD : RTM_DELETE);
}
}
IFNET_RUNLOCK();
Index: sys/netinet/sctp_crc32.h
===================================================================
--- sys/netinet/sctp_crc32.h
+++ sys/netinet/sctp_crc32.h
@@ -30,17 +30,16 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#ifndef _NETINET_SCTP_CRC32_H_
#define _NETINET_SCTP_CRC32_H_
#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 <sys/gsb_crc32.h>
-#ifdef SCTP
+#if defined(SCTP) || defined(SCTP_SUPPORT)
#include <netinet/sctp_os.h>
#include <netinet/sctp.h>
#include <netinet/sctp_crc32.h>
@@ -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_kdtrace.c
===================================================================
--- sys/netinet/sctp_kdtrace.c
+++ sys/netinet/sctp_kdtrace.c
@@ -34,13 +34,11 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#ifndef _NETINET_SCTP_DTRACE_DEFINE_H_
-#define _NETINET_SCTP_DTRACE_DEFINE_H_
-
+#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/sdt.h>
-SDT_PROVIDER_DECLARE(sctp);
+SDT_PROVIDER_DEFINE(sctp);
/********************************************************/
/* Cwnd probe - tracks changes in the congestion window on a netp */
@@ -174,4 +172,27 @@
"int", /* The up/down amount */
"int"); /* The new value of the cwnd */
-#endif
+/*
+ * Standard Solaris-compatible probes.
+ */
+SDT_PROBE_DEFINE5_XLATE(sctp, , , receive,
+ "void *", "pktinfo_t *",
+ "struct sctp_tcb *", "csinfo_t *",
+ "struct mbuf *", "ipinfo_t *",
+ "struct sctp_tcb *", "sctpsinfo_t *" ,
+ "struct sctphdr *", "sctpinfo_t *");
+
+SDT_PROBE_DEFINE5_XLATE(sctp, , , send,
+ "void *", "pktinfo_t *",
+ "struct sctp_tcb *", "csinfo_t *",
+ "uint8_t *", "ipinfo_t *",
+ "struct sctp_tcb *", "sctpsinfo_t *" ,
+ "struct sctphdr *", "sctpinfo_t *");
+
+SDT_PROBE_DEFINE6_XLATE(sctp, , , state__change,
+ "void *", "void *",
+ "struct sctp_tcb *", "csinfo_t *",
+ "void *", "void *",
+ "struct sctp_tcb *", "sctpsinfo_t *",
+ "void *", "void *",
+ "int", "sctplsinfo_t *");
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 <sys/param.h>
+#include <sys/domain.h>
+#include <sys/eventhandler.h>
#include <sys/ktr.h>
#include <sys/systm.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/mbuf.h>
@@ -83,7 +86,6 @@
#include <netinet/icmp_var.h>
#ifdef INET6
-#include <sys/domain.h>
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#include <netinet6/in6_pcb.h>
@@ -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_pcb.c
===================================================================
--- sys/netinet/sctp_pcb.c
+++ sys/netinet/sctp_pcb.c
@@ -47,7 +47,6 @@
#include <netinet/sctp_output.h>
#include <netinet/sctp_timer.h>
#include <netinet/sctp_bsd_addr.h>
-#include <netinet/sctp_dtrace_define.h>
#if defined(INET) || defined(INET6)
#include <netinet/udp.h>
#endif
Index: sys/netinet/sctp_syscalls.c
===================================================================
--- sys/netinet/sctp_syscalls.c
+++ sys/netinet/sctp_syscalls.c
@@ -78,6 +78,7 @@
#include <security/mac/mac_framework.h>
#include <netinet/sctp.h>
+#include <netinet/sctp_os_bsd.h>
#include <netinet/sctp_peeloff.h>
static struct syscall_helper_data sctp_syscalls[] = {
@@ -88,28 +89,42 @@
SYSCALL_INIT_LAST
};
-static void
-sctp_syscalls_init(void *unused __unused)
+int
+sctp_syscalls_init(void)
+{
+ int error;
+
+ 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_KLD);
+ if (error != 0)
+ return (error);
+#endif
+ return (0);
+}
+
+int
+sctp_syscalls_uninit(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_unregister(sctp_syscalls);
+ 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_unregister(sctp_syscalls);
+ if (error != 0)
+ return (error);
#endif
+ 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 +134,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 +196,7 @@
fdrop(headfp, td);
done2:
return (error);
-#else /* SCTP */
- return (EOPNOTSUPP);
-#endif /* SCTP */
+#endif
}
int
@@ -199,7 +212,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 +307,7 @@
sctp_bad2:
free(to, M_SONAME);
return (error);
-#else /* SCTP */
- return (EOPNOTSUPP);
-#endif /* SCTP */
+#endif
}
int
@@ -312,7 +323,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 +435,7 @@
sctp_bad2:
free(to, M_SONAME);
return (error);
-#else /* SCTP */
- return (EOPNOTSUPP);
-#endif /* SCTP */
+#endif
}
int
@@ -442,7 +451,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 +581,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
@@ -54,15 +54,51 @@
#include <netinet/sctp_bsd_addr.h>
#include <netinet/udp.h>
-
-
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 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);
/* Initialize and modify the sysctled variables */
sctp_init_sysctls();
@@ -89,8 +125,56 @@
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, NULL,
+ EVENTHANDLER_PRI_FIRST);
+
+ return (sctp_syscalls_init());
}
+static int
+sctp_uninit(void)
+{
+ int 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);
+
+ 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 <netinet6/pim6_var.h>
#include <netinet6/nd6.h>
-#ifdef SCTP
-#include <netinet/in_pcb.h>
-#include <netinet/sctp_pcb.h>
-#include <netinet/sctp.h>
-#include <netinet/sctp_var.h>
-#include <netinet6/sctp6_var.h>
-#endif /* SCTP */
-
#include <netinet6/ip6protosw.h>
/*
@@ -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
@@ -38,6 +38,7 @@
#include "opt_inet6.h"
#include "opt_ipsec.h"
#include "opt_ipstealth.h"
+#include "opt_sctp.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -351,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 <netinet6/in6_rss.h>
#include <netipsec/ipsec_support.h>
-#ifdef SCTP
+#if defined(SCTP) || defined(SCTP_SUPPORT)
#include <netinet/sctp.h>
#include <netinet/sctp_crc32.h>
#endif
@@ -915,7 +915,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
@@ -945,7 +945,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
@@ -1012,7 +1012,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);
@@ -1117,7 +1117,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,7 +57,9 @@
#include <netinet/icmp6.h>
#include <netinet/udp.h>
-extern struct protosw inetsw[];
+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)
Index: sys/netipsec/ipsec_output.c
===================================================================
--- sys/netipsec/ipsec_output.c
+++ sys/netipsec/ipsec_output.c
@@ -71,7 +71,7 @@
#ifdef INET6
#include <netinet/icmp6.h>
#endif
-#ifdef SCTP
+#if defined(SCTP) || defined(SCTP_SUPPORT)
#include <netinet/sctp_crc32.h>
#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,10 +40,11 @@
#include <sys/cdefs.h>
__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"
#include <sys/param.h>
#include <sys/bus.h>
@@ -5586,7 +5587,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(m, (uint32_t)(ip->ip_hl << 2));
m0->m_pkthdr.csum_flags &= ~CSUM_SCTP;
Index: sys/sys/eventhandler.h
===================================================================
--- sys/sys/eventhandler.h
+++ sys/sys/eventhandler.h
@@ -312,4 +312,9 @@
EVENTHANDLER_DECLARE(device_attach, device_attach_fn);
EVENTHANDLER_DECLARE(device_detach, device_detach_fn);
+/* Interface address addition and removal event */
+struct ifaddr;
+typedef void (*rt_addrmsg_fn)(void *, struct ifaddr *, int);
+EVENTHANDLER_DECLARE(rt_addrmsg, rt_addrmsg_fn);
+
#endif /* _SYS_EVENTHANDLER_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 12, 7:55 AM (4 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31336985
Default Alt Text
D21997.id63186.diff (28 KB)
Attached To
Mode
D21997: Allow SCTP to be build as a module
Attached
Detach File
Event Timeline
Log In to Comment