Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add core networking support for SCTP.
details: https://anonhg.NetBSD.org/src/rev/d060174bc8c0
branches: trunk
changeset: 340995:d060174bc8c0
user: rjs <rjs%NetBSD.org@localhost>
date: Tue Oct 13 21:28:34 2015 +0000
description:
Add core networking support for SCTP.
diffstat:
distrib/sets/lists/comp/mi | 4 +-
sys/kern/uipc_socket.c | 50 +-
sys/net/rtsock.c | 18 +-
sys/netinet/Makefile | 3 +-
sys/netinet/files.netinet | 20 +-
sys/netinet/in.h | 3 +-
sys/netinet/in_proto.c | 51 +-
sys/netinet/sctp.h | 301 +
sys/netinet/sctp_asconf.c | 2876 +++++++++++
sys/netinet/sctp_asconf.h | 66 +
sys/netinet/sctp_constants.h | 832 +++
sys/netinet/sctp_crc32.c | 184 +
sys/netinet/sctp_crc32.h | 49 +
sys/netinet/sctp_hashdriver.c | 265 +
sys/netinet/sctp_hashdriver.h | 43 +
sys/netinet/sctp_header.h | 489 +
sys/netinet/sctp_indata.c | 4704 ++++++++++++++++++
sys/netinet/sctp_indata.h | 63 +
sys/netinet/sctp_input.c | 4300 ++++++++++++++++
sys/netinet/sctp_input.h | 45 +
sys/netinet/sctp_output.c | 10179 ++++++++++++++++++++++++++++++++++++++++
sys/netinet/sctp_output.h | 122 +
sys/netinet/sctp_pcb.c | 4818 ++++++++++++++++++
sys/netinet/sctp_pcb.h | 761 ++
sys/netinet/sctp_peeloff.c | 200 +
sys/netinet/sctp_peeloff.h | 50 +
sys/netinet/sctp_structs.h | 648 ++
sys/netinet/sctp_timer.c | 1534 ++++++
sys/netinet/sctp_timer.h | 74 +
sys/netinet/sctp_uio.h | 524 ++
sys/netinet/sctp_usrreq.c | 4021 +++++++++++++++
sys/netinet/sctp_var.h | 243 +
sys/netinet/sctputil.c | 3742 ++++++++++++++
sys/netinet/sctputil.h | 279 +
sys/netinet6/files.netinet6 | 4 +-
sys/netinet6/in6_proto.c | 50 +-
sys/netinet6/sctp6_usrreq.c | 1355 +++++
sys/netinet6/sctp6_var.h | 51 +
sys/sys/mbuf.h | 3 +-
sys/sys/protosw.h | 4 +-
sys/sys/socket.h | 3 +-
41 files changed, 43010 insertions(+), 21 deletions(-)
diffs (truncated from 43430 to 300 lines):
diff -r 81c689503db4 -r d060174bc8c0 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Tue Oct 13 20:49:39 2015 +0000
+++ b/distrib/sets/lists/comp/mi Tue Oct 13 21:28:34 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1996 2015/10/02 05:22:49 msaitoh Exp $
+# $NetBSD: mi,v 1.1997 2015/10/13 21:28:34 rjs Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -2290,6 +2290,8 @@
./usr/include/netinet/pim_var.h comp-c-include
./usr/include/netinet/portalgo.h comp-c-include
./usr/include/netinet/rfc6056.h comp-obsolete obsolete
+./usr/include/netinet/sctp.h comp-c-include
+./usr/include/netinet/sctp_uio.h comp-c-include
./usr/include/netinet/tcp.h comp-c-include
./usr/include/netinet/tcp_debug.h comp-c-include
./usr/include/netinet/tcp_fsm.h comp-c-include
diff -r 81c689503db4 -r d060174bc8c0 sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c Tue Oct 13 20:49:39 2015 +0000
+++ b/sys/kern/uipc_socket.c Tue Oct 13 21:28:34 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket.c,v 1.246 2015/08/24 22:21:26 pooka Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.247 2015/10/13 21:28:35 rjs Exp $ */
/*-
* Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.246 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.247 2015/10/13 21:28:35 rjs Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -80,6 +80,7 @@
#include "opt_mbuftrace.h"
#include "opt_somaxkva.h"
#include "opt_multiprocessor.h" /* XXX */
+#include "opt_sctp.h"
#endif
#include <sys/param.h>
@@ -644,6 +645,7 @@
solisten(struct socket *so, int backlog, struct lwp *l)
{
int error;
+ short oldopt, oldqlimit;
solock(so);
if ((so->so_state & (SS_ISCONNECTED | SS_ISCONNECTING |
@@ -651,16 +653,21 @@
sounlock(so);
return EINVAL;
}
- error = (*so->so_proto->pr_usrreqs->pr_listen)(so, l);
- if (error != 0) {
- sounlock(so);
- return error;
- }
+ oldopt = so->so_options;
+ oldqlimit = so->so_qlimit;
if (TAILQ_EMPTY(&so->so_q))
so->so_options |= SO_ACCEPTCONN;
if (backlog < 0)
backlog = 0;
so->so_qlimit = min(backlog, somaxconn);
+
+ error = (*so->so_proto->pr_usrreqs->pr_listen)(so, l);
+ if (error != 0) {
+ so->so_options = oldopt;
+ so->so_qlimit = oldqlimit;
+ sounlock(so);
+ return error;
+ }
sounlock(so);
return 0;
}
@@ -1323,6 +1330,31 @@
sbsync(&so->so_rcv, nextrecord);
}
}
+ if (pr->pr_flags & PR_ADDR_OPT) {
+ /*
+ * For SCTP we may be getting a
+ * whole message OR a partial delivery.
+ */
+ if (m->m_type == MT_SONAME) {
+ orig_resid = 0;
+ if (flags & MSG_PEEK) {
+ if (paddr)
+ *paddr = m_copy(m, 0, m->m_len);
+ m = m->m_next;
+ } else {
+ sbfree(&so->so_rcv, m);
+ if (paddr) {
+ *paddr = m;
+ so->so_rcv.sb_mb = m->m_next;
+ m->m_next = 0;
+ m = so->so_rcv.sb_mb;
+ } else {
+ MFREE(m, so->so_rcv.sb_mb);
+ m = so->so_rcv.sb_mb;
+ }
+ }
+ }
+ }
/*
* Process one or more MT_CONTROL mbufs present before any data mbufs
@@ -1457,6 +1489,10 @@
if (len == m->m_len - moff) {
if (m->m_flags & M_EOR)
flags |= MSG_EOR;
+#ifdef SCTP
+ if (m->m_flags & M_NOTIFICATION)
+ flags |= MSG_NOTIFICATION;
+#endif /* SCTP */
if (flags & MSG_PEEK) {
m = m->m_next;
moff = 0;
diff -r 81c689503db4 -r d060174bc8c0 sys/net/rtsock.c
--- a/sys/net/rtsock.c Tue Oct 13 20:49:39 2015 +0000
+++ b/sys/net/rtsock.c Tue Oct 13 21:28:34 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock.c,v 1.173 2015/08/07 08:11:33 ozaki-r Exp $ */
+/* $NetBSD: rtsock.c,v 1.174 2015/10/13 21:28:34 rjs Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,12 +61,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.173 2015/08/07 08:11:33 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.174 2015/10/13 21:28:34 rjs Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
#include "opt_mpls.h"
#include "opt_compat_netbsd.h"
+#include "opt_sctp.h"
#endif
#include <sys/param.h>
@@ -90,6 +91,11 @@
#include <netmpls/mpls.h>
+#ifdef SCTP
+extern void sctp_add_ip_address(struct ifaddr *);
+extern void sctp_delete_ip_address(struct ifaddr *);
+#endif
+
#if defined(COMPAT_14) || defined(COMPAT_50)
#include <compat/net/if.h>
#include <compat/net/route.h>
@@ -1056,6 +1062,14 @@
KASSERT(ifa != NULL);
ifp = ifa->ifa_ifp;
+#ifdef SCTP
+ if (cmd == RTM_ADD) {
+ sctp_add_ip_address(ifa);
+ } else if (cmd == RTM_DELETE) {
+ sctp_delete_ip_address(ifa);
+ }
+#endif
+
COMPATCALL(rt_newaddrmsg, (cmd, ifa, error, rt));
if (COMPATNAME(route_info).ri_cb.any_count == 0)
return;
diff -r 81c689503db4 -r d060174bc8c0 sys/netinet/Makefile
--- a/sys/netinet/Makefile Tue Oct 13 20:49:39 2015 +0000
+++ b/sys/netinet/Makefile Tue Oct 13 21:28:34 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.26 2015/02/10 19:11:52 rjs Exp $
+# $NetBSD: Makefile,v 1.27 2015/10/13 21:28:35 rjs Exp $
INCSDIR= /usr/include/netinet
@@ -7,6 +7,7 @@
in_selsrc.h in_systm.h \
in_var.h ip.h ip_carp.h ip6.h ip_ecn.h ip_encap.h \
ip_icmp.h ip_mroute.h ip_var.h pim.h pim_var.h portalgo.h \
+ sctp.h sctp_uio.h \
tcp.h tcp_debug.h tcp_fsm.h tcp_seq.h tcp_timer.h tcp_var.h \
tcpip.h udp.h udp_var.h \
tcp_vtw.h
diff -r 81c689503db4 -r d060174bc8c0 sys/netinet/files.netinet
--- a/sys/netinet/files.netinet Tue Oct 13 20:49:39 2015 +0000
+++ b/sys/netinet/files.netinet Tue Oct 13 21:28:34 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.netinet,v 1.26 2015/02/10 19:11:52 rjs Exp $
+# $NetBSD: files.netinet,v 1.27 2015/10/13 21:28:35 rjs Exp $
defflag opt_tcp_debug.h TCP_DEBUG
defparam opt_tcp_debug.h TCP_NDEBUG
@@ -20,6 +20,12 @@
defflag opt_dccp.h DCCP DCCP_TFRC DCCPSTATES DCCPBHASHSIZE
DCCP_DEBUG_ON ACKDEBUG
+defflag opt_sctp.h SCTP SCTP_DEBUG SCTP_WITH_NO_CSUM
+ SCTP_LOCK_LOGGING SCTP_MBUF_LOGGING
+ SCTP_MBCNT_LOGGING SCTP_PACKET_LOGGING
+ SCTP_LTRACE_CHUNKS SCTP_LTRACE_ERRORS
+ SCTP_USE_PERCPU_STAT SCTP_MCORE_INPUT
+
file netinet/igmp.c inet
file netinet/in.c inet
file netinet/in_offload.c inet
@@ -53,3 +59,15 @@
file netinet/dccp_tcplike.c inet & dccp | inet6 & dccp
file netinet/dccp_tfrc.c inet & dccp | inet6 & dccp
file netinet/dccp_usrreq.c inet & dccp | inet6 & dccp
+
+file netinet/sctp_asconf.c inet & sctp | inet6 & sctp
+file netinet/sctp_crc32.c inet & sctp | inet6 & sctp
+file netinet/sctp_hashdriver.c inet & sctp | inet6 & sctp
+file netinet/sctp_indata.c inet & sctp | inet6 & sctp
+file netinet/sctp_input.c inet & sctp | inet6 & sctp
+file netinet/sctp_output.c inet & sctp | inet6 & sctp
+file netinet/sctp_pcb.c inet & sctp | inet6 & sctp
+file netinet/sctp_peeloff.c inet & sctp | inet6 & sctp
+file netinet/sctp_timer.c inet & sctp | inet6 & sctp
+file netinet/sctp_usrreq.c inet & sctp | inet6 & sctp
+file netinet/sctputil.c inet & sctp | inet6 & sctp
diff -r 81c689503db4 -r d060174bc8c0 sys/netinet/in.h
--- a/sys/netinet/in.h Tue Oct 13 20:49:39 2015 +0000
+++ b/sys/netinet/in.h Tue Oct 13 21:28:34 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in.h,v 1.97 2015/05/02 14:41:32 roy Exp $ */
+/* $NetBSD: in.h,v 1.98 2015/10/13 21:28:35 rjs Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@@ -105,6 +105,7 @@
#define IPPROTO_IPCOMP 108 /* IP Payload Comp. Protocol */
#define IPPROTO_VRRP 112 /* VRRP RFC 2338 */
#define IPPROTO_CARP 112 /* Common Address Resolution Protocol */
+#define IPPROTO_SCTP 132 /* SCTP */
#define IPPROTO_PFSYNC 240 /* PFSYNC */
#define IPPROTO_RAW 255 /* raw IP packet */
#define IPPROTO_MAX 256
diff -r 81c689503db4 -r d060174bc8c0 sys/netinet/in_proto.c
--- a/sys/netinet/in_proto.c Tue Oct 13 20:49:39 2015 +0000
+++ b/sys/netinet/in_proto.c Tue Oct 13 21:28:34 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in_proto.c,v 1.114 2015/08/31 08:05:20 ozaki-r Exp $ */
+/* $NetBSD: in_proto.c,v 1.115 2015/10/13 21:28:35 rjs Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.114 2015/08/31 08:05:20 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.115 2015/10/13 21:28:35 rjs Exp $");
#ifdef _KERNEL_OPT
#include "opt_mrouting.h"
@@ -70,6 +70,7 @@
#include "opt_pim.h"
#include "opt_gateway.h"
#include "opt_dccp.h"
+#include "opt_sctp.h"
#include "opt_compat_netbsd.h"
#endif
@@ -120,6 +121,11 @@
#include <netinet/dccp_var.h>
#endif
+#ifdef SCTP
+#include <netinet/sctp.h>
+#include <netinet/sctp_var.h>
+#endif
+
/*
* TCP/IP protocol family: IP, ICMP, UDP, TCP.
*/
@@ -173,6 +179,14 @@
#define dccp_ctloutput dccp_ctloutput_wrapper
#endif
+#ifdef SCTP
+PR_WRAP_CTLINPUT(sctp_ctlinput)
+PR_WRAP_CTLOUTPUT(sctp_ctloutput)
+
+#define sctp_ctlinput sctp_ctlinput_wrapper
+#define sctp_ctloutput sctp_ctloutput_wrapper
+#endif
+
#if defined(IPSEC)
PR_WRAP_CTLINPUT(ah4_ctlinput)
@@ -224,6 +238,39 @@
.pr_init = dccp_init,
Home |
Main Index |
Thread Index |
Old Index