summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorrrs <rrs@FreeBSD.org>2008-07-09 16:45:30 +0000
committerrrs <rrs@FreeBSD.org>2008-07-09 16:45:30 +0000
commita51aa927fad5ab9ebbb294340935d462f68ee19b (patch)
tree4a87f4aa4fe465871cb0aabaa4a65bf4595791b3 /sys/netinet
parentc0ef832fd278f80304905d075e4657c1a92b196b (diff)
downloadFreeBSD-src-a51aa927fad5ab9ebbb294340935d462f68ee19b.zip
FreeBSD-src-a51aa927fad5ab9ebbb294340935d462f68ee19b.tar.gz
1) Adds the rest of the VIMAGE change macros
2) Adds some __UserSpace__ on some of the common defines that the user space code needs 3) Fixes a bug when we send up data to a user that failed. We need to a) trim off the data chunk headers, if present, and b) make sure the frag bit is communicated properly for the msgs coming off the stream queues... i.e. we see if some of the msg has been taken. Obtained from: jeli contributed the VIMAGE changes on this pass Thanks Julain!
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/sctp_asconf.c4
-rw-r--r--sys/netinet/sctp_asconf.h2
-rw-r--r--sys/netinet/sctp_bsd_addr.c13
-rw-r--r--sys/netinet/sctp_bsd_addr.h2
-rw-r--r--sys/netinet/sctp_cc_functions.h2
-rw-r--r--sys/netinet/sctp_constants.h4
-rw-r--r--sys/netinet/sctp_crc32.h2
-rw-r--r--sys/netinet/sctp_indata.c4
-rw-r--r--sys/netinet/sctp_indata.h2
-rw-r--r--sys/netinet/sctp_input.c8
-rw-r--r--sys/netinet/sctp_input.h2
-rw-r--r--sys/netinet/sctp_os_bsd.h23
-rw-r--r--sys/netinet/sctp_output.c30
-rw-r--r--sys/netinet/sctp_output.h5
-rw-r--r--sys/netinet/sctp_pcb.c28
-rw-r--r--sys/netinet/sctp_pcb.h3
-rw-r--r--sys/netinet/sctp_sysctl.h2
-rw-r--r--sys/netinet/sctp_timer.c6
-rw-r--r--sys/netinet/sctp_timer.h2
-rw-r--r--sys/netinet/sctp_uio.h4
-rw-r--r--sys/netinet/sctp_usrreq.c5
-rw-r--r--sys/netinet/sctp_var.h2
-rw-r--r--sys/netinet/sctputil.c36
-rw-r--r--sys/netinet/sctputil.h2
24 files changed, 121 insertions, 72 deletions
diff --git a/sys/netinet/sctp_asconf.c b/sys/netinet/sctp_asconf.c
index 18e073d..d28e3bd 100644
--- a/sys/netinet/sctp_asconf.c
+++ b/sys/netinet/sctp_asconf.c
@@ -877,7 +877,9 @@ send_reply:
*/
/* we probably don't need these operations */
(void)sa6_recoverscope(from6);
- sa6_embedscope(from6, ip6_use_defzone);
+ sa6_embedscope(from6,
+ MODULE_GLOBAL(MOD_INET6, ip6_use_defzone));
+
break;
}
#endif
diff --git a/sys/netinet/sctp_asconf.h b/sys/netinet/sctp_asconf.h
index 12f1281..1a3f7ff 100644
--- a/sys/netinet/sctp_asconf.h
+++ b/sys/netinet/sctp_asconf.h
@@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef _NETINET_SCTP_ASCONF_H_
#define _NETINET_SCTP_ASCONF_H_
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
/*
* function prototypes
diff --git a/sys/netinet/sctp_bsd_addr.c b/sys/netinet/sctp_bsd_addr.c
index d1003fa..03de58e 100644
--- a/sys/netinet/sctp_bsd_addr.c
+++ b/sys/netinet/sctp_bsd_addr.c
@@ -79,7 +79,6 @@ MALLOC_DEFINE(SCTP_M_MVRF, "sctp_mvrf", "sctp mvrf pcb list");
MALLOC_DEFINE(SCTP_M_ITER, "sctp_iter", "sctp iterator control");
MALLOC_DEFINE(SCTP_M_SOCKOPT, "sctp_socko", "sctp socket option");
-
#if defined(SCTP_USE_THREAD_BASED_ITERATOR)
void
sctp_wakeup_iterator(void)
@@ -116,6 +115,7 @@ sctp_startup_iterator(void)
#endif
#ifdef INET6
+
void
sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa)
{
@@ -123,7 +123,7 @@ sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa)
ifa6 = (struct in6_ifaddr *)ifa->ifa;
ifa->flags = ifa6->ia6_flags;
- if (!ip6_use_deprecated) {
+ if (!MODULE_GLOBAL(MOD_INET6, ip6_use_deprecated)) {
if (ifa->flags &
IN6_IFF_DEPRECATED) {
ifa->localifa_flags |= SCTP_ADDR_IFA_UNUSEABLE;
@@ -143,7 +143,7 @@ sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa)
}
}
-#endif
+#endif /* INET6 */
static uint32_t
@@ -189,6 +189,8 @@ sctp_is_desired_interface_type(struct ifaddr *ifa)
static void
sctp_init_ifns_for_vrf(int vrfid)
{
+
+
/*
* Here we must apply ANY locks needed by the IFN we access and also
* make sure we lock any IFA that exists as we float through the
@@ -200,8 +202,9 @@ sctp_init_ifns_for_vrf(int vrfid)
struct sctp_ifa *sctp_ifa;
uint32_t ifa_flags;
- TAILQ_FOREACH(ifn, &ifnet, if_list) {
+ TAILQ_FOREACH(ifn, &MODULE_GLOBAL(MOD_NET, ifnet), if_list) {
TAILQ_FOREACH(ifa, &ifn->if_addrlist, ifa_list) {
+
if (ifa->ifa_addr == NULL) {
continue;
}
@@ -329,7 +332,7 @@ void
struct ifnet *ifn;
struct ifaddr *ifa;
- TAILQ_FOREACH(ifn, &ifnet, if_list) {
+ TAILQ_FOREACH(ifn, &MODULE_GLOBAL(MOD_NET, ifnet), if_list) {
if (!(*pred) (ifn)) {
continue;
}
diff --git a/sys/netinet/sctp_bsd_addr.h b/sys/netinet/sctp_bsd_addr.h
index f8bf375..2260cf9 100644
--- a/sys/netinet/sctp_bsd_addr.h
+++ b/sys/netinet/sctp_bsd_addr.h
@@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$");
#define __sctp_bsd_addr_h__
#include <netinet/sctp_pcb.h>
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
#if defined(SCTP_USE_THREAD_BASED_ITERATOR)
void sctp_wakeup_iterator(void);
diff --git a/sys/netinet/sctp_cc_functions.h b/sys/netinet/sctp_cc_functions.h
index 5d27aef..1a681ad 100644
--- a/sys/netinet/sctp_cc_functions.h
+++ b/sys/netinet/sctp_cc_functions.h
@@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$");
#ifndef __sctp_cc_functions_h__
#define __sctp_cc_functions_h__
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
void
sctp_set_initial_cc_param(struct sctp_tcb *stcb,
diff --git a/sys/netinet/sctp_constants.h b/sys/netinet/sctp_constants.h
index 9f628b8..75c9839 100644
--- a/sys/netinet/sctp_constants.h
+++ b/sys/netinet/sctp_constants.h
@@ -1070,6 +1070,7 @@ __FBSDID("$FreeBSD$");
#define SCTP_GETTIME_TIMEVAL(x) (getmicrouptime(x))
#define SCTP_GETPTIME_TIMEVAL(x) (microuptime(x))
+#endif
/*#if defined(__FreeBSD__) || defined(__APPLE__)*/
/*#define SCTP_GETTIME_TIMEVAL(x) { \*/
/* (x)->tv_sec = ticks / 1000; \*/
@@ -1080,6 +1081,7 @@ __FBSDID("$FreeBSD$");
/*#define SCTP_GETTIME_TIMEVAL(x) (microtime(x))*/
/*#endif __FreeBSD__ */
+#if defined(_KERNEL) || defined(__Userspace__)
#define sctp_sowwakeup(inp, so) \
do { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
@@ -1118,5 +1120,5 @@ do { \
} \
} while (0)
-#endif /* _KERNEL */
+#endif /* _KERNEL || __Userspace__ */
#endif
diff --git a/sys/netinet/sctp_crc32.h b/sys/netinet/sctp_crc32.h
index 3d118e5..88739ed 100644
--- a/sys/netinet/sctp_crc32.h
+++ b/sys/netinet/sctp_crc32.h
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
#ifndef SCTP_USE_ADLER32
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
uint32_t update_crc32(uint32_t, unsigned char *, unsigned int);
uint32_t old_update_crc32(uint32_t, unsigned char *, unsigned int);
diff --git a/sys/netinet/sctp_indata.c b/sys/netinet/sctp_indata.c
index c71a684..8a1d057 100644
--- a/sys/netinet/sctp_indata.c
+++ b/sys/netinet/sctp_indata.c
@@ -3184,6 +3184,10 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
if ((PR_SCTP_TTL_ENABLED(tp1->flags)) && tp1->sent < SCTP_DATAGRAM_ACKED) {
/* Is it expired? */
if (
+ /*
+ * TODO sctp_constants.h needs alternative
+ * time macros when _KERNEL is undefined.
+ */
(timevalcmp(&now, &tp1->rec.data.timetodrop, >))
) {
/* Yes so drop it */
diff --git a/sys/netinet/sctp_indata.h b/sys/netinet/sctp_indata.h
index 9ab5ebf..81c1d72 100644
--- a/sys/netinet/sctp_indata.h
+++ b/sys/netinet/sctp_indata.h
@@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef __sctp_indata_h__
#define __sctp_indata_h__
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
struct sctp_queued_to_read *
sctp_build_readq_entry(struct sctp_tcb *stcb,
diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c
index a6acb16..7a6377f 100644
--- a/sys/netinet/sctp_input.c
+++ b/sys/netinet/sctp_input.c
@@ -2299,6 +2299,10 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
/* Expire time is in Ticks, so we convert to seconds */
time_expires.tv_sec = cookie->time_entered.tv_sec + TICKS_TO_SEC(cookie->cookie_life);
time_expires.tv_usec = cookie->time_entered.tv_usec;
+ /*
+ * TODO sctp_constants.h needs alternative time macros when _KERNEL
+ * is undefined.
+ */
if (timevalcmp(&now, &time_expires, >)) {
/* cookie is stale! */
struct mbuf *op_err;
@@ -5371,7 +5375,7 @@ sctp_skip_csum_4:
goto bad;
}
/* validate mbuf chain length with IP payload length */
- if (mlen < (ip->ip_len - iphlen)) {
+ if (mlen < (SCTP_GET_IPV4_LENGTH(ip) - iphlen)) {
SCTP_STAT_INCR(sctps_hdrops);
goto bad;
}
@@ -5434,7 +5438,7 @@ sctp_skip_csum_4:
* idea, so I will leave it in place.
*/
if (inp && ipsec4_in_reject(m, &inp->ip_inp.inp)) {
- ipsec4stat.in_polvio++;
+ MODULE_GLOBAL(MOD_IPSEC, ipsec4stat).in_polvio++;
SCTP_STAT_INCR(sctps_hdrops);
goto bad;
}
diff --git a/sys/netinet/sctp_input.h b/sys/netinet/sctp_input.h
index 2a28970..39f6420 100644
--- a/sys/netinet/sctp_input.h
+++ b/sys/netinet/sctp_input.h
@@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef __sctp_input_h__
#define __sctp_input_h__
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
void
sctp_common_input_processing(struct mbuf **, int, int, int,
struct sctphdr *, struct sctp_chunkhdr *, struct sctp_inpcb *,
diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h
index 8bf2954..a1795d2 100644
--- a/sys/netinet/sctp_os_bsd.h
+++ b/sys/netinet/sctp_os_bsd.h
@@ -60,6 +60,9 @@ __FBSDID("$FreeBSD$");
#include <sys/random.h>
#include <sys/limits.h>
#include <sys/queue.h>
+#if defined(__FreeBSD__) && __FreeBSD_version > 800000 && defined(VIMAGE)
+#include <sys/vimage.h>
+#endif
#include <machine/cpu.h>
#include <net/if.h>
@@ -139,6 +142,26 @@ MALLOC_DECLARE(SCTP_M_SOCKOPT);
#define SCTP_BASE_VAR(__m) system_base_info.__m
/*
+ * Macros to expand out globals defined by various modules
+ * to either a real global or a virtualized instance of one,
+ * depending on whether VIMAGE is defined in opt_vimage.h
+ * XXX opt_vimage.h not yet present, more framework to come.
+ * XXX so will always evaluate to the global for now (VIMAGE not defined)
+ */
+/* first define modules that supply us information */
+#define MOD_NET net
+#define MOD_INET inet
+#define MOD_INET6 inet6
+#define MOD_IPSEC ipsec
+
+/* then define the macro(s) that hook into the vimage macros */
+#if defined(__FreeBSD__) && __FreeBSD_version > 800000 && defined(VIMAGE)
+#define VSYMNAME(__MODULE) vnet_ ## __MODULE
+#define MODULE_GLOBAL(__MODULE, __SYMBOL) VSYM(VSYMNAME(__MODULE), __SYMBOL)
+#else
+#define MODULE_GLOBAL(__MODULE, __SYMBOL) (__SYMBOL)
+#endif
+/*
*
*/
#define USER_ADDR_NULL (NULL) /* FIX ME: temp */
diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c
index a0b437d..19bbbac 100644
--- a/sys/netinet/sctp_output.c
+++ b/sys/netinet/sctp_output.c
@@ -3510,7 +3510,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
tos_value = inp->ip_inp.inp.inp_ip_tos;
}
if ((nofragment_flag) && (port == 0)) {
-#if defined(WITH_CONVERT_IP_OFF) || defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(WITH_CONVERT_IP_OFF) || defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__)
ip->ip_off = IP_DF;
#else
ip->ip_off = htons(IP_DF);
@@ -3826,7 +3826,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
sin6 = &tmp;
/* KAME hack: embed scopeid */
- if (sa6_embedscope(sin6, ip6_use_defzone) != 0) {
+ if (sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) {
SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
return (EINVAL);
}
@@ -3880,7 +3880,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
if (net->src_addr_selected == 0) {
sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
/* KAME hack: embed scopeid */
- if (sa6_embedscope(sin6, ip6_use_defzone) != 0) {
+ if (sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) {
SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
return (EINVAL);
}
@@ -3903,7 +3903,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
} else {
sin6 = (struct sockaddr_in6 *)&ro->ro_dst;
/* KAME hack: embed scopeid */
- if (sa6_embedscope(sin6, ip6_use_defzone) != 0) {
+ if (sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) {
SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
return (EINVAL);
}
@@ -5096,7 +5096,7 @@ do_a_abort:
*/
(void)sa6_recoverscope(sin6);
stc.scope_id = sin6->sin6_scope_id;
- sa6_embedscope(sin6, ip6_use_defzone);
+ sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone));
stc.loopback_scope = 1;
stc.local_scope = 0;
stc.site_scope = 1;
@@ -5132,7 +5132,7 @@ do_a_abort:
*/
(void)sa6_recoverscope(sin6);
stc.scope_id = sin6->sin6_scope_id;
- sa6_embedscope(sin6, ip6_use_defzone);
+ sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone));
} else if (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) {
/*
* If the new destination is
@@ -5761,6 +5761,10 @@ sctp_set_prsctp_policy(struct sctp_tcb *stcb,
(void)SCTP_GETTIME_TIMEVAL(&sp->ts);
tv.tv_sec = sp->timetolive / 1000;
tv.tv_usec = (sp->timetolive * 1000) % 1000000;
+ /*
+ * TODO sctp_constants.h needs alternative
+ * time macros when _KERNEL is undefined.
+ */
timevaladd(&sp->ts, &tv);
}
break;
@@ -10260,7 +10264,7 @@ sctp_send_shutdown_complete2(struct mbuf *m, int iphlen, struct sctphdr *sh,
/* Fill in the IPv6 header for the ABORT */
ip6_out->ip6_flow = ip6->ip6_flow;
- ip6_out->ip6_hlim = ip6_defhlim;
+ ip6_out->ip6_hlim = MODULE_GLOBAL(MOD_INET6, ip6_defhlim);
if (port) {
ip6_out->ip6_nxt = IPPROTO_UDP;
} else {
@@ -10277,7 +10281,7 @@ sctp_send_shutdown_complete2(struct mbuf *m, int iphlen, struct sctphdr *sh,
comp_cp = (struct sctp_shutdown_complete_msg *)(
(caddr_t)ip6_out + offset_out);
break;
-#endif
+#endif /* INET6 */
default:
/* Currently not supported. */
return;
@@ -11225,7 +11229,7 @@ sctp_send_abort(struct mbuf *m, int iphlen, struct sctphdr *sh, uint32_t vtag,
/* Fill in the IP6 header for the ABORT */
ip6_out->ip6_flow = ip6->ip6_flow;
- ip6_out->ip6_hlim = ip6_defhlim;
+ ip6_out->ip6_hlim = MODULE_GLOBAL(MOD_INET6, ip6_defhlim);
if (port) {
ip6_out->ip6_nxt = IPPROTO_UDP;
} else {
@@ -11237,7 +11241,7 @@ sctp_send_abort(struct mbuf *m, int iphlen, struct sctphdr *sh, uint32_t vtag,
iphlen_out = sizeof(*ip6_out);
abm = (struct sctp_abort_msg *)((caddr_t)ip6_out + iphlen_out);
break;
-#endif
+#endif /* INET6 */
default:
/* Currently not supported */
if (err_cause)
@@ -11517,7 +11521,7 @@ sctp_send_operr_to(struct mbuf *m, int iphlen, struct mbuf *scm, uint32_t vtag,
in6 = mtod(m, struct ip6_hdr *);
out6 = mtod(mout, struct ip6_hdr *);
out6->ip6_flow = in6->ip6_flow;
- out6->ip6_hlim = ip6_defhlim;
+ out6->ip6_hlim = MODULE_GLOBAL(MOD_INET6, ip6_defhlim);
if (port) {
out6->ip6_nxt = IPPROTO_UDP;
} else {
@@ -11568,7 +11572,7 @@ sctp_send_operr_to(struct mbuf *m, int iphlen, struct mbuf *scm, uint32_t vtag,
RTFREE(ro.ro_rt);
break;
}
-#endif
+#endif /* INET6 */
default:
/* TSNH */
break;
@@ -13162,7 +13166,7 @@ sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t * ro)
return (0);
/* get prefix entry of address */
- LIST_FOREACH(pfx, &nd_prefix, ndpr_entry) {
+ LIST_FOREACH(pfx, &MODULE_GLOBAL(MOD_INET6, nd_prefix), ndpr_entry) {
if (pfx->ndpr_stateflags & NDPRF_DETACHED)
continue;
if (IN6_ARE_MASKED_ADDR_EQUAL(&pfx->ndpr_prefix.sin6_addr,
diff --git a/sys/netinet/sctp_output.h b/sys/netinet/sctp_output.h
index f0961b8..ddbe7096 100644
--- a/sys/netinet/sctp_output.h
+++ b/sys/netinet/sctp_output.h
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/sctp_header.h>
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
struct mbuf *
@@ -201,6 +201,9 @@ sctp_send_abort(struct mbuf *, int, struct sctphdr *, uint32_t,
void sctp_send_operr_to(struct mbuf *, int, struct mbuf *, uint32_t, uint32_t, uint16_t);
+#endif /* _KERNEL || __Userspace__ */
+
+#if defined(_KERNEL) || defined (__Userspace__)
int
sctp_sosend(struct socket *so,
struct sockaddr *addr,
diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c
index 5cdc812..17c1da0 100644
--- a/sys/netinet/sctp_pcb.c
+++ b/sys/netinet/sctp_pcb.c
@@ -59,11 +59,11 @@ SCTP6_ARE_ADDR_EQUAL(struct sockaddr_in6 *a, struct sockaddr_in6 *b)
struct sockaddr_in6 tmp_a, tmp_b;
memcpy(&tmp_a, a, sizeof(struct sockaddr_in6));
- if (sa6_embedscope(&tmp_a, ip6_use_defzone) != 0) {
+ if (sa6_embedscope(&tmp_a, MODULE_GLOBAL(MOD_INET6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone))) != 0) {
return 0;
}
memcpy(&tmp_b, b, sizeof(struct sockaddr_in6));
- if (sa6_embedscope(&tmp_b, ip6_use_defzone) != 0) {
+ if (sa6_embedscope(&tmp_b, MODULE_GLOBAL(MOD_INET6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone))) != 0) {
return 0;
}
return (IN6_ARE_ADDR_EQUAL(&tmp_a.sin6_addr, &tmp_b.sin6_addr));
@@ -1894,7 +1894,7 @@ sctp_findassociation_addr(struct mbuf *m, int iphlen, int offset,
/* Get the scopes in properly to the sin6 addr's */
/* we probably don't need these operations */
(void)sa6_recoverscope(from6);
- sa6_embedscope(from6, ip6_use_defzone);
+ sa6_embedscope(from6, MODULE_GLOBAL(MOD_INET6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)));
break;
}
#endif
@@ -1941,7 +1941,7 @@ sctp_findassociation_addr(struct mbuf *m, int iphlen, int offset,
/* Get the scopes in properly to the sin6 addr's */
/* we probably don't need these operations */
(void)sa6_recoverscope(to6);
- sa6_embedscope(to6, ip6_use_defzone);
+ sa6_embedscope(to6, MODULE_GLOBAL(MOD_INET6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)));
break;
}
#endif
@@ -2193,7 +2193,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)
}
#endif /* IPSEC */
SCTP_INCR_EP_COUNT();
- inp->ip_inp.inp.inp_ip_ttl = ip_defttl;
+ inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(MOD_INET, ip_defttl);
SCTP_INP_INFO_WUNLOCK();
so->so_pcb = (caddr_t)inp;
@@ -2606,7 +2606,7 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
bindall = 0;
/* KAME hack: embed scopeid */
- if (sa6_embedscope(sin6, ip6_use_defzone) != 0) {
+ if (sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone)) != 0) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
return (EINVAL);
}
@@ -2706,8 +2706,8 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
int done;
if (ip_inp->inp_flags & INP_HIGHPORT) {
- first = ipport_hifirstauto;
- last = ipport_hilastauto;
+ first = MODULE_GLOBAL(MOD_INET, ipport_hifirstauto);
+ last = MODULE_GLOBAL(MOD_INET, ipport_hilastauto);
} else if (ip_inp->inp_flags & INP_LOWPORT) {
if (p && (error =
priv_check(p, PRIV_NETINET_RESERVEDPORT)
@@ -2718,8 +2718,8 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
return (error);
}
- first = ipport_lowfirstauto;
- last = ipport_lowlastauto;
+ first = MODULE_GLOBAL(MOD_INET, ipport_lowfirstauto);
+ last = MODULE_GLOBAL(MOD_INET, ipport_lowlastauto);
} else {
first = ipport_firstauto;
last = ipport_lastauto;
@@ -3635,7 +3635,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
struct sockaddr_in6 *sin6;
sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
- (void)sa6_embedscope(sin6, ip6_use_defzone);
+ (void)sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone));
sin6->sin6_scope_id = 0;
}
#endif
@@ -5357,12 +5357,6 @@ sctp_pcb_finish(void)
struct sctp_tagblock *twait_block, *prev_twait_block;
int i;
- /* FIXME MT */
- SCTP_BASE_INFO(threads_must_exit) = 1;
-#if defined(SCTP_USE_THREAD_BASED_ITERATOR)
- /* Wake the thread up so it will exit now */
- sctp_wakeup_iterator();
-#endif
/*
* free the vrf/ifn/ifa lists and hashes (be sure address monitor is
* destroyed first).
diff --git a/sys/netinet/sctp_pcb.h b/sys/netinet/sctp_pcb.h
index ef0cdf9..7f63dcd 100644
--- a/sys/netinet/sctp_pcb.h
+++ b/sys/netinet/sctp_pcb.h
@@ -450,7 +450,8 @@ struct sctp_tcb {
#include <netinet/sctp_lock_bsd.h>
-#if defined(_KERNEL)
+/* TODO where to put non-_KERNEL things for __Userspace__? */
+#if defined(_KERNEL) || defined(__Userspace__)
/* Attention Julian, this is the extern that
* goes with the base info. sctp_pcb.c has
diff --git a/sys/netinet/sctp_sysctl.h b/sys/netinet/sctp_sysctl.h
index 27c84a4..f739c96 100644
--- a/sys/netinet/sctp_sysctl.h
+++ b/sys/netinet/sctp_sysctl.h
@@ -483,7 +483,7 @@ struct sctp_sysctl {
#endif
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
#if defined(SYSCTL_DECL)
SYSCTL_DECL(_net_inet_sctp);
#endif
diff --git a/sys/netinet/sctp_timer.c b/sys/netinet/sctp_timer.c
index 409ade3..c3cf1df 100644
--- a/sys/netinet/sctp_timer.c
+++ b/sys/netinet/sctp_timer.c
@@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/sctp_os.h>
#include <netinet/sctp_pcb.h>
#ifdef INET6
-#include <netinet6/sctp6_var.h>
#endif
#include <netinet/sctp_var.h>
#include <netinet/sctp_sysctl.h>
@@ -402,8 +401,7 @@ sctp_find_alternate_net(struct sctp_tcb *stcb,
}
if (this_random % 2 == 1) {
max_cwnd_net = mnet;
- max_cwnd = mnet->cwnd;
- //Useless ?
+ max_cwnd = mnet->cwnd; /* Useless? */
}
}
}
@@ -1711,7 +1709,7 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp,
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
/* KAME hack: embed scopeid */
- (void)sa6_embedscope(sin6, ip6_use_defzone);
+ (void)sa6_embedscope(sin6, MODULE_GLOBAL(MOD_INET6, ip6_use_defzone));
}
#endif
diff --git a/sys/netinet/sctp_timer.h b/sys/netinet/sctp_timer.h
index 216d0d4..c3b3188 100644
--- a/sys/netinet/sctp_timer.h
+++ b/sys/netinet/sctp_timer.h
@@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$");
#ifndef __sctp_timer_h__
#define __sctp_timer_h__
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
#define SCTP_RTT_SHIFT 3
#define SCTP_RTT_VAR_SHIFT 2
diff --git a/sys/netinet/sctp_uio.h b/sys/netinet/sctp_uio.h
index 15cf54e..7714343 100644
--- a/sys/netinet/sctp_uio.h
+++ b/sys/netinet/sctp_uio.h
@@ -1037,7 +1037,7 @@ struct sctp_log {
/*
* Kernel defined for sctp_send
*/
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
int
sctp_lower_sosend(struct socket *so,
struct sockaddr *addr,
@@ -1065,7 +1065,7 @@ sctp_sorecvmsg(struct socket *so,
/*
* API system calls
*/
-#if !(defined(_KERNEL))
+#if !(defined(_KERNEL)) && !(defined(__Userspace__))
__BEGIN_DECLS
int sctp_peeloff __P((int, sctp_assoc_t));
diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c
index 7d92968..6c34d47 100644
--- a/sys/netinet/sctp_usrreq.c
+++ b/sys/netinet/sctp_usrreq.c
@@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/sctp_header.h>
#include <netinet/sctp_var.h>
#if defined(INET6)
-#include <netinet6/sctp6_var.h>
#endif
#include <netinet/sctp_sysctl.h>
#include <netinet/sctp_output.h>
@@ -63,7 +62,6 @@ sctp_init(void)
/* Initialize and modify the sysctled variables */
sctp_init_sysctls();
-
if ((nmbclusters / 8) > SCTP_ASOC_MAX_CHUNKS_ON_QUEUE)
SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = (nmbclusters / 8);
/*
@@ -532,7 +530,7 @@ sctp_attach(struct socket *so, int proto, struct thread *p)
inp->sctp_flags &= ~SCTP_PCB_FLAGS_BOUND_V6; /* I'm not v6! */
ip_inp = &inp->ip_inp.inp;
ip_inp->inp_vflag |= INP_IPV4;
- ip_inp->inp_ip_ttl = ip_defttl;
+ ip_inp->inp_ip_ttl = MODULE_GLOBAL(MOD_INET, ip_defttl);
#ifdef IPSEC
error = ipsec_init_policy(so, &ip_inp->inp_sp);
#ifdef SCTP_LOG_CLOSING
@@ -3986,7 +3984,6 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
return (error);
}
-
int
sctp_ctloutput(struct socket *so, struct sockopt *sopt)
{
diff --git a/sys/netinet/sctp_var.h b/sys/netinet/sctp_var.h
index e66d74c..3ef801c 100644
--- a/sys/netinet/sctp_var.h
+++ b/sys/netinet/sctp_var.h
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/sctp_uio.h>
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
extern struct pr_usrreqs sctp_usrreqs;
diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c
index 42903b1..0b33c49 100644
--- a/sys/netinet/sctputil.c
+++ b/sys/netinet/sctputil.c
@@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/sctp_var.h>
#include <netinet/sctp_sysctl.h>
#ifdef INET6
-#include <netinet6/sctp6_var.h>
#endif
#include <netinet/sctp_header.h>
#include <netinet/sctp_output.h>
@@ -3098,7 +3097,7 @@ sctp_notify_send_failed(struct sctp_tcb *stcb, uint32_t error,
#endif
)
{
- struct mbuf *m_notify;
+ struct mbuf *m_notify, *tt;
struct sctp_send_failed *ssf;
struct sctp_queued_to_read *control;
int length;
@@ -3107,11 +3106,12 @@ sctp_notify_send_failed(struct sctp_tcb *stcb, uint32_t error,
/* event not enabled */
return;
- length = sizeof(struct sctp_send_failed) + chk->send_size;
m_notify = sctp_get_mbuf_for_msg(sizeof(struct sctp_send_failed), 0, M_DONTWAIT, 1, MT_DATA);
if (m_notify == NULL)
/* no space left */
return;
+ length = sizeof(struct sctp_send_failed) + chk->send_size;
+ length -= sizeof(struct sctp_data_chunk);
SCTP_BUF_LEN(m_notify) = 0;
ssf = mtod(m_notify, struct sctp_send_failed *);
ssf->ssf_type = SCTP_SEND_FAILED;
@@ -3130,6 +3130,18 @@ sctp_notify_send_failed(struct sctp_tcb *stcb, uint32_t error,
ssf->ssf_info.sinfo_context = chk->rec.data.context;
ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb);
ssf->ssf_assoc_id = sctp_get_associd(stcb);
+
+ /* Take off the chunk header */
+ m_adj(chk->data, sizeof(struct sctp_data_chunk));
+
+ /* trim out any 0 len mbufs */
+ while (SCTP_BUF_LEN(chk->data) == 0) {
+ tt = chk->data;
+ chk->data = SCTP_BUF_NEXT(tt);
+ SCTP_BUF_NEXT(tt) = NULL;
+ sctp_m_freem(tt);
+ }
+
SCTP_BUF_NEXT(m_notify) = chk->data;
SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed);
@@ -3195,7 +3207,11 @@ sctp_notify_send_failed2(struct sctp_tcb *stcb, uint32_t error,
bzero(&ssf->ssf_info, sizeof(ssf->ssf_info));
ssf->ssf_info.sinfo_stream = sp->stream;
ssf->ssf_info.sinfo_ssn = sp->strseq;
- ssf->ssf_info.sinfo_flags = sp->sinfo_flags;
+ if (sp->some_taken) {
+ ssf->ssf_info.sinfo_flags = SCTP_DATA_LAST_FRAG;
+ } else {
+ ssf->ssf_info.sinfo_flags = SCTP_DATA_NOT_FRAG;
+ }
ssf->ssf_info.sinfo_ppid = sp->ppid;
ssf->ssf_info.sinfo_context = sp->context;
ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb);
@@ -5467,10 +5483,10 @@ found_one:
bzero(&sin6, sizeof(sin6));
sin6.sin6_family = AF_INET6;
sin6.sin6_len = sizeof(struct sockaddr_in6);
- sin6.sin6_addr.s6_addr32[2] = ntohl(0x0000ffff);
+ sin6.sin6_addr.s6_addr16[2] = 0xffff;
bcopy(&sin->sin_addr,
- &sin6.sin6_addr.s6_addr32[3],
- sizeof(sin6.sin6_addr.s6_addr32[3]));
+ &sin6.sin6_addr.s6_addr16[3],
+ sizeof(sin6.sin6_addr.s6_addr16[3]));
sin6.sin6_port = sin->sin_port;
memcpy(from, (caddr_t)&sin6, sizeof(sin6));
}
@@ -6000,8 +6016,6 @@ sctp_dynamic_set_primary(struct sockaddr *sa, uint32_t vrf_id)
}
-
-
int
sctp_soreceive(struct socket *so,
struct sockaddr **psa,
@@ -6256,7 +6270,7 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp,
return;
}
addr_touse = sa;
-#if defined(INET6)
+#if defined(INET6) && !defined(__Userspace__) /* TODO port in6_sin6_2_sin */
if (sa->sa_family == AF_INET6) {
struct sockaddr_in6 *sin6;
@@ -6382,7 +6396,7 @@ sctp_bindx_delete_address(struct socket *so, struct sctp_inpcb *inp,
return;
}
addr_touse = sa;
-#if defined(INET6)
+#if defined(INET6) && !defined(__Userspace__) /* TODO port in6_sin6_2_sin */
if (sa->sa_family == AF_INET6) {
struct sockaddr_in6 *sin6;
diff --git a/sys/netinet/sctputil.h b/sys/netinet/sctputil.h
index 3fd384e..5be1df7 100644
--- a/sys/netinet/sctputil.h
+++ b/sys/netinet/sctputil.h
@@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$");
#define __sctputil_h__
-#if defined(_KERNEL)
+#if defined(_KERNEL) || defined(__Userspace__)
#ifdef SCTP_ASOCLOG_OF_TSNS
OpenPOWER on IntegriCloud