Add the SCTP_SUPPORT kernel option.

This is in preparation for enabling a loadable SCTP stack.  Analogous to
IPSEC/IPSEC_SUPPORT, the SCTP_SUPPORT kernel option must be configured
in order to support a loadable SCTP implementation.

Discussed with:	tuexen
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Mark Johnston 2020-06-18 19:32:34 +00:00
parent ead7e10308
commit 95033af923
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362338
14 changed files with 44 additions and 34 deletions

View File

@ -26,13 +26,16 @@
.\"
.\" $FreeBSD$
.\"
.Dd January 4, 2020
.Dd June 18, 2020
.Dt SCTP 4
.Os
.Sh NAME
.Nm sctp
.Nd Internet Stream Control Transmission Protocol
.Sh SYNOPSIS
.Cd "options SCTP"
.Cd "options SCTP_SUPPORT"
.Pp
.In sys/types.h
.In sys/socket.h
.In netinet/sctp.h

View File

@ -697,7 +697,12 @@ options LIBALIAS
# 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
@ -710,6 +715,7 @@ options SCTP
# 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
@ -733,7 +739,6 @@ options SCTP_PACKET_LOGGING
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

View File

@ -476,6 +476,7 @@ XBONEHACK
# 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

View File

@ -793,7 +793,7 @@ sonewconn(struct socket *head, int connstatus)
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.

View File

@ -94,7 +94,7 @@ static struct pr_usrreqs nousrreqs;
#include <netinet/sctp_pcb.h>
#include <netinet/sctp.h>
#include <netinet/sctp_var.h>
#endif /* SCTP */
#endif
FEATURE(inet, "Internet Protocol version 4");
@ -324,7 +324,7 @@ SYSCTL_NODE(_net_inet, IPPROTO_UDP, udp, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
"UDP");
SYSCTL_NODE(_net_inet, IPPROTO_TCP, tcp, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
"TCP");
#ifdef SCTP
#if defined(SCTP) || defined(SCTP_SUPPORT)
SYSCTL_NODE(_net_inet, IPPROTO_SCTP, sctp, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
"SCTP");
#endif

View File

@ -69,7 +69,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#endif
#ifdef SCTP
#if defined(SCTP) || defined(SCTP_SUPPORT)
#include <netinet/sctp_crc32.h>
#endif
@ -215,7 +215,7 @@ divert_packet(struct mbuf *m, bool incoming)
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;

View File

@ -86,7 +86,7 @@ __FBSDID("$FreeBSD$");
#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
@ -154,7 +154,7 @@ ip_output_pfil(struct mbuf **mp, struct ifnet *ifp, int flags,
}
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
@ -185,7 +185,7 @@ ip_output_pfil(struct mbuf **mp, struct ifnet *ifp, int flags,
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
@ -753,7 +753,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
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) {
@ -905,7 +905,7 @@ ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu,
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) {

View File

@ -37,18 +37,17 @@ __FBSDID("$FreeBSD$");
#include "opt_sctp.h"
#include <sys/gsb_crc32.h>
#ifdef SCTP
#include <netinet/sctp_os.h>
#include <netinet/sctp.h>
#include <netinet/sctp_crc32.h>
#include <netinet/sctp_pcb.h>
#else
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/gsb_crc32.h>
#include <sys/mbuf.h>
#include <netinet/sctp.h>
#include <netinet/sctp_crc32.h>
#ifdef SCTP
#include <netinet/sctp_os.h>
#include <netinet/sctp_crc32.h>
#include <netinet/sctp_pcb.h>
#endif
static uint32_t
@ -117,7 +116,7 @@ sctp_calculate_cksum(struct mbuf *m, uint32_t offset)
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 +127,10 @@ sctp_delayed_cksum(struct mbuf *m, uint32_t offset)
uint32_t checksum;
checksum = sctp_calculate_cksum(m, offset);
#ifdef SCTP
SCTP_STAT_DECR(sctps_sendhwcrc);
SCTP_STAT_INCR(sctps_sendswcrc);
#endif
offset += offsetof(struct sctphdr, checksum);
if (offset + sizeof(uint32_t) > (uint32_t)(m->m_pkthdr.len)) {

View File

@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
#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 */

View File

@ -429,7 +429,7 @@ SYSCTL_NODE(_net_inet6, IPPROTO_UDP, udp6, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
"UDP6");
SYSCTL_NODE(_net_inet6, IPPROTO_TCP, tcp6, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
"TCP6");
#ifdef SCTP
#if defined(SCTP) || defined(SCTP_SUPPORT)
SYSCTL_NODE(_net_inet6, IPPROTO_SCTP, sctp6, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
"SCTP6");
#endif

View File

@ -360,7 +360,7 @@ ip6_forward(struct mbuf *m, int srcrt)
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

View File

@ -114,7 +114,7 @@ __FBSDID("$FreeBSD$");
#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
@ -221,7 +221,7 @@ ip6_output_delayed_csum(struct mbuf *m, struct ifnet *ifp, int csum_flags,
__func__, __LINE__, plen, optlen, m, ifp, csum_flags, frag));
if ((csum_flags & CSUM_DELAY_DATA_IPV6) ||
#ifdef SCTP
#if defined(SCTP) || defined(SCTP_SUPPORT)
(csum_flags & CSUM_SCTP_IPV6) ||
#endif
(!frag && (ifp->if_capenable & IFCAP_NOMAP) == 0)) {
@ -238,7 +238,7 @@ ip6_output_delayed_csum(struct mbuf *m, struct ifnet *ifp, int csum_flags,
sizeof(struct ip6_hdr) + optlen);
m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6;
}
#ifdef SCTP
#if defined(SCTP) || defined(SCTP_SUPPORT)
if (csum_flags & CSUM_SCTP_IPV6) {
sctp_delayed_cksum(m, sizeof(struct ip6_hdr) + optlen);
m->m_pkthdr.csum_flags &= ~CSUM_SCTP_IPV6;
@ -1041,7 +1041,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt,
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
@ -1073,7 +1073,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt,
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

View File

@ -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 @@ ipsec4_common_output(struct mbuf *m, struct inpcb *inp, int forwarding)
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 @@ ipsec6_common_output(struct mbuf *m, struct inpcb *inp, int forwarding)
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;

View File

@ -40,9 +40,9 @@
#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"
@ -103,7 +103,7 @@ __FBSDID("$FreeBSD$");
#include <netinet6/scope6_var.h>
#endif /* INET6 */
#ifdef SCTP
#if defined(SCTP) || defined(SCTP_SUPPORT)
#include <netinet/sctp_crc32.h>
#endif
@ -5474,7 +5474,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
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;