summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/netinet
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-09 14:47:04 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-10 11:03:27 +0100
commit0577772720a4ecb050a230f75346f90b246e93c8 (patch)
treea3fba8bb57e77c932e08dd0d4bbe49adb6312e5e /freebsd/sys/netinet
parentUpdate to FreeBSD head 2016-12-10 (diff)
downloadrtems-libbsd-0577772720a4ecb050a230f75346f90b246e93c8.tar.bz2
Update to FreeBSD head 2017-01-09
Git mirror commit 1f8e4a995a6ede4bdb24e6d335ccda2bdb0175ab.
Diffstat (limited to 'freebsd/sys/netinet')
-rw-r--r--freebsd/sys/netinet/icmp_var.h2
-rw-r--r--freebsd/sys/netinet/ip_carp.c126
-rw-r--r--freebsd/sys/netinet/ip_fastfwd.c5
-rw-r--r--freebsd/sys/netinet/ip_icmp.c81
-rw-r--r--freebsd/sys/netinet/ip_input.c33
-rw-r--r--freebsd/sys/netinet/ip_output.c3
-rw-r--r--freebsd/sys/netinet/sctp_asconf.c74
-rw-r--r--freebsd/sys/netinet/sctp_auth.c102
-rw-r--r--freebsd/sys/netinet/sctp_auth.h90
-rw-r--r--freebsd/sys/netinet/sctp_bsd_addr.c4
-rw-r--r--freebsd/sys/netinet/sctp_bsd_addr.h2
-rw-r--r--freebsd/sys/netinet/sctp_cc_functions.c188
-rw-r--r--freebsd/sys/netinet/sctp_crc32.c10
-rw-r--r--freebsd/sys/netinet/sctp_indata.c437
-rw-r--r--freebsd/sys/netinet/sctp_indata.h2
-rw-r--r--freebsd/sys/netinet/sctp_input.c137
-rw-r--r--freebsd/sys/netinet/sctp_input.h2
-rw-r--r--freebsd/sys/netinet/sctp_output.c502
-rw-r--r--freebsd/sys/netinet/sctp_output.h8
-rw-r--r--freebsd/sys/netinet/sctp_pcb.c118
-rw-r--r--freebsd/sys/netinet/sctp_pcb.h6
-rw-r--r--freebsd/sys/netinet/sctp_structs.h10
-rw-r--r--freebsd/sys/netinet/sctp_sysctl.c22
-rw-r--r--freebsd/sys/netinet/sctp_timer.c22
-rw-r--r--freebsd/sys/netinet/sctp_usrreq.c124
-rw-r--r--freebsd/sys/netinet/sctputil.c180
-rw-r--r--freebsd/sys/netinet/sctputil.h4
-rw-r--r--freebsd/sys/netinet/tcp_hostcache.c5
-rw-r--r--freebsd/sys/netinet/tcp_input.c25
-rw-r--r--freebsd/sys/netinet/tcp_output.c42
-rw-r--r--freebsd/sys/netinet/tcp_sack.c3
-rw-r--r--freebsd/sys/netinet/tcp_subr.c7
-rw-r--r--freebsd/sys/netinet/tcp_syncache.c3
33 files changed, 1406 insertions, 973 deletions
diff --git a/freebsd/sys/netinet/icmp_var.h b/freebsd/sys/netinet/icmp_var.h
index d3e72bc2..d76679f6 100644
--- a/freebsd/sys/netinet/icmp_var.h
+++ b/freebsd/sys/netinet/icmp_var.h
@@ -96,7 +96,7 @@ extern int badport_bandlim(int);
#define BANDLIM_RST_OPENPORT 4 /* No connection, listener */
#define BANDLIM_ICMP6_UNREACH 5
#define BANDLIM_SCTP_OOTB 6
-#define BANDLIM_MAX 6
+#define BANDLIM_MAX 7
#endif
#endif
diff --git a/freebsd/sys/netinet/ip_carp.c b/freebsd/sys/netinet/ip_carp.c
index 6b683f45..5f67b6f5 100644
--- a/freebsd/sys/netinet/ip_carp.c
+++ b/freebsd/sys/netinet/ip_carp.c
@@ -583,27 +583,96 @@ carp6_input(struct mbuf **mp, int *offp, int proto)
}
#endif /* INET6 */
+/*
+ * This routine should not be necessary at all, but some switches
+ * (VMWare ESX vswitches) can echo our own packets back at us,
+ * and we must ignore them or they will cause us to drop out of
+ * MASTER mode.
+ *
+ * We cannot catch all cases of network loops. Instead, what we
+ * do here is catch any packet that arrives with a carp header
+ * with a VHID of 0, that comes from an address that is our own.
+ * These packets are by definition "from us" (even if they are from
+ * a misconfigured host that is pretending to be us).
+ *
+ * The VHID test is outside this mini-function.
+ */
+static int
+carp_source_is_self(struct mbuf *m, struct ifaddr *ifa, sa_family_t af)
+{
+#ifdef INET
+ struct ip *ip4;
+ struct in_addr in4;
+#endif
+#ifdef INET6
+ struct ip6_hdr *ip6;
+ struct in6_addr in6;
+#endif
+
+ switch (af) {
+#ifdef INET
+ case AF_INET:
+ ip4 = mtod(m, struct ip *);
+ in4 = ifatoia(ifa)->ia_addr.sin_addr;
+ return (in4.s_addr == ip4->ip_src.s_addr);
+#endif
+#ifdef INET6
+ case AF_INET6:
+ ip6 = mtod(m, struct ip6_hdr *);
+ in6 = ifatoia6(ifa)->ia_addr.sin6_addr;
+ return (memcmp(&in6, &ip6->ip6_src, sizeof(in6)) == 0);
+#endif
+ default:
+ break;
+ }
+ return (0);
+}
+
static void
carp_input_c(struct mbuf *m, struct carp_header *ch, sa_family_t af)
{
struct ifnet *ifp = m->m_pkthdr.rcvif;
- struct ifaddr *ifa;
+ struct ifaddr *ifa, *match;
struct carp_softc *sc;
uint64_t tmp_counter;
struct timeval sc_tv, ch_tv;
+ int error;
- /* verify that the VHID is valid on the receiving interface */
+ /*
+ * Verify that the VHID is valid on the receiving interface.
+ *
+ * There should be just one match. If there are none
+ * the VHID is not valid and we drop the packet. If
+ * there are multiple VHID matches, take just the first
+ * one, for compatibility with previous code. While we're
+ * scanning, check for obvious loops in the network topology
+ * (these should never happen, and as noted above, we may
+ * miss real loops; this is just a double-check).
+ */
IF_ADDR_RLOCK(ifp);
- IFNET_FOREACH_IFA(ifp, ifa)
- if (ifa->ifa_addr->sa_family == af &&
- ifa->ifa_carp->sc_vhid == ch->carp_vhid) {
- ifa_ref(ifa);
- break;
- }
+ error = 0;
+ match = NULL;
+ IFNET_FOREACH_IFA(ifp, ifa) {
+ if (match == NULL && ifa->ifa_carp != NULL &&
+ ifa->ifa_addr->sa_family == af &&
+ ifa->ifa_carp->sc_vhid == ch->carp_vhid)
+ match = ifa;
+ if (ch->carp_vhid == 0 && carp_source_is_self(m, ifa, af))
+ error = ELOOP;
+ }
+ ifa = error ? NULL : match;
+ if (ifa != NULL)
+ ifa_ref(ifa);
IF_ADDR_RUNLOCK(ifp);
if (ifa == NULL) {
- CARPSTATS_INC(carps_badvhid);
+ if (error == ELOOP) {
+ CARP_DEBUG("dropping looped packet on interface %s\n",
+ ifp->if_xname);
+ CARPSTATS_INC(carps_badif); /* ??? */
+ } else {
+ CARPSTATS_INC(carps_badvhid);
+ }
m_freem(m);
return;
}
@@ -789,12 +858,41 @@ carp_send_ad_error(struct carp_softc *sc, int error)
}
}
+/*
+ * Pick the best ifaddr on the given ifp for sending CARP
+ * advertisements.
+ *
+ * "Best" here is defined by ifa_preferred(). This function is much
+ * much like ifaof_ifpforaddr() except that we just use ifa_preferred().
+ *
+ * (This could be simplified to return the actual address, except that
+ * it has a different format in AF_INET and AF_INET6.)
+ */
+static struct ifaddr *
+carp_best_ifa(int af, struct ifnet *ifp)
+{
+ struct ifaddr *ifa, *best;
+
+ if (af >= AF_MAX)
+ return (NULL);
+ best = NULL;
+ IF_ADDR_RLOCK(ifp);
+ TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
+ if (ifa->ifa_addr->sa_family == af &&
+ (best == NULL || ifa_preferred(best, ifa)))
+ best = ifa;
+ }
+ IF_ADDR_RUNLOCK(ifp);
+ if (best != NULL)
+ ifa_ref(best);
+ return (best);
+}
+
static void
carp_send_ad_locked(struct carp_softc *sc)
{
struct carp_header ch;
struct timeval tv;
- struct sockaddr sa;
struct ifaddr *ifa;
struct carp_header *ch_ptr;
struct mbuf *m;
@@ -843,9 +941,7 @@ carp_send_ad_locked(struct carp_softc *sc)
ip->ip_sum = 0;
ip_fillid(ip);
- bzero(&sa, sizeof(sa));
- sa.sa_family = AF_INET;
- ifa = ifaof_ifpforaddr(&sa, sc->sc_carpdev);
+ ifa = carp_best_ifa(AF_INET, sc->sc_carpdev);
if (ifa != NULL) {
ip->ip_src.s_addr =
ifatoia(ifa)->ia_addr.sin_addr.s_addr;
@@ -889,11 +985,9 @@ carp_send_ad_locked(struct carp_softc *sc)
ip6->ip6_vfc |= IPV6_VERSION;
ip6->ip6_hlim = CARP_DFLTTL;
ip6->ip6_nxt = IPPROTO_CARP;
- bzero(&sa, sizeof(sa));
/* set the source address */
- sa.sa_family = AF_INET6;
- ifa = ifaof_ifpforaddr(&sa, sc->sc_carpdev);
+ ifa = carp_best_ifa(AF_INET6, sc->sc_carpdev);
if (ifa != NULL) {
bcopy(IFA_IN6(ifa), &ip6->ip6_src,
sizeof(struct in6_addr));
diff --git a/freebsd/sys/netinet/ip_fastfwd.c b/freebsd/sys/netinet/ip_fastfwd.c
index bc4d70b4..1d948781 100644
--- a/freebsd/sys/netinet/ip_fastfwd.c
+++ b/freebsd/sys/netinet/ip_fastfwd.c
@@ -402,8 +402,9 @@ passout:
*/
m_clrprotoflags(m);
- IP_PROBE(send, NULL, NULL, ip, nh.nh_ifp,
- ip, NULL);
+ IP_PROBE(send, NULL, NULL,
+ mtod(m, struct ip *), nh.nh_ifp,
+ mtod(m, struct ip *), NULL);
/* XXX: we can use cached route here */
error = (*nh.nh_ifp->if_output)(nh.nh_ifp, m,
(struct sockaddr *)&dst, NULL);
diff --git a/freebsd/sys/netinet/ip_icmp.c b/freebsd/sys/netinet/ip_icmp.c
index a1331cac..b1816458 100644
--- a/freebsd/sys/netinet/ip_icmp.c
+++ b/freebsd/sys/netinet/ip_icmp.c
@@ -975,44 +975,59 @@ ip_next_mtu(int mtu, int dir)
* the 'final' error, but it doesn't make sense to solve the printing
* delay with more complex code.
*/
+struct icmp_rate {
+ const char *descr;
+ struct counter_rate cr;
+};
+static VNET_DEFINE(struct icmp_rate, icmp_rates[BANDLIM_MAX]) = {
+ { "icmp unreach response" },
+ { "icmp ping response" },
+ { "icmp tstamp response" },
+ { "closed port RST response" },
+ { "open port RST response" },
+ { "icmp6 unreach response" },
+ { "sctp ootb response" }
+};
+#define V_icmp_rates VNET(icmp_rates)
+
+static void
+icmp_bandlimit_init(void)
+{
+
+ for (int i = 0; i < BANDLIM_MAX; i++) {
+ V_icmp_rates[i].cr.cr_rate = counter_u64_alloc(M_WAITOK);
+ V_icmp_rates[i].cr.cr_ticks = ticks;
+ }
+}
+VNET_SYSINIT(icmp_bandlimit, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY,
+ icmp_bandlimit_init, NULL);
+
+static void
+icmp_bandlimit_uninit(void)
+{
+
+ for (int i = 0; i < BANDLIM_MAX; i++)
+ counter_u64_free(V_icmp_rates[i].cr.cr_rate);
+}
+VNET_SYSUNINIT(icmp_bandlimit, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD,
+ icmp_bandlimit_uninit, NULL);
int
badport_bandlim(int which)
{
+ int64_t pps;
-#define N(a) (sizeof (a) / sizeof (a[0]))
- static struct rate {
- const char *type;
- struct timeval lasttime;
- int curpps;
- } rates[BANDLIM_MAX+1] = {
- { "icmp unreach response" },
- { "icmp ping response" },
- { "icmp tstamp response" },
- { "closed port RST response" },
- { "open port RST response" },
- { "icmp6 unreach response" },
- { "sctp ootb response" }
- };
+ if (V_icmplim == 0 || which == BANDLIM_UNLIMITED)
+ return (0);
- /*
- * Return ok status if feature disabled or argument out of range.
- */
- if (V_icmplim > 0 && (u_int) which < N(rates)) {
- struct rate *r = &rates[which];
- int opps = r->curpps;
+ KASSERT(which >= 0 && which < BANDLIM_MAX,
+ ("%s: which %d", __func__, which));
- if (!ppsratecheck(&r->lasttime, &r->curpps, V_icmplim))
- return -1; /* discard packet */
- /*
- * If we've dropped below the threshold after having
- * rate-limited traffic print the message. This preserves
- * the previous behaviour at the expense of added complexity.
- */
- if (V_icmplim_output && opps > V_icmplim)
- log(LOG_NOTICE, "Limiting %s from %d to %d packets/sec\n",
- r->type, opps, V_icmplim);
- }
- return 0; /* okay to send packet */
-#undef N
+ pps = counter_ratecheck(&V_icmp_rates[which].cr, V_icmplim);
+ if (pps == -1)
+ return (-1);
+ if (pps > 0 && V_icmplim_output)
+ log(LOG_NOTICE, "Limiting %s from %jd to %d packets/sec\n",
+ V_icmp_rates[which].descr, (intmax_t )pps, V_icmplim);
+ return (0);
}
diff --git a/freebsd/sys/netinet/ip_input.c b/freebsd/sys/netinet/ip_input.c
index a2278616..9061d41b 100644
--- a/freebsd/sys/netinet/ip_input.c
+++ b/freebsd/sys/netinet/ip_input.c
@@ -552,24 +552,35 @@ tooshort:
m_adj(m, ip_len - m->m_pkthdr.len);
}
- /* Try to forward the packet, but if we fail continue */
+ /*
+ * Try to forward the packet, but if we fail continue.
+ * ip_tryforward() does inbound and outbound packet firewall
+ * processing. If firewall has decided that destination becomes
+ * our local address, it sets M_FASTFWD_OURS flag. In this
+ * case skip another inbound firewall processing and update
+ * ip pointer.
+ */
+ if (V_ipforwarding != 0
#ifdef IPSEC
- /* For now we do not handle IPSEC in tryforward. */
- if (!key_havesp(IPSEC_DIR_INBOUND) && !key_havesp(IPSEC_DIR_OUTBOUND) &&
- (V_ipforwarding == 1))
- if (ip_tryforward(m) == NULL)
+ && !key_havesp(IPSEC_DIR_INBOUND)
+ && !key_havesp(IPSEC_DIR_OUTBOUND)
+#endif
+ ) {
+ if ((m = ip_tryforward(m)) == NULL)
return;
+ if (m->m_flags & M_FASTFWD_OURS) {
+ m->m_flags &= ~M_FASTFWD_OURS;
+ ip = mtod(m, struct ip *);
+ goto ours;
+ }
+ }
+#ifdef IPSEC
/*
* Bypass packet filtering for packets previously handled by IPsec.
*/
if (ip_ipsec_filtertunnel(m))
goto passin;
-#else
- if (V_ipforwarding == 1)
- if (ip_tryforward(m) == NULL)
- return;
-#endif /* IPSEC */
-
+#endif
/*
* Run through list of hooks for input packets.
*
diff --git a/freebsd/sys/netinet/ip_output.c b/freebsd/sys/netinet/ip_output.c
index 5436ea2d..541acb2f 100644
--- a/freebsd/sys/netinet/ip_output.c
+++ b/freebsd/sys/netinet/ip_output.c
@@ -698,7 +698,8 @@ sendit:
*/
m_clrprotoflags(m);
- IP_PROBE(send, NULL, NULL, ip, ifp, ip, NULL);
+ IP_PROBE(send, NULL, NULL, mtod(m, struct ip *), ifp,
+ mtod(m, struct ip *), NULL);
error = (*ifp->if_output)(ifp, m,
(const struct sockaddr *)gw, ro);
} else
diff --git a/freebsd/sys/netinet/sctp_asconf.c b/freebsd/sys/netinet/sctp_asconf.c
index 5d86e520..04a813d3 100644
--- a/freebsd/sys/netinet/sctp_asconf.c
+++ b/freebsd/sys/netinet/sctp_asconf.c
@@ -99,7 +99,7 @@ sctp_asconf_success_response(uint32_t id)
}
static struct mbuf *
-sctp_asconf_error_response(uint32_t id, uint16_t cause, uint8_t * error_tlv,
+sctp_asconf_error_response(uint32_t id, uint16_t cause, uint8_t *error_tlv,
uint16_t tlv_length)
{
struct mbuf *m_reply = NULL;
@@ -134,7 +134,7 @@ sctp_asconf_error_response(uint32_t id, uint16_t cause, uint8_t * error_tlv,
return (NULL);
}
if (error_tlv != NULL) {
- tlv = (uint8_t *) (error + 1);
+ tlv = (uint8_t *)(error + 1);
memcpy(tlv, error_tlv, tlv_length);
}
SCTP_BUF_LEN(m_reply) = aph->ph.param_length;
@@ -224,7 +224,7 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap
#endif
default:
m_reply = sctp_asconf_error_response(aph->correlation_id,
- SCTP_CAUSE_INVALID_PARAM, (uint8_t *) aph,
+ SCTP_CAUSE_INVALID_PARAM, (uint8_t *)aph,
aparam_length);
return (m_reply);
} /* end switch */
@@ -239,7 +239,7 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap
/* add the address */
if (bad_address) {
m_reply = sctp_asconf_error_response(aph->correlation_id,
- SCTP_CAUSE_INVALID_PARAM, (uint8_t *) aph,
+ SCTP_CAUSE_INVALID_PARAM, (uint8_t *)aph,
aparam_length);
} else if (sctp_add_remote_addr(stcb, sa, &net, stcb->asoc.port,
SCTP_DONOT_SETSCOPE,
@@ -247,7 +247,7 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap
SCTPDBG(SCTP_DEBUG_ASCONF1,
"process_asconf_add_ip: error adding address\n");
m_reply = sctp_asconf_error_response(aph->correlation_id,
- SCTP_CAUSE_RESOURCE_SHORTAGE, (uint8_t *) aph,
+ SCTP_CAUSE_RESOURCE_SHORTAGE, (uint8_t *)aph,
aparam_length);
} else {
/* notify upper layer */
@@ -369,7 +369,7 @@ sctp_process_asconf_delete_ip(struct sockaddr *src,
#endif
default:
m_reply = sctp_asconf_error_response(aph->correlation_id,
- SCTP_CAUSE_UNRESOLVABLE_ADDR, (uint8_t *) aph,
+ SCTP_CAUSE_UNRESOLVABLE_ADDR, (uint8_t *)aph,
aparam_length);
return (m_reply);
}
@@ -379,7 +379,7 @@ sctp_process_asconf_delete_ip(struct sockaddr *src,
/* trying to delete the source address! */
SCTPDBG(SCTP_DEBUG_ASCONF1, "process_asconf_delete_ip: tried to delete source addr\n");
m_reply = sctp_asconf_error_response(aph->correlation_id,
- SCTP_CAUSE_DELETING_SRC_ADDR, (uint8_t *) aph,
+ SCTP_CAUSE_DELETING_SRC_ADDR, (uint8_t *)aph,
aparam_length);
return (m_reply);
}
@@ -393,7 +393,7 @@ sctp_process_asconf_delete_ip(struct sockaddr *src,
/* what error to reply with?? */
m_reply =
sctp_asconf_error_response(aph->correlation_id,
- SCTP_CAUSE_REQUEST_REFUSED, (uint8_t *) aph,
+ SCTP_CAUSE_REQUEST_REFUSED, (uint8_t *)aph,
aparam_length);
} else if (response_required) {
m_reply =
@@ -412,7 +412,7 @@ sctp_process_asconf_delete_ip(struct sockaddr *src,
/* only one address in the asoc */
SCTPDBG(SCTP_DEBUG_ASCONF1, "process_asconf_delete_ip: tried to delete last IP addr!\n");
m_reply = sctp_asconf_error_response(aph->correlation_id,
- SCTP_CAUSE_DELETING_LAST_ADDR, (uint8_t *) aph,
+ SCTP_CAUSE_DELETING_LAST_ADDR, (uint8_t *)aph,
aparam_length);
} else {
if (response_required) {
@@ -494,7 +494,7 @@ sctp_process_asconf_set_primary(struct sockaddr *src,
#endif
default:
m_reply = sctp_asconf_error_response(aph->correlation_id,
- SCTP_CAUSE_UNRESOLVABLE_ADDR, (uint8_t *) aph,
+ SCTP_CAUSE_UNRESOLVABLE_ADDR, (uint8_t *)aph,
aparam_length);
return (m_reply);
}
@@ -565,7 +565,7 @@ sctp_process_asconf_set_primary(struct sockaddr *src,
"process_asconf_set_primary: set primary failed!\n");
/* must have been an invalid address, so report */
m_reply = sctp_asconf_error_response(aph->correlation_id,
- SCTP_CAUSE_UNRESOLVABLE_ADDR, (uint8_t *) aph,
+ SCTP_CAUSE_UNRESOLVABLE_ADDR, (uint8_t *)aph,
aparam_length);
}
@@ -660,7 +660,7 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
/* skip the lookup address parameter */
offset += sizeof(struct sctp_asconf_chunk);
- p_addr = (struct sctp_ipv6addr_param *)sctp_m_getptr(m, offset, sizeof(struct sctp_paramhdr), (uint8_t *) & aparam_buf);
+ p_addr = (struct sctp_ipv6addr_param *)sctp_m_getptr(m, offset, sizeof(struct sctp_paramhdr), (uint8_t *)&aparam_buf);
if (p_addr == NULL) {
SCTPDBG(SCTP_DEBUG_ASCONF1,
"handle_asconf: couldn't get lookup addr!\n");
@@ -670,7 +670,7 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
/* param_length is already validated in process_control... */
offset += ntohs(p_addr->ph.param_length); /* skip lookup addr */
/* get pointer to first asconf param in ASCONF */
- aph = (struct sctp_asconf_paramhdr *)sctp_m_getptr(m, offset, sizeof(struct sctp_asconf_paramhdr), (uint8_t *) & aparam_buf);
+ aph = (struct sctp_asconf_paramhdr *)sctp_m_getptr(m, offset, sizeof(struct sctp_asconf_paramhdr), (uint8_t *)&aparam_buf);
if (aph == NULL) {
SCTPDBG(SCTP_DEBUG_ASCONF1, "Empty ASCONF received?\n");
goto send_reply;
@@ -767,7 +767,7 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
/* get pointer to next asconf param */
aph = (struct sctp_asconf_paramhdr *)sctp_m_getptr(m, offset,
sizeof(struct sctp_asconf_paramhdr),
- (uint8_t *) & aparam_buf);
+ (uint8_t *)&aparam_buf);
if (aph == NULL) {
/* can't get an asconf paramhdr */
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: can't get asconf param hdr!\n");
@@ -1096,7 +1096,7 @@ sctp_path_check_and_react(struct sctp_tcb *stcb, struct sctp_ifa *newifa)
* NOT corresponding to the current nexthop, the path will
* not be changed.
*/
- SCTP_RTALLOC((sctp_route_t *) & net->ro,
+ SCTP_RTALLOC((sctp_route_t *)&net->ro,
stcb->sctp_ep->def_vrf_id,
stcb->sctp_ep->fibnum);
if (net->ro.ro_rt == NULL)
@@ -1106,7 +1106,7 @@ sctp_path_check_and_react(struct sctp_tcb *stcb, struct sctp_ifa *newifa)
switch (net->ro._l_addr.sa.sa_family) {
#ifdef INET
case AF_INET:
- if (sctp_v4src_match_nexthop(newifa, (sctp_route_t *) & net->ro)) {
+ if (sctp_v4src_match_nexthop(newifa, (sctp_route_t *)&net->ro)) {
changed = 1;
}
break;
@@ -1114,7 +1114,7 @@ sctp_path_check_and_react(struct sctp_tcb *stcb, struct sctp_ifa *newifa)
#ifdef INET6
case AF_INET6:
if (sctp_v6src_match_nexthop(
- &newifa->address.sin6, (sctp_route_t *) & net->ro)) {
+ &newifa->address.sin6, (sctp_route_t *)&net->ro)) {
changed = 1;
}
break;
@@ -2421,8 +2421,10 @@ sctp_is_addr_pending(struct sctp_tcb *stcb, struct sctp_ifa *sctp_ifa)
}
}
- /* we want to find the sequences which consist of ADD -> DEL -> ADD
- * or DEL -> ADD */
+ /*
+ * we want to find the sequences which consist of ADD -> DEL -> ADD
+ * or DEL -> ADD
+ */
if (add_cnt > del_cnt ||
(add_cnt == del_cnt && last_param_type == SCTP_ADD_IP_ADDRESS)) {
return (1);
@@ -2474,8 +2476,10 @@ sctp_find_valid_localaddr(struct sctp_tcb *stcb, int addr_locked)
if (sctp_is_addr_restricted(stcb, sctp_ifa) &&
(!sctp_is_addr_pending(stcb, sctp_ifa)))
continue;
- /* found a valid local v4 address to
- * use */
+ /*
+ * found a valid local v4 address to
+ * use
+ */
if (addr_locked == SCTP_ADDR_NOT_LOCKED)
SCTP_IPI_ADDR_RUNLOCK();
return (&sctp_ifa->address.sa);
@@ -2492,8 +2496,10 @@ sctp_find_valid_localaddr(struct sctp_tcb *stcb, int addr_locked)
}
sin6 = &sctp_ifa->address.sin6;
if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
- /* we skip unspecifed
- * addresses */
+ /*
+ * we skip unspecifed
+ * addresses
+ */
continue;
}
if (prison_check_ip6(stcb->sctp_ep->ip_inp.inp.inp_cred,
@@ -2510,8 +2516,10 @@ sctp_find_valid_localaddr(struct sctp_tcb *stcb, int addr_locked)
if (sctp_is_addr_restricted(stcb, sctp_ifa) &&
(!sctp_is_addr_pending(stcb, sctp_ifa)))
continue;
- /* found a valid local v6 address to
- * use */
+ /*
+ * found a valid local v6 address to
+ * use
+ */
if (addr_locked == SCTP_ADDR_NOT_LOCKED)
SCTP_IPI_ADDR_RUNLOCK();
return (&sctp_ifa->address.sa);
@@ -2779,7 +2787,7 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m,
/* go through the addresses in the init-ack */
ph = (struct sctp_paramhdr *)
sctp_m_getptr(m, offset, sizeof(struct sctp_paramhdr),
- (uint8_t *) & tmp_param);
+ (uint8_t *)&tmp_param);
while (ph != NULL) {
ptype = ntohs(ph->param_type);
plen = ntohs(ph->param_length);
@@ -2793,7 +2801,7 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m,
a6p = (struct sctp_ipv6addr_param *)
sctp_m_getptr(m, offset,
sizeof(struct sctp_ipv6addr_param),
- (uint8_t *) & addr6_store);
+ (uint8_t *)&addr6_store);
if (plen != sizeof(struct sctp_ipv6addr_param) ||
a6p == NULL) {
return;
@@ -2814,7 +2822,7 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m,
/* get the entire IPv4 address param */
a4p = (struct sctp_ipv4addr_param *)sctp_m_getptr(m, offset,
sizeof(struct sctp_ipv4addr_param),
- (uint8_t *) & addr4_store);
+ (uint8_t *)&addr4_store);
if (plen != sizeof(struct sctp_ipv4addr_param) ||
a4p == NULL) {
return;
@@ -2876,7 +2884,7 @@ next_addr:
if ((offset + sizeof(struct sctp_paramhdr)) > length)
return;
ph = (struct sctp_paramhdr *)sctp_m_getptr(m, offset,
- sizeof(struct sctp_paramhdr), (uint8_t *) & tmp_param);
+ sizeof(struct sctp_paramhdr), (uint8_t *)&tmp_param);
} /* while */
}
@@ -2927,7 +2935,7 @@ sctp_addr_in_initack(struct mbuf *m, uint32_t offset, uint32_t length, struct so
}
/* go through the addresses in the init-ack */
ph = (struct sctp_paramhdr *)sctp_m_getptr(m, offset,
- sizeof(struct sctp_paramhdr), (uint8_t *) & tmp_param);
+ sizeof(struct sctp_paramhdr), (uint8_t *)&tmp_param);
while (ph != NULL) {
ptype = ntohs(ph->param_type);
plen = ntohs(ph->param_length);
@@ -2943,7 +2951,7 @@ sctp_addr_in_initack(struct mbuf *m, uint32_t offset, uint32_t length, struct so
a6p = (struct sctp_ipv6addr_param *)
sctp_m_getptr(m, offset,
sizeof(struct sctp_ipv6addr_param),
- (uint8_t *) & addr6_store);
+ (uint8_t *)&addr6_store);
if (a6p == NULL) {
return (0);
}
@@ -2973,7 +2981,7 @@ sctp_addr_in_initack(struct mbuf *m, uint32_t offset, uint32_t length, struct so
a4p = (struct sctp_ipv4addr_param *)
sctp_m_getptr(m, offset,
sizeof(struct sctp_ipv4addr_param),
- (uint8_t *) & addr4_store);
+ (uint8_t *)&addr4_store);
if (a4p == NULL) {
return (0);
}
@@ -2995,7 +3003,7 @@ sctp_addr_in_initack(struct mbuf *m, uint32_t offset, uint32_t length, struct so
}
ph = (struct sctp_paramhdr *)
sctp_m_getptr(m, offset, sizeof(struct sctp_paramhdr),
- (uint8_t *) & tmp_param);
+ (uint8_t *)&tmp_param);
} /* while */
/* not found! */
return (0);
diff --git a/freebsd/sys/netinet/sctp_auth.c b/freebsd/sys/netinet/sctp_auth.c
index 19e30718..4bcb2459 100644
--- a/freebsd/sys/netinet/sctp_auth.c
+++ b/freebsd/sys/netinet/sctp_auth.c
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
void
-sctp_clear_chunklist(sctp_auth_chklist_t * chklist)
+sctp_clear_chunklist(sctp_auth_chklist_t *chklist)
{
bzero(chklist, sizeof(*chklist));
/* chklist->num_chunks = 0; */
@@ -75,14 +75,14 @@ sctp_alloc_chunklist(void)
}
void
-sctp_free_chunklist(sctp_auth_chklist_t * list)
+sctp_free_chunklist(sctp_auth_chklist_t *list)
{
if (list != NULL)
SCTP_FREE(list, SCTP_M_AUTH_CL);
}
sctp_auth_chklist_t *
-sctp_copy_chunklist(sctp_auth_chklist_t * list)
+sctp_copy_chunklist(sctp_auth_chklist_t *list)
{
sctp_auth_chklist_t *new_list;
@@ -104,7 +104,7 @@ sctp_copy_chunklist(sctp_auth_chklist_t * list)
* add a chunk to the required chunks list
*/
int
-sctp_auth_add_chunk(uint8_t chunk, sctp_auth_chklist_t * list)
+sctp_auth_add_chunk(uint8_t chunk, sctp_auth_chklist_t *list)
{
if (list == NULL)
return (-1);
@@ -130,7 +130,7 @@ sctp_auth_add_chunk(uint8_t chunk, sctp_auth_chklist_t * list)
* delete a chunk from the required chunks list
*/
int
-sctp_auth_delete_chunk(uint8_t chunk, sctp_auth_chklist_t * list)
+sctp_auth_delete_chunk(uint8_t chunk, sctp_auth_chklist_t *list)
{
if (list == NULL)
return (-1);
@@ -146,7 +146,7 @@ sctp_auth_delete_chunk(uint8_t chunk, sctp_auth_chklist_t * list)
}
size_t
-sctp_auth_get_chklist_size(const sctp_auth_chklist_t * list)
+sctp_auth_get_chklist_size(const sctp_auth_chklist_t *list)
{
if (list == NULL)
return (0);
@@ -159,7 +159,7 @@ sctp_auth_get_chklist_size(const sctp_auth_chklist_t * list)
* guarantee ptr has space for up to 256 bytes
*/
int
-sctp_serialize_auth_chunks(const sctp_auth_chklist_t * list, uint8_t * ptr)
+sctp_serialize_auth_chunks(const sctp_auth_chklist_t *list, uint8_t *ptr)
{
int i, count = 0;
@@ -176,7 +176,7 @@ sctp_serialize_auth_chunks(const sctp_auth_chklist_t * list, uint8_t * ptr)
}
int
-sctp_pack_auth_chunks(const sctp_auth_chklist_t * list, uint8_t * ptr)
+sctp_pack_auth_chunks(const sctp_auth_chklist_t *list, uint8_t *ptr)
{
int i, size = 0;
@@ -208,8 +208,8 @@ sctp_pack_auth_chunks(const sctp_auth_chklist_t * list, uint8_t * ptr)
}
int
-sctp_unpack_auth_chunks(const uint8_t * ptr, uint8_t num_chunks,
- sctp_auth_chklist_t * list)
+sctp_unpack_auth_chunks(const uint8_t *ptr, uint8_t num_chunks,
+ sctp_auth_chklist_t *list)
{
int i;
int size;
@@ -259,14 +259,14 @@ sctp_alloc_key(uint32_t keylen)
}
void
-sctp_free_key(sctp_key_t * key)
+sctp_free_key(sctp_key_t *key)
{
if (key != NULL)
SCTP_FREE(key, SCTP_M_AUTH_KY);
}
void
-sctp_print_key(sctp_key_t * key, const char *str)
+sctp_print_key(sctp_key_t *key, const char *str)
{
uint32_t i;
@@ -285,7 +285,7 @@ sctp_print_key(sctp_key_t * key, const char *str)
}
void
-sctp_show_key(sctp_key_t * key, const char *str)
+sctp_show_key(sctp_key_t *key, const char *str)
{
uint32_t i;
@@ -304,7 +304,7 @@ sctp_show_key(sctp_key_t * key, const char *str)
}
static uint32_t
-sctp_get_keylen(sctp_key_t * key)
+sctp_get_keylen(sctp_key_t *key)
{
if (key != NULL)
return (key->keylen);
@@ -331,7 +331,7 @@ sctp_generate_random_key(uint32_t keylen)
}
sctp_key_t *
-sctp_set_key(uint8_t * key, uint32_t keylen)
+sctp_set_key(uint8_t *key, uint32_t keylen)
{
sctp_key_t *new_key;
@@ -351,7 +351,7 @@ sctp_set_key(uint8_t * key, uint32_t keylen)
* 0 if key1 = key2
*/
static int
-sctp_compare_key(sctp_key_t * key1, sctp_key_t * key2)
+sctp_compare_key(sctp_key_t *key1, sctp_key_t *key2)
{
uint32_t maxlen;
uint32_t i;
@@ -402,7 +402,7 @@ sctp_compare_key(sctp_key_t * key1, sctp_key_t * key2)
* order for concatenation
*/
sctp_key_t *
-sctp_compute_hashkey(sctp_key_t * key1, sctp_key_t * key2, sctp_key_t * shared)
+sctp_compute_hashkey(sctp_key_t *key1, sctp_key_t *key2, sctp_key_t *shared)
{
uint32_t keylen;
sctp_key_t *new_key;
@@ -476,7 +476,7 @@ sctp_alloc_sharedkey(void)
}
void
-sctp_free_sharedkey(sctp_sharedkey_t * skey)
+sctp_free_sharedkey(sctp_sharedkey_t *skey)
{
if (skey == NULL)
return;
@@ -502,7 +502,7 @@ sctp_find_sharedkey(struct sctp_keyhead *shared_keys, uint16_t key_id)
int
sctp_insert_sharedkey(struct sctp_keyhead *shared_keys,
- sctp_sharedkey_t * new_skey)
+ sctp_sharedkey_t *new_skey)
{
sctp_sharedkey_t *skey;
@@ -596,7 +596,7 @@ sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked
}
static sctp_sharedkey_t *
-sctp_copy_sharedkey(const sctp_sharedkey_t * skey)
+sctp_copy_sharedkey(const sctp_sharedkey_t *skey)
{
sctp_sharedkey_t *new_skey;
@@ -654,7 +654,7 @@ sctp_alloc_hmaclist(uint16_t num_hmacs)
}
void
-sctp_free_hmaclist(sctp_hmaclist_t * list)
+sctp_free_hmaclist(sctp_hmaclist_t *list)
{
if (list != NULL) {
SCTP_FREE(list, SCTP_M_AUTH_HL);
@@ -663,7 +663,7 @@ sctp_free_hmaclist(sctp_hmaclist_t * list)
}
int
-sctp_auth_add_hmacid(sctp_hmaclist_t * list, uint16_t hmac_id)
+sctp_auth_add_hmacid(sctp_hmaclist_t *list, uint16_t hmac_id)
{
int i;
@@ -691,7 +691,7 @@ sctp_auth_add_hmacid(sctp_hmaclist_t * list, uint16_t hmac_id)
}
sctp_hmaclist_t *
-sctp_copy_hmaclist(sctp_hmaclist_t * list)
+sctp_copy_hmaclist(sctp_hmaclist_t *list)
{
sctp_hmaclist_t *new_list;
int i;
@@ -729,7 +729,7 @@ sctp_default_supported_hmaclist(void)
* find the best HMAC id to use for the peer based on local support
*/
uint16_t
-sctp_negotiate_hmacid(sctp_hmaclist_t * peer, sctp_hmaclist_t * local)
+sctp_negotiate_hmacid(sctp_hmaclist_t *peer, sctp_hmaclist_t *local)
{
int i, j;
@@ -756,7 +756,7 @@ sctp_negotiate_hmacid(sctp_hmaclist_t * peer, sctp_hmaclist_t * local)
* caller must guarantee ptr has appropriate space
*/
int
-sctp_serialize_hmaclist(sctp_hmaclist_t * list, uint8_t * ptr)
+sctp_serialize_hmaclist(sctp_hmaclist_t *list, uint8_t *ptr)
{
int i;
uint16_t hmac_id;
@@ -802,7 +802,7 @@ sctp_alloc_authinfo(void)
}
void
-sctp_free_authinfo(sctp_authinfo_t * authinfo)
+sctp_free_authinfo(sctp_authinfo_t *authinfo)
{
if (authinfo == NULL)
return;
@@ -860,7 +860,7 @@ sctp_get_hmac_block_len(uint16_t hmac_algo)
}
static void
-sctp_hmac_init(uint16_t hmac_algo, sctp_hash_context_t * ctx)
+sctp_hmac_init(uint16_t hmac_algo, sctp_hash_context_t *ctx)
{
switch (hmac_algo) {
case SCTP_AUTH_HMAC_ID_SHA1:
@@ -877,8 +877,8 @@ sctp_hmac_init(uint16_t hmac_algo, sctp_hash_context_t * ctx)
}
static void
-sctp_hmac_update(uint16_t hmac_algo, sctp_hash_context_t * ctx,
- uint8_t * text, uint32_t textlen)
+sctp_hmac_update(uint16_t hmac_algo, sctp_hash_context_t *ctx,
+ uint8_t *text, uint32_t textlen)
{
switch (hmac_algo) {
case SCTP_AUTH_HMAC_ID_SHA1:
@@ -895,8 +895,8 @@ sctp_hmac_update(uint16_t hmac_algo, sctp_hash_context_t * ctx,
}
static void
-sctp_hmac_final(uint16_t hmac_algo, sctp_hash_context_t * ctx,
- uint8_t * digest)
+sctp_hmac_final(uint16_t hmac_algo, sctp_hash_context_t *ctx,
+ uint8_t *digest)
{
switch (hmac_algo) {
case SCTP_AUTH_HMAC_ID_SHA1:
@@ -923,8 +923,8 @@ sctp_hmac_final(uint16_t hmac_algo, sctp_hash_context_t * ctx,
* resultant digest.
*/
uint32_t
-sctp_hmac(uint16_t hmac_algo, uint8_t * key, uint32_t keylen,
- uint8_t * text, uint32_t textlen, uint8_t * digest)
+sctp_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
+ uint8_t *text, uint32_t textlen, uint8_t *digest)
{
uint32_t digestlen;
uint32_t blocklen;
@@ -983,8 +983,8 @@ sctp_hmac(uint16_t hmac_algo, uint8_t * key, uint32_t keylen,
/* mbuf version */
uint32_t
-sctp_hmac_m(uint16_t hmac_algo, uint8_t * key, uint32_t keylen,
- struct mbuf *m, uint32_t m_offset, uint8_t * digest, uint32_t trailer)
+sctp_hmac_m(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
+ struct mbuf *m, uint32_t m_offset, uint8_t *digest, uint32_t trailer)
{
uint32_t digestlen;
uint32_t blocklen;
@@ -1031,17 +1031,17 @@ sctp_hmac_m(uint16_t hmac_algo, uint8_t * key, uint32_t keylen,
sctp_hmac_update(hmac_algo, &ctx, ipad, blocklen);
/* find the correct starting mbuf and offset (get start of text) */
m_tmp = m;
- while ((m_tmp != NULL) && (m_offset >= (uint32_t) SCTP_BUF_LEN(m_tmp))) {
+ while ((m_tmp != NULL) && (m_offset >= (uint32_t)SCTP_BUF_LEN(m_tmp))) {
m_offset -= SCTP_BUF_LEN(m_tmp);
m_tmp = SCTP_BUF_NEXT(m_tmp);
}
/* now use the rest of the mbuf chain for the text */
while (m_tmp != NULL) {
if ((SCTP_BUF_NEXT(m_tmp) == NULL) && trailer) {
- sctp_hmac_update(hmac_algo, &ctx, mtod(m_tmp, uint8_t *) + m_offset,
+ sctp_hmac_update(hmac_algo, &ctx, mtod(m_tmp, uint8_t *)+m_offset,
SCTP_BUF_LEN(m_tmp) - (trailer + m_offset));
} else {
- sctp_hmac_update(hmac_algo, &ctx, mtod(m_tmp, uint8_t *) + m_offset,
+ sctp_hmac_update(hmac_algo, &ctx, mtod(m_tmp, uint8_t *)+m_offset,
SCTP_BUF_LEN(m_tmp) - m_offset);
}
@@ -1066,9 +1066,9 @@ sctp_hmac_m(uint16_t hmac_algo, uint8_t * key, uint32_t keylen,
* Returns -1 on error, 0 on success.
*/
int
-sctp_verify_hmac(uint16_t hmac_algo, uint8_t * key, uint32_t keylen,
- uint8_t * text, uint32_t textlen,
- uint8_t * digest, uint32_t digestlen)
+sctp_verify_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
+ uint8_t *text, uint32_t textlen,
+ uint8_t *digest, uint32_t digestlen)
{
uint32_t len;
uint8_t temp[SCTP_AUTH_DIGEST_LEN_MAX];
@@ -1099,8 +1099,8 @@ sctp_verify_hmac(uint16_t hmac_algo, uint8_t * key, uint32_t keylen,
* the keylen exceeds the HMAC block len).
*/
uint32_t
-sctp_compute_hmac(uint16_t hmac_algo, sctp_key_t * key, uint8_t * text,
- uint32_t textlen, uint8_t * digest)
+sctp_compute_hmac(uint16_t hmac_algo, sctp_key_t *key, uint8_t *text,
+ uint32_t textlen, uint8_t *digest)
{
uint32_t digestlen;
uint32_t blocklen;
@@ -1134,8 +1134,8 @@ sctp_compute_hmac(uint16_t hmac_algo, sctp_key_t * key, uint8_t * text,
/* mbuf version */
uint32_t
-sctp_compute_hmac_m(uint16_t hmac_algo, sctp_key_t * key, struct mbuf *m,
- uint32_t m_offset, uint8_t * digest)
+sctp_compute_hmac_m(uint16_t hmac_algo, sctp_key_t *key, struct mbuf *m,
+ uint32_t m_offset, uint8_t *digest)
{
uint32_t digestlen;
uint32_t blocklen;
@@ -1166,7 +1166,7 @@ sctp_compute_hmac_m(uint16_t hmac_algo, sctp_key_t * key, struct mbuf *m,
}
int
-sctp_auth_is_supported_hmac(sctp_hmaclist_t * list, uint16_t id)
+sctp_auth_is_supported_hmac(sctp_hmaclist_t *list, uint16_t id)
{
int i;
@@ -1424,7 +1424,7 @@ sctp_auth_get_cookie_params(struct sctp_tcb *stcb, struct mbuf *m,
length += offset;
phdr = (struct sctp_paramhdr *)sctp_m_getptr(m, offset,
- sizeof(struct sctp_paramhdr), (uint8_t *) & tmp_param);
+ sizeof(struct sctp_paramhdr), (uint8_t *)&tmp_param);
while (phdr != NULL) {
ptype = ntohs(phdr->param_type);
plen = ntohs(phdr->param_length);
@@ -1491,7 +1491,7 @@ sctp_auth_get_cookie_params(struct sctp_tcb *stcb, struct mbuf *m,
if (offset + sizeof(struct sctp_paramhdr) > length)
break;
phdr = (struct sctp_paramhdr *)sctp_m_getptr(m, offset, sizeof(struct sctp_paramhdr),
- (uint8_t *) & tmp_param);
+ (uint8_t *)&tmp_param);
}
/* concatenate the full random key */
keylen = sizeof(*p_random) + random_len + sizeof(*hmacs) + hmacs_len;
@@ -1601,14 +1601,14 @@ sctp_bzero_m(struct mbuf *m, uint32_t m_offset, uint32_t size)
/* find the correct starting mbuf and offset (get start position) */
m_tmp = m;
- while ((m_tmp != NULL) && (m_offset >= (uint32_t) SCTP_BUF_LEN(m_tmp))) {
+ while ((m_tmp != NULL) && (m_offset >= (uint32_t)SCTP_BUF_LEN(m_tmp))) {
m_offset -= SCTP_BUF_LEN(m_tmp);
m_tmp = SCTP_BUF_NEXT(m_tmp);
}
/* now use the rest of the mbuf chain */
while ((m_tmp != NULL) && (size > 0)) {
- data = mtod(m_tmp, uint8_t *) + m_offset;
- if (size > (uint32_t) SCTP_BUF_LEN(m_tmp)) {
+ data = mtod(m_tmp, uint8_t *)+m_offset;
+ if (size > (uint32_t)SCTP_BUF_LEN(m_tmp)) {
bzero(data, SCTP_BUF_LEN(m_tmp));
size -= SCTP_BUF_LEN(m_tmp);
} else {
diff --git a/freebsd/sys/netinet/sctp_auth.h b/freebsd/sys/netinet/sctp_auth.h
index b98764e2..04fd6464 100644
--- a/freebsd/sys/netinet/sctp_auth.h
+++ b/freebsd/sys/netinet/sctp_auth.h
@@ -51,12 +51,12 @@ __FBSDID("$FreeBSD$");
typedef union sctp_hash_context {
SCTP_SHA1_CTX sha1;
SCTP_SHA256_CTX sha256;
-} sctp_hash_context_t;
+} sctp_hash_context_t;
typedef struct sctp_key {
uint32_t keylen;
uint8_t key[];
-} sctp_key_t;
+} sctp_key_t;
typedef struct sctp_shared_key {
LIST_ENTRY(sctp_shared_key) next;
@@ -64,7 +64,7 @@ typedef struct sctp_shared_key {
uint32_t refcount; /* reference count */
uint16_t keyid; /* shared key ID */
uint8_t deactivated; /* key is deactivated */
-} sctp_sharedkey_t;
+} sctp_sharedkey_t;
LIST_HEAD(sctp_keyhead, sctp_shared_key);
@@ -72,14 +72,14 @@ LIST_HEAD(sctp_keyhead, sctp_shared_key);
typedef struct sctp_auth_chklist {
uint8_t chunks[256];
uint8_t num_chunks;
-} sctp_auth_chklist_t;
+} sctp_auth_chklist_t;
/* hmac algos supported list */
typedef struct sctp_hmaclist {
uint16_t max_algo; /* max algorithms allocated */
uint16_t num_algo; /* num algorithms used */
uint16_t hmac[];
-} sctp_hmaclist_t;
+} sctp_hmaclist_t;
/* authentication info */
typedef struct sctp_authinformation {
@@ -91,7 +91,7 @@ typedef struct sctp_authinformation {
uint16_t active_keyid; /* active send keyid */
uint16_t assoc_keyid; /* current send keyid (cached) */
uint16_t recv_keyid; /* last recv keyid (cached) */
-} sctp_authinfo_t;
+} sctp_authinfo_t;
@@ -106,42 +106,42 @@ typedef struct sctp_authinformation {
/* socket option api functions */
extern sctp_auth_chklist_t *sctp_alloc_chunklist(void);
-extern void sctp_free_chunklist(sctp_auth_chklist_t * chklist);
-extern void sctp_clear_chunklist(sctp_auth_chklist_t * chklist);
-extern sctp_auth_chklist_t *sctp_copy_chunklist(sctp_auth_chklist_t * chklist);
-extern int sctp_auth_add_chunk(uint8_t chunk, sctp_auth_chklist_t * list);
-extern int sctp_auth_delete_chunk(uint8_t chunk, sctp_auth_chklist_t * list);
-extern size_t sctp_auth_get_chklist_size(const sctp_auth_chklist_t * list);
+extern void sctp_free_chunklist(sctp_auth_chklist_t *chklist);
+extern void sctp_clear_chunklist(sctp_auth_chklist_t *chklist);
+extern sctp_auth_chklist_t *sctp_copy_chunklist(sctp_auth_chklist_t *chklist);
+extern int sctp_auth_add_chunk(uint8_t chunk, sctp_auth_chklist_t *list);
+extern int sctp_auth_delete_chunk(uint8_t chunk, sctp_auth_chklist_t *list);
+extern size_t sctp_auth_get_chklist_size(const sctp_auth_chklist_t *list);
extern int
-sctp_serialize_auth_chunks(const sctp_auth_chklist_t * list,
- uint8_t * ptr);
+sctp_serialize_auth_chunks(const sctp_auth_chklist_t *list,
+ uint8_t *ptr);
extern int
-sctp_pack_auth_chunks(const sctp_auth_chklist_t * list,
- uint8_t * ptr);
+sctp_pack_auth_chunks(const sctp_auth_chklist_t *list,
+ uint8_t *ptr);
extern int
-sctp_unpack_auth_chunks(const uint8_t * ptr, uint8_t num_chunks,
- sctp_auth_chklist_t * list);
+sctp_unpack_auth_chunks(const uint8_t *ptr, uint8_t num_chunks,
+ sctp_auth_chklist_t *list);
/* key handling */
extern sctp_key_t *sctp_alloc_key(uint32_t keylen);
-extern void sctp_free_key(sctp_key_t * key);
-extern void sctp_print_key(sctp_key_t * key, const char *str);
-extern void sctp_show_key(sctp_key_t * key, const char *str);
+extern void sctp_free_key(sctp_key_t *key);
+extern void sctp_print_key(sctp_key_t *key, const char *str);
+extern void sctp_show_key(sctp_key_t *key, const char *str);
extern sctp_key_t *sctp_generate_random_key(uint32_t keylen);
-extern sctp_key_t *sctp_set_key(uint8_t * key, uint32_t keylen);
+extern sctp_key_t *sctp_set_key(uint8_t *key, uint32_t keylen);
extern sctp_key_t *
-sctp_compute_hashkey(sctp_key_t * key1, sctp_key_t * key2,
- sctp_key_t * shared);
+sctp_compute_hashkey(sctp_key_t *key1, sctp_key_t *key2,
+ sctp_key_t *shared);
/* shared key handling */
extern sctp_sharedkey_t *sctp_alloc_sharedkey(void);
-extern void sctp_free_sharedkey(sctp_sharedkey_t * skey);
+extern void sctp_free_sharedkey(sctp_sharedkey_t *skey);
extern sctp_sharedkey_t *
sctp_find_sharedkey(struct sctp_keyhead *shared_keys,
uint16_t key_id);
extern int
sctp_insert_sharedkey(struct sctp_keyhead *shared_keys,
- sctp_sharedkey_t * new_skey);
+ sctp_sharedkey_t *new_skey);
extern int
sctp_copy_skeylist(const struct sctp_keyhead *src,
struct sctp_keyhead *dest);
@@ -155,42 +155,42 @@ sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t keyid,
/* hmac list handling */
extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint16_t num_hmacs);
-extern void sctp_free_hmaclist(sctp_hmaclist_t * list);
-extern int sctp_auth_add_hmacid(sctp_hmaclist_t * list, uint16_t hmac_id);
-extern sctp_hmaclist_t *sctp_copy_hmaclist(sctp_hmaclist_t * list);
+extern void sctp_free_hmaclist(sctp_hmaclist_t *list);
+extern int sctp_auth_add_hmacid(sctp_hmaclist_t *list, uint16_t hmac_id);
+extern sctp_hmaclist_t *sctp_copy_hmaclist(sctp_hmaclist_t *list);
extern sctp_hmaclist_t *sctp_default_supported_hmaclist(void);
extern uint16_t
-sctp_negotiate_hmacid(sctp_hmaclist_t * peer,
- sctp_hmaclist_t * local);
-extern int sctp_serialize_hmaclist(sctp_hmaclist_t * list, uint8_t * ptr);
+sctp_negotiate_hmacid(sctp_hmaclist_t *peer,
+ sctp_hmaclist_t *local);
+extern int sctp_serialize_hmaclist(sctp_hmaclist_t *list, uint8_t *ptr);
extern int
sctp_verify_hmac_param(struct sctp_auth_hmac_algo *hmacs,
uint32_t num_hmacs);
extern sctp_authinfo_t *sctp_alloc_authinfo(void);
-extern void sctp_free_authinfo(sctp_authinfo_t * authinfo);
+extern void sctp_free_authinfo(sctp_authinfo_t *authinfo);
/* keyed-HMAC functions */
extern uint32_t sctp_get_auth_chunk_len(uint16_t hmac_algo);
extern uint32_t sctp_get_hmac_digest_len(uint16_t hmac_algo);
extern uint32_t
-sctp_hmac(uint16_t hmac_algo, uint8_t * key, uint32_t keylen,
- uint8_t * text, uint32_t textlen, uint8_t * digest);
+sctp_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
+ uint8_t *text, uint32_t textlen, uint8_t *digest);
extern int
-sctp_verify_hmac(uint16_t hmac_algo, uint8_t * key, uint32_t keylen,
- uint8_t * text, uint32_t textlen, uint8_t * digest, uint32_t digestlen);
+sctp_verify_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
+ uint8_t *text, uint32_t textlen, uint8_t *digest, uint32_t digestlen);
extern uint32_t
-sctp_compute_hmac(uint16_t hmac_algo, sctp_key_t * key,
- uint8_t * text, uint32_t textlen, uint8_t * digest);
-extern int sctp_auth_is_supported_hmac(sctp_hmaclist_t * list, uint16_t id);
+sctp_compute_hmac(uint16_t hmac_algo, sctp_key_t *key,
+ uint8_t *text, uint32_t textlen, uint8_t *digest);
+extern int sctp_auth_is_supported_hmac(sctp_hmaclist_t *list, uint16_t id);
/* mbuf versions */
extern uint32_t
-sctp_hmac_m(uint16_t hmac_algo, uint8_t * key, uint32_t keylen,
- struct mbuf *m, uint32_t m_offset, uint8_t * digest, uint32_t trailer);
+sctp_hmac_m(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
+ struct mbuf *m, uint32_t m_offset, uint8_t *digest, uint32_t trailer);
extern uint32_t
-sctp_compute_hmac_m(uint16_t hmac_algo, sctp_key_t * key,
- struct mbuf *m, uint32_t m_offset, uint8_t * digest);
+sctp_compute_hmac_m(uint16_t hmac_algo, sctp_key_t *key,
+ struct mbuf *m, uint32_t m_offset, uint8_t *digest);
/*
* authentication routines
@@ -212,7 +212,7 @@ sctp_fill_hmac_digest_m(struct mbuf *m, uint32_t auth_offset,
struct sctp_auth_chunk *auth, struct sctp_tcb *stcb, uint16_t key_id);
extern struct mbuf *
sctp_add_auth_chunk(struct mbuf *m, struct mbuf **m_end,
- struct sctp_auth_chunk **auth_ret, uint32_t * offset,
+ struct sctp_auth_chunk **auth_ret, uint32_t *offset,
struct sctp_tcb *stcb, uint8_t chunk);
extern int
sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *ch,
diff --git a/freebsd/sys/netinet/sctp_bsd_addr.c b/freebsd/sys/netinet/sctp_bsd_addr.c
index 72c63d76..b3cb2ce3 100644
--- a/freebsd/sys/netinet/sctp_bsd_addr.c
+++ b/freebsd/sys/netinet/sctp_bsd_addr.c
@@ -479,7 +479,7 @@ again_locked:
lenat++;
*lenat = value;
lenat++;
- tick_tock = (uint32_t *) lenat;
+ tick_tock = (uint32_t *)lenat;
lenat++;
*tick_tock = sctp_get_tick_count();
copyto = (void *)lenat;
@@ -500,7 +500,7 @@ no_log:
int
-sctp_copy_out_packet_log(uint8_t * target, int length)
+sctp_copy_out_packet_log(uint8_t *target, int length)
{
/*
* We wind through the packet log starting at start copying up to
diff --git a/freebsd/sys/netinet/sctp_bsd_addr.h b/freebsd/sys/netinet/sctp_bsd_addr.h
index 5fb1efb4..8c0383a5 100644
--- a/freebsd/sys/netinet/sctp_bsd_addr.h
+++ b/freebsd/sys/netinet/sctp_bsd_addr.h
@@ -53,7 +53,7 @@ void sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa);
#ifdef SCTP_PACKET_LOGGING
void sctp_packet_log(struct mbuf *m);
-int sctp_copy_out_packet_log(uint8_t * target, int length);
+int sctp_copy_out_packet_log(uint8_t *target, int length);
#endif
diff --git a/freebsd/sys/netinet/sctp_cc_functions.c b/freebsd/sys/netinet/sctp_cc_functions.c
index 49670e9b..b153d325 100644
--- a/freebsd/sys/netinet/sctp_cc_functions.c
+++ b/freebsd/sys/netinet/sctp_cc_functions.c
@@ -124,7 +124,7 @@ sctp_cwnd_update_after_fr(struct sctp_tcb *stcb,
t_ssthresh += net->ssthresh;
t_cwnd += net->cwnd;
if (net->lastsa > 0) {
- t_ucwnd_sbw += (uint64_t) net->cwnd / (uint64_t) net->lastsa;
+ t_ucwnd_sbw += (uint64_t)net->cwnd / (uint64_t)net->lastsa;
}
}
if (t_ucwnd_sbw == 0) {
@@ -152,27 +152,31 @@ sctp_cwnd_update_after_fr(struct sctp_tcb *stcb,
if ((asoc->sctp_cmt_on_off == SCTP_CMT_RPV1) ||
(asoc->sctp_cmt_on_off == SCTP_CMT_RPV2)) {
if (asoc->sctp_cmt_on_off == SCTP_CMT_RPV1) {
- net->ssthresh = (uint32_t) (((uint64_t) 4 *
- (uint64_t) net->mtu *
- (uint64_t) net->ssthresh) /
- (uint64_t) t_ssthresh);
+ net->ssthresh = (uint32_t)(((uint64_t)4 *
+ (uint64_t)net->mtu *
+ (uint64_t)net->ssthresh) /
+ (uint64_t)t_ssthresh);
}
if (asoc->sctp_cmt_on_off == SCTP_CMT_RPV2) {
uint32_t srtt;
srtt = net->lastsa;
- /* lastsa>>3; we don't need
- * to devide ... */
+ /*
+ * lastsa>>3; we don't need
+ * to devide ...
+ */
if (srtt == 0) {
srtt = 1;
}
- /* Short Version => Equal to
- * Contel Version MBe */
- net->ssthresh = (uint32_t) (((uint64_t) 4 *
- (uint64_t) net->mtu *
- (uint64_t) net->cwnd) /
- ((uint64_t) srtt *
+ /*
+ * Short Version => Equal to
+ * Contel Version MBe
+ */
+ net->ssthresh = (uint32_t)(((uint64_t)4 *
+ (uint64_t)net->mtu *
+ (uint64_t)net->cwnd) /
+ ((uint64_t)srtt *
t_ucwnd_sbw));
/* INCREASE FACTOR */ ;
}
@@ -251,7 +255,7 @@ cc_bw_same(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw,
{
uint64_t oth, probepoint;
- probepoint = (((uint64_t) net->cwnd) << 32);
+ probepoint = (((uint64_t)net->cwnd) << 32);
if (net->rtt > net->cc_mod.rtcc.lbw_rtt + rtt_offset) {
/*
* rtt increased we don't update bw.. so we don't update the
@@ -387,7 +391,7 @@ cc_bw_decrease(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw, uint6
uint64_t oth, probepoint;
/* Bandwidth decreased. */
- probepoint = (((uint64_t) net->cwnd) << 32);
+ probepoint = (((uint64_t)net->cwnd) << 32);
if (net->rtt > net->cc_mod.rtcc.lbw_rtt + rtt_offset) {
/* rtt increased */
/* Did we add more */
@@ -403,8 +407,10 @@ cc_bw_decrease(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw, uint6
net->flight_size,
probepoint);
if (net->cc_mod.rtcc.ret_from_eq) {
- /* Switch over to CA if we are less
- * aggressive */
+ /*
+ * Switch over to CA if we are less
+ * aggressive
+ */
net->ssthresh = net->cwnd - 1;
net->partial_bytes_acked = 0;
}
@@ -530,7 +536,7 @@ cc_bw_increase(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw, uint6
* attention to the inst_ind since our overall sum is increasing.
*/
/* PROBE POINT 0 */
- probepoint = (((uint64_t) net->cwnd) << 32);
+ probepoint = (((uint64_t)net->cwnd) << 32);
SDT_PROBE5(sctp, cwnd, net, rttvar,
vtag,
((net->cc_mod.rtcc.lbw << 32) | nbw),
@@ -612,8 +618,8 @@ cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw)
*/
bw_shift = SCTP_BASE_SYSCTL(sctp_rttvar_bw);
rtt = stcb->asoc.my_vtag;
- vtag = (rtt << 32) | (((uint32_t) (stcb->sctp_ep->sctp_lport)) << 16) | (stcb->rport);
- probepoint = (((uint64_t) net->cwnd) << 32);
+ vtag = (rtt << 32) | (((uint32_t)(stcb->sctp_ep->sctp_lport)) << 16) | (stcb->rport);
+ probepoint = (((uint64_t)net->cwnd) << 32);
rtt = net->rtt;
if (net->cc_mod.rtcc.rtt_set_this_sack) {
net->cc_mod.rtcc.rtt_set_this_sack = 0;
@@ -633,7 +639,7 @@ cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw)
probepoint |= ((0xb << 16) | inst_ind);
} else {
inst_ind = net->cc_mod.rtcc.last_inst_ind;
- inst_bw = bytes_for_this_rtt / (uint64_t) (net->rtt);
+ inst_bw = bytes_for_this_rtt / (uint64_t)(net->rtt);
/* Can't determine do not change */
probepoint |= ((0xc << 16) | inst_ind);
}
@@ -705,11 +711,11 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb,
if (srtt > 0) {
uint64_t tmp;
- t_ucwnd_sbw += (uint64_t) net->cwnd / (uint64_t) srtt;
- t_path_mptcp += (((uint64_t) net->cwnd) << SHIFT_MPTCP_MULTI_Z) /
- (((uint64_t) net->mtu) * (uint64_t) srtt);
- tmp = (((uint64_t) net->cwnd) << SHIFT_MPTCP_MULTI_N) /
- ((uint64_t) net->mtu * (uint64_t) (srtt * srtt));
+ t_ucwnd_sbw += (uint64_t)net->cwnd / (uint64_t)srtt;
+ t_path_mptcp += (((uint64_t)net->cwnd) << SHIFT_MPTCP_MULTI_Z) /
+ (((uint64_t)net->mtu) * (uint64_t)srtt);
+ tmp = (((uint64_t)net->cwnd) << SHIFT_MPTCP_MULTI_N) /
+ ((uint64_t)net->mtu * (uint64_t)(srtt * srtt));
if (tmp > max_path) {
max_path = tmp;
}
@@ -797,10 +803,10 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb,
} else {
uint64_t vtag, probepoint;
- probepoint = (((uint64_t) net->cwnd) << 32);
+ probepoint = (((uint64_t)net->cwnd) << 32);
probepoint |= ((0xa << 16) | 0);
vtag = (net->rtt << 32) |
- (((uint32_t) (stcb->sctp_ep->sctp_lport)) << 16) |
+ (((uint32_t)(stcb->sctp_ep->sctp_lport)) << 16) |
(stcb->rport);
SDT_PROBE5(sctp, cwnd, net, rttvar,
@@ -832,13 +838,13 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb,
old_cwnd = net->cwnd;
switch (asoc->sctp_cmt_on_off) {
case SCTP_CMT_RPV1:
- limit = (uint32_t) (((uint64_t) net->mtu *
- (uint64_t) SCTP_BASE_SYSCTL(sctp_L2_abc_variable) *
- (uint64_t) net->ssthresh) /
- (uint64_t) t_ssthresh);
- incr = (uint32_t) (((uint64_t) net->net_ack *
- (uint64_t) net->ssthresh) /
- (uint64_t) t_ssthresh);
+ limit = (uint32_t)(((uint64_t)net->mtu *
+ (uint64_t)SCTP_BASE_SYSCTL(sctp_L2_abc_variable) *
+ (uint64_t)net->ssthresh) /
+ (uint64_t)t_ssthresh);
+ incr = (uint32_t)(((uint64_t)net->net_ack *
+ (uint64_t)net->ssthresh) /
+ (uint64_t)t_ssthresh);
if (incr > limit) {
incr = limit;
}
@@ -847,20 +853,22 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb,
}
break;
case SCTP_CMT_RPV2:
- /* lastsa>>3; we don't need
- * to divide ... */
+ /*
+ * lastsa>>3; we don't need
+ * to divide ...
+ */
srtt = net->lastsa;
if (srtt == 0) {
srtt = 1;
}
- limit = (uint32_t) (((uint64_t) net->mtu *
- (uint64_t) SCTP_BASE_SYSCTL(sctp_L2_abc_variable) *
- (uint64_t) net->cwnd) /
- ((uint64_t) srtt * t_ucwnd_sbw));
+ limit = (uint32_t)(((uint64_t)net->mtu *
+ (uint64_t)SCTP_BASE_SYSCTL(sctp_L2_abc_variable) *
+ (uint64_t)net->cwnd) /
+ ((uint64_t)srtt * t_ucwnd_sbw));
/* INCREASE FACTOR */
- incr = (uint32_t) (((uint64_t) net->net_ack *
- (uint64_t) net->cwnd) /
- ((uint64_t) srtt * t_ucwnd_sbw));
+ incr = (uint32_t)(((uint64_t)net->net_ack *
+ (uint64_t)net->cwnd) /
+ ((uint64_t)srtt * t_ucwnd_sbw));
/* INCREASE FACTOR */
if (incr > limit) {
incr = limit;
@@ -870,11 +878,11 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb,
}
break;
case SCTP_CMT_MPTCP:
- limit = (uint32_t) (((uint64_t) net->mtu *
+ limit = (uint32_t)(((uint64_t)net->mtu *
mptcp_like_alpha *
- (uint64_t) SCTP_BASE_SYSCTL(sctp_L2_abc_variable)) >>
+ (uint64_t)SCTP_BASE_SYSCTL(sctp_L2_abc_variable)) >>
SHIFT_MPTCP_MULTI);
- incr = (uint32_t) (((uint64_t) net->net_ack *
+ incr = (uint32_t)(((uint64_t)net->net_ack *
mptcp_like_alpha) >>
SHIFT_MPTCP_MULTI);
if (incr > limit) {
@@ -924,23 +932,25 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb,
old_cwnd = net->cwnd;
switch (asoc->sctp_cmt_on_off) {
case SCTP_CMT_RPV1:
- incr = (uint32_t) (((uint64_t) net->mtu *
- (uint64_t) net->ssthresh) /
- (uint64_t) t_ssthresh);
+ incr = (uint32_t)(((uint64_t)net->mtu *
+ (uint64_t)net->ssthresh) /
+ (uint64_t)t_ssthresh);
if (incr == 0) {
incr = 1;
}
break;
case SCTP_CMT_RPV2:
- /* lastsa>>3; we don't need
- * to divide ... */
+ /*
+ * lastsa>>3; we don't need
+ * to divide ...
+ */
srtt = net->lastsa;
if (srtt == 0) {
srtt = 1;
}
- incr = (uint32_t) ((uint64_t) net->mtu *
- (uint64_t) net->cwnd /
- ((uint64_t) srtt *
+ incr = (uint32_t)((uint64_t)net->mtu *
+ (uint64_t)net->cwnd /
+ ((uint64_t)srtt *
t_ucwnd_sbw));
/* INCREASE FACTOR */
if (incr == 0) {
@@ -948,8 +958,8 @@ sctp_cwnd_update_after_sack_common(struct sctp_tcb *stcb,
}
break;
case SCTP_CMT_MPTCP:
- incr = (uint32_t) ((mptcp_like_alpha *
- (uint64_t) net->cwnd) >>
+ incr = (uint32_t)((mptcp_like_alpha *
+ (uint64_t)net->cwnd) >>
SHIFT_MPTCP_MULTI);
if (incr > net->mtu) {
incr = net->mtu;
@@ -1023,7 +1033,7 @@ sctp_cwnd_update_after_timeout(struct sctp_tcb *stcb, struct sctp_nets *net)
srtt = lnet->lastsa;
/* lastsa>>3; we don't need to divide ... */
if (srtt > 0) {
- t_ucwnd_sbw += (uint64_t) lnet->cwnd / (uint64_t) srtt;
+ t_ucwnd_sbw += (uint64_t)lnet->cwnd / (uint64_t)srtt;
}
}
if (t_ssthresh < 1) {
@@ -1033,10 +1043,10 @@ sctp_cwnd_update_after_timeout(struct sctp_tcb *stcb, struct sctp_nets *net)
t_ucwnd_sbw = 1;
}
if (stcb->asoc.sctp_cmt_on_off == SCTP_CMT_RPV1) {
- net->ssthresh = (uint32_t) (((uint64_t) 4 *
- (uint64_t) net->mtu *
- (uint64_t) net->ssthresh) /
- (uint64_t) t_ssthresh);
+ net->ssthresh = (uint32_t)(((uint64_t)4 *
+ (uint64_t)net->mtu *
+ (uint64_t)net->ssthresh) /
+ (uint64_t)t_ssthresh);
} else {
uint64_t cc_delta;
@@ -1045,9 +1055,9 @@ sctp_cwnd_update_after_timeout(struct sctp_tcb *stcb, struct sctp_nets *net)
if (srtt == 0) {
srtt = 1;
}
- cc_delta = t_ucwnd_sbw * (uint64_t) srtt / 2;
+ cc_delta = t_ucwnd_sbw * (uint64_t)srtt / 2;
if (cc_delta < t_cwnd) {
- net->ssthresh = (uint32_t) ((uint64_t) t_cwnd - cc_delta);
+ net->ssthresh = (uint32_t)((uint64_t)t_cwnd - cc_delta);
} else {
net->ssthresh = net->mtu;
}
@@ -1100,8 +1110,10 @@ sctp_cwnd_update_after_ecn_echo_common(struct sctp_tcb *stcb, struct sctp_nets *
sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT);
}
} else {
- /* Further tuning down required over the drastic
- * original cut */
+ /*
+ * Further tuning down required over the drastic
+ * original cut
+ */
net->ssthresh -= (net->mtu * num_pkt_lost);
net->cwnd -= (net->mtu * num_pkt_lost);
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) {
@@ -1115,8 +1127,10 @@ sctp_cwnd_update_after_ecn_echo_common(struct sctp_tcb *stcb, struct sctp_nets *
net->ssthresh = net->cwnd / 2;
if (net->ssthresh < net->mtu) {
net->ssthresh = net->mtu;
- /* here back off the timer as well, to slow
- * us down */
+ /*
+ * here back off the timer as well, to slow
+ * us down
+ */
net->RTO <<= 1;
}
net->cwnd = net->ssthresh;
@@ -1136,7 +1150,7 @@ sctp_cwnd_update_after_ecn_echo_common(struct sctp_tcb *stcb, struct sctp_nets *
static void
sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb,
struct sctp_nets *net, struct sctp_pktdrop_chunk *cp,
- uint32_t * bottle_bw, uint32_t * on_queue)
+ uint32_t *bottle_bw, uint32_t *on_queue)
{
uint32_t bw_avail;
unsigned int incr;
@@ -1154,7 +1168,7 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb,
*on_queue = net->flight_size;
}
/* rtt is measured in micro seconds, bottle_bw in bytes per second */
- bw_avail = (uint32_t) (((uint64_t) (*bottle_bw) * net->rtt) / (uint64_t) 1000000);
+ bw_avail = (uint32_t)(((uint64_t)(*bottle_bw) * net->rtt) / (uint64_t)1000000);
if (bw_avail > *bottle_bw) {
/*
* Cap the growth to no more than the bottle neck. This can
@@ -1333,9 +1347,9 @@ sctp_cwnd_new_rtcc_transmission_begins(struct sctp_tcb *stcb,
if (net->cc_mod.rtcc.lbw) {
/* Clear the old bw.. we went to 0 in-flight */
- vtag = (net->rtt << 32) | (((uint32_t) (stcb->sctp_ep->sctp_lport)) << 16) |
+ vtag = (net->rtt << 32) | (((uint32_t)(stcb->sctp_ep->sctp_lport)) << 16) |
(stcb->rport);
- probepoint = (((uint64_t) net->cwnd) << 32);
+ probepoint = (((uint64_t)net->cwnd) << 32);
/* Probe point 8 */
probepoint |= ((8 << 16) | 0);
SDT_PROBE5(sctp, cwnd, net, rttvar,
@@ -1363,8 +1377,10 @@ sctp_cwnd_new_rtcc_transmission_begins(struct sctp_tcb *stcb,
cwnd_in_mtu = SCTP_BASE_SYSCTL(sctp_initial_cwnd);
if (cwnd_in_mtu == 0) {
- /* Using 0 means that the value of RFC 4960
- * is used. */
+ /*
+ * Using 0 means that the value of RFC 4960
+ * is used.
+ */
cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND));
} else {
/*
@@ -1376,8 +1392,10 @@ sctp_cwnd_new_rtcc_transmission_begins(struct sctp_tcb *stcb,
cwnd = (net->mtu - sizeof(struct sctphdr)) * cwnd_in_mtu;
}
if (net->cwnd > cwnd) {
- /* Only set if we are not a timeout (i.e.
- * down to 1 mtu) */
+ /*
+ * Only set if we are not a timeout (i.e.
+ * down to 1 mtu)
+ */
net->cwnd = cwnd;
}
}
@@ -1392,10 +1410,10 @@ sctp_set_rtcc_initial_cc_param(struct sctp_tcb *stcb,
sctp_set_initial_cc_param(stcb, net);
stcb->asoc.use_precise_time = 1;
- probepoint = (((uint64_t) net->cwnd) << 32);
+ probepoint = (((uint64_t)net->cwnd) << 32);
probepoint |= ((9 << 16) | 0);
vtag = (net->rtt << 32) |
- (((uint32_t) (stcb->sctp_ep->sctp_lport)) << 16) |
+ (((uint32_t)(stcb->sctp_ep->sctp_lport)) << 16) |
(stcb->rport);
SDT_PROBE5(sctp, cwnd, net, rttvar,
vtag,
@@ -1616,7 +1634,7 @@ sctp_hs_cwnd_increase(struct sctp_tcb *stcb, struct sctp_nets *net)
}
}
net->last_hs_used = indx;
- incr = (((int32_t) sctp_cwnd_adjust[indx].increase) << 10);
+ incr = (((int32_t)sctp_cwnd_adjust[indx].increase) << 10);
net->cwnd += incr;
}
sctp_enforce_cwnd_limit(&stcb->asoc, net);
@@ -1642,7 +1660,7 @@ sctp_hs_cwnd_decrease(struct sctp_tcb *stcb, struct sctp_nets *net)
} else {
/* drop by the proper amount */
net->ssthresh = net->cwnd - (int)((net->cwnd / 100) *
- (int32_t) sctp_cwnd_adjust[net->last_hs_used].drop_percent);
+ (int32_t)sctp_cwnd_adjust[net->last_hs_used].drop_percent);
net->cwnd = net->ssthresh;
/* now where are we */
indx = net->last_hs_used;
@@ -1953,7 +1971,7 @@ htcp_beta_update(struct htcp *ca, uint32_t minRTT, uint32_t maxRTT)
return;
}
}
- if (ca->modeswitch && minRTT > (uint32_t) MSEC_TO_TICKS(10) && maxRTT) {
+ if (ca->modeswitch && minRTT > (uint32_t)MSEC_TO_TICKS(10) && maxRTT) {
ca->beta = (minRTT << 7) / maxRTT;
if (ca->beta < BETA_MIN)
ca->beta = BETA_MIN;
@@ -1972,7 +1990,7 @@ htcp_alpha_update(struct htcp *ca)
uint32_t factor = 1;
uint32_t diff = htcp_cong_time(ca);
- if (diff > (uint32_t) hz) {
+ if (diff > (uint32_t)hz) {
diff -= hz;
factor = 1 + (10 * diff + ((diff / 2) * (diff / 2) / hz)) / hz;
}
@@ -2007,8 +2025,10 @@ htcp_param_update(struct sctp_nets *net)
htcp_beta_update(&net->cc_mod.htcp_ca, minRTT, maxRTT);
htcp_alpha_update(&net->cc_mod.htcp_ca);
- /* add slowly fading memory for maxRTT to accommodate routing
- * changes etc */
+ /*
+ * add slowly fading memory for maxRTT to accommodate routing
+ * changes etc
+ */
if (minRTT > 0 && maxRTT > minRTT)
net->cc_mod.htcp_ca.maxRTT = minRTT + ((maxRTT - minRTT) * 95) / 100;
}
diff --git a/freebsd/sys/netinet/sctp_crc32.c b/freebsd/sys/netinet/sctp_crc32.c
index 9130feb2..99aebe48 100644
--- a/freebsd/sys/netinet/sctp_crc32.c
+++ b/freebsd/sys/netinet/sctp_crc32.c
@@ -92,7 +92,7 @@ sctp_calculate_cksum(struct mbuf *m, uint32_t offset)
at = m;
/* find the correct mbuf and offset into mbuf */
- while ((at != NULL) && (offset > (uint32_t) SCTP_BUF_LEN(at))) {
+ while ((at != NULL) && (offset > (uint32_t)SCTP_BUF_LEN(at))) {
offset -= SCTP_BUF_LEN(at); /* update remaining offset
* left */
at = SCTP_BUF_NEXT(at);
@@ -105,7 +105,7 @@ sctp_calculate_cksum(struct mbuf *m, uint32_t offset)
}
if (offset) {
/* we only offset once into the first mbuf */
- if (offset < (uint32_t) SCTP_BUF_LEN(at))
+ if (offset < (uint32_t)SCTP_BUF_LEN(at))
offset = 0;
else
offset -= SCTP_BUF_LEN(at);
@@ -133,9 +133,9 @@ sctp_delayed_cksum(struct mbuf *m, uint32_t offset)
SCTP_STAT_INCR(sctps_sendswcrc);
offset += offsetof(struct sctphdr, checksum);
- if (offset + sizeof(uint32_t) > (uint32_t) (m->m_len)) {
+ if (offset + sizeof(uint32_t) > (uint32_t)(m->m_len)) {
SCTP_PRINTF("sctp_delayed_cksum(): m->len: %d, off: %d.\n",
- (uint32_t) m->m_len, offset);
+ (uint32_t)m->m_len, offset);
/*
* XXX this shouldn't happen, but if it does, the correct
* behavior may be to insert the checksum in the appropriate
@@ -143,6 +143,6 @@ sctp_delayed_cksum(struct mbuf *m, uint32_t offset)
*/
return;
}
- *(uint32_t *) (m->m_data + offset) = checksum;
+ *(uint32_t *)(m->m_data + offset) = checksum;
#endif
}
diff --git a/freebsd/sys/netinet/sctp_indata.c b/freebsd/sys/netinet/sctp_indata.c
index d9449a66..57f13a13 100644
--- a/freebsd/sys/netinet/sctp_indata.c
+++ b/freebsd/sys/netinet/sctp_indata.c
@@ -98,14 +98,14 @@ sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc)
return (calc);
}
/* get actual space */
- calc = (uint32_t) sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv);
+ calc = (uint32_t)sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv);
/*
* take out what has NOT been put on socket queue and we yet hold
* for putting up.
*/
- calc = sctp_sbspace_sub(calc, (uint32_t) (asoc->size_on_reasm_queue +
+ calc = sctp_sbspace_sub(calc, (uint32_t)(asoc->size_on_reasm_queue +
asoc->cnt_on_reasm_queue * MSIZE));
- calc = sctp_sbspace_sub(calc, (uint32_t) (asoc->size_on_all_streams +
+ calc = sctp_sbspace_sub(calc, (uint32_t)(asoc->size_on_all_streams +
asoc->cnt_on_all_streams * MSIZE));
if (calc == 0) {
/* out of space */
@@ -335,16 +335,18 @@ sctp_place_control_in_stream(struct sctp_stream_in *strm,
{
struct sctp_queued_to_read *at;
struct sctp_readhead *q;
- uint8_t bits, unordered;
+ uint8_t flags, unordered;
- bits = (control->sinfo_flags >> 8);
- unordered = bits & SCTP_DATA_UNORDERED;
+ flags = (control->sinfo_flags >> 8);
+ unordered = flags & SCTP_DATA_UNORDERED;
if (unordered) {
q = &strm->uno_inqueue;
if (asoc->idata_supported == 0) {
if (!TAILQ_EMPTY(q)) {
- /* Only one stream can be here in old style
- * -- abort */
+ /*
+ * Only one stream can be here in old style
+ * -- abort
+ */
return (-1);
}
TAILQ_INSERT_TAIL(q, control, next_instrm);
@@ -354,8 +356,10 @@ sctp_place_control_in_stream(struct sctp_stream_in *strm,
} else {
q = &strm->inqueue;
}
- if ((bits & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
- control->end_added = control->last_frag_seen = control->first_frag_seen = 1;
+ if ((flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
+ control->end_added = 1;
+ control->first_frag_seen = 1;
+ control->last_frag_seen = 1;
}
if (TAILQ_EMPTY(q)) {
/* Empty queue */
@@ -396,8 +400,7 @@ sctp_place_control_in_stream(struct sctp_stream_in *strm,
sctp_log_strm_del(control, at,
SCTP_STR_LOG_FROM_INSERT_TL);
}
- TAILQ_INSERT_AFTER(q,
- at, control, next_instrm);
+ TAILQ_INSERT_AFTER(q, at, control, next_instrm);
if (unordered) {
control->on_strm_q = SCTP_ON_UNORDERED;
} else {
@@ -436,7 +439,7 @@ sctp_abort_in_reasm(struct sctp_tcb *stcb,
chk->rec.data.tsn,
chk->rec.data.sid,
chk->rec.data.fsn,
- (uint16_t) chk->rec.data.mid);
+ (uint16_t)chk->rec.data.mid);
}
oper = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
sctp_m_freem(chk->data);
@@ -473,7 +476,6 @@ sctp_clean_up_control(struct sctp_tcb *stcb, struct sctp_queued_to_read *control
*/
static void
sctp_queue_data_to_stream(struct sctp_tcb *stcb,
- struct sctp_stream_in *strm,
struct sctp_association *asoc,
struct sctp_queued_to_read *control, int *abort_flag, int *need_reasm)
{
@@ -499,16 +501,17 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
int queue_needed;
uint32_t nxt_todel;
struct mbuf *op_err;
+ struct sctp_stream_in *strm;
char msg[SCTP_DIAG_INFO_LEN];
+ strm = &asoc->strmin[control->sinfo_stream];
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_STR_LOGGING_ENABLE) {
sctp_log_strm_del(control, NULL, SCTP_STR_LOG_FROM_INTO_STRD);
}
if (SCTP_MID_GT((asoc->idata_supported), strm->last_mid_delivered, control->mid)) {
/* The incoming sseq is behind where we last delivered? */
SCTPDBG(SCTP_DEBUG_INDATA1, "Duplicate S-SEQ: %u delivered: %u from peer, Abort association\n",
- control->mid, strm->last_mid_delivered);
-protocol_error:
+ strm->last_mid_delivered, control->mid);
/*
* throw it in the stream so it gets cleaned up in
* association destruction
@@ -520,10 +523,10 @@ protocol_error:
control->sinfo_stream, control->mid);
} else {
snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
- (uint16_t) strm->last_mid_delivered,
+ (uint16_t)strm->last_mid_delivered,
control->sinfo_tsn,
control->sinfo_stream,
- (uint16_t) control->mid);
+ (uint16_t)control->mid);
}
op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_2;
@@ -532,9 +535,6 @@ protocol_error:
return;
}
- if ((SCTP_TSN_GE(asoc->cumulative_tsn, control->sinfo_tsn)) && (asoc->idata_supported == 0)) {
- goto protocol_error;
- }
queue_needed = 1;
asoc->size_on_all_streams += control->length;
sctp_ucount_incr(asoc->cnt_on_all_streams);
@@ -836,8 +836,10 @@ restart:
TAILQ_INSERT_TAIL(&nc->reasm, tchk, sctp_next);
tchk = TAILQ_FIRST(&control->reasm);
}
- /* Now lets add it to the queue
- * after removing control */
+ /*
+ * Now lets add it to the queue
+ * after removing control
+ */
TAILQ_INSERT_TAIL(&strm->uno_inqueue, nc, next_instrm);
nc->on_strm_q = SCTP_ON_UNORDERED;
if (control->on_strm_q) {
@@ -861,8 +863,10 @@ restart:
}
sctp_wakeup_the_read_socket(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
if ((nc->first_frag_seen) && !TAILQ_EMPTY(&nc->reasm)) {
- /* Switch to the new guy and
- * continue */
+ /*
+ * Switch to the new guy and
+ * continue
+ */
control = nc;
goto restart;
} else {
@@ -922,8 +926,10 @@ sctp_inject_old_unordered_data(struct sctp_tcb *stcb,
uint32_t tmp;
if (SCTP_TSN_GT(chk->rec.data.fsn, control->fsn_included)) {
- /* Easy way the start of a new guy beyond
- * the lowest */
+ /*
+ * Easy way the start of a new guy beyond
+ * the lowest
+ */
goto place_chunk;
}
if ((chk->rec.data.fsn == control->fsn_included) ||
@@ -974,7 +980,8 @@ sctp_inject_old_unordered_data(struct sctp_tcb *stcb,
goto place_chunk;
}
control->first_frag_seen = 1;
- control->top_fsn = control->fsn_included = chk->rec.data.fsn;
+ control->fsn_included = chk->rec.data.fsn;
+ control->top_fsn = chk->rec.data.fsn;
control->sinfo_tsn = chk->rec.data.tsn;
control->sinfo_ppid = chk->rec.data.ppid;
control->data = chk->data;
@@ -1041,7 +1048,7 @@ sctp_deliver_reasm_check(struct sctp_tcb *stcb, struct sctp_association *asoc,
}
control = TAILQ_FIRST(&strm->uno_inqueue);
- if ((control) &&
+ if ((control != NULL) &&
(asoc->idata_supported == 0)) {
/* Special handling needed for "old" data format */
if (sctp_handle_old_unordered_data(stcb, asoc, strm, control, pd_point, inp_read_lock_held)) {
@@ -1138,8 +1145,10 @@ done_un:
}
}
if (strm->pd_api_started) {
- /* Can't add more must have gotten an un-ordered above being
- * partially delivered. */
+ /*
+ * Can't add more must have gotten an un-ordered above being
+ * partially delivered.
+ */
return (0);
}
deliver_more:
@@ -1171,15 +1180,21 @@ deliver_more:
ret++;
}
if (((control->sinfo_flags >> 8) & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
- /* A singleton now slipping through - mark
- * it non-revokable too */
+ /*
+ * A singleton now slipping through - mark
+ * it non-revokable too
+ */
sctp_mark_non_revokable(asoc, control->sinfo_tsn);
} else if (control->end_added == 0) {
- /* Check if we can defer adding until its
- * all there */
+ /*
+ * Check if we can defer adding until its
+ * all there
+ */
if ((control->length < pd_point) || (strm->pd_api_started)) {
- /* Don't need it or cannot add more
- * (one being delivered that way) */
+ /*
+ * Don't need it or cannot add more
+ * (one being delivered that way)
+ */
goto out;
}
}
@@ -1238,6 +1253,8 @@ sctp_add_chk_to_control(struct sctp_queued_to_read *control,
chk->data = NULL;
if (chk->rec.data.rcv_flags & SCTP_DATA_FIRST_FRAG) {
control->first_frag_seen = 1;
+ control->sinfo_tsn = chk->rec.data.tsn;
+ control->sinfo_ppid = chk->rec.data.ppid;
}
if (chk->rec.data.rcv_flags & SCTP_DATA_LAST_FRAG) {
/* Its complete */
@@ -1278,7 +1295,6 @@ sctp_add_chk_to_control(struct sctp_queued_to_read *control,
*/
static void
sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
- struct sctp_stream_in *strm,
struct sctp_queued_to_read *control,
struct sctp_tmit_chunk *chk,
int created_control,
@@ -1286,8 +1302,10 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
{
uint32_t next_fsn;
struct sctp_tmit_chunk *at, *nat;
+ struct sctp_stream_in *strm;
int do_wakeup, unordered;
+ strm = &asoc->strmin[control->sinfo_stream];
/*
* For old un-ordered data chunks.
*/
@@ -1349,6 +1367,8 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
return;
}
control->first_frag_seen = 1;
+ control->sinfo_ppid = chk->rec.data.ppid;
+ control->sinfo_tsn = chk->rec.data.tsn;
control->fsn_included = chk->rec.data.fsn;
control->data = chk->data;
sctp_mark_non_revokable(asoc, chk->rec.data.tsn);
@@ -1381,8 +1401,10 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
* we know the first FSN (which is the TSN).
*/
if (SCTP_TSN_GE(control->fsn_included, chk->rec.data.fsn)) {
- /* We have already delivered up to
- * this so its a dup */
+ /*
+ * We have already delivered up to
+ * this so its a dup
+ */
sctp_abort_in_reasm(stcb, control, chk,
abort_flag,
SCTP_FROM_SCTP_INDATA + SCTP_LOC_9);
@@ -1409,8 +1431,10 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
*/
if (SCTP_TSN_GE(control->fsn_included, chk->rec.data.fsn)) {
- /* We have already delivered up to
- * this so its a dup */
+ /*
+ * We have already delivered up to
+ * this so its a dup
+ */
SCTPDBG(SCTP_DEBUG_XXX,
"New fsn: %u is already seen in included_fsn: %u -- abort\n",
chk->rec.data.fsn, control->fsn_included);
@@ -1420,8 +1444,10 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
return;
}
}
- /* validate not beyond top FSN if we have seen last
- * one */
+ /*
+ * validate not beyond top FSN if we have seen last
+ * one
+ */
if (SCTP_TSN_GT(chk->rec.data.fsn, control->top_fsn)) {
SCTPDBG(SCTP_DEBUG_XXX,
"New fsn: %u is beyond or at top_fsn: %u -- abort\n",
@@ -1455,8 +1481,10 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
inserted = 1;
break;
} else if (at->rec.data.fsn == chk->rec.data.fsn) {
- /* Gak, He sent me a duplicate str seq
- * number */
+ /*
+ * Gak, He sent me a duplicate str seq
+ * number
+ */
/*
* foo bar, I guess I will just free this
* new guy, should we abort too? FIX ME
@@ -1561,13 +1589,11 @@ sctp_find_reasm_entry(struct sctp_stream_in *strm, uint32_t mid, int ordered, in
static int
sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
struct mbuf **m, int offset, int chk_length,
- struct sctp_nets *net, uint32_t * high_tsn, int *abort_flag,
- int *break_flag, int last_chunk, uint8_t chtype)
+ struct sctp_nets *net, uint32_t *high_tsn, int *abort_flag,
+ int *break_flag, int last_chunk, uint8_t chk_type)
{
/* Process a data chunk */
/* struct sctp_tmit_chunk *chk; */
- struct sctp_data_chunk *ch;
- struct sctp_idata_chunk *nch, chunk_buf;
struct sctp_tmit_chunk *chk;
uint32_t tsn, fsn, gap, mid;
struct mbuf *dmbuf;
@@ -1578,58 +1604,63 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
char msg[SCTP_DIAG_INFO_LEN];
struct sctp_queued_to_read *control = NULL;
uint32_t ppid;
- uint8_t chunk_flags;
+ uint8_t chk_flags;
struct sctp_stream_reset_list *liste;
- struct sctp_stream_in *strm;
int ordered;
size_t clen;
int created_control = 0;
- chk = NULL;
- if (chtype == SCTP_IDATA) {
- nch = (struct sctp_idata_chunk *)sctp_m_getptr(*m, offset,
- sizeof(struct sctp_idata_chunk), (uint8_t *) & chunk_buf);
- ch = (struct sctp_data_chunk *)nch;
+ if (chk_type == SCTP_IDATA) {
+ struct sctp_idata_chunk *chunk, chunk_buf;
+
+ chunk = (struct sctp_idata_chunk *)sctp_m_getptr(*m, offset,
+ sizeof(struct sctp_idata_chunk), (uint8_t *)&chunk_buf);
+ chk_flags = chunk->ch.chunk_flags;
clen = sizeof(struct sctp_idata_chunk);
- tsn = ntohl(ch->dp.tsn);
- mid = ntohl(nch->dp.mid);
- ppid = nch->dp.ppid_fsn.ppid;
- if (ch->ch.chunk_flags & SCTP_DATA_FIRST_FRAG)
+ tsn = ntohl(chunk->dp.tsn);
+ sid = ntohs(chunk->dp.sid);
+ mid = ntohl(chunk->dp.mid);
+ if (chk_flags & SCTP_DATA_FIRST_FRAG) {
fsn = 0;
- else
- fsn = ntohl(nch->dp.ppid_fsn.fsn);
+ ppid = chunk->dp.ppid_fsn.ppid;
+ } else {
+ fsn = ntohl(chunk->dp.ppid_fsn.fsn);
+ ppid = 0xffffffff; /* Use as an invalid value. */
+ }
} else {
- ch = (struct sctp_data_chunk *)sctp_m_getptr(*m, offset,
- sizeof(struct sctp_data_chunk), (uint8_t *) & chunk_buf);
- tsn = ntohl(ch->dp.tsn);
- ppid = ch->dp.ppid;
+ struct sctp_data_chunk *chunk, chunk_buf;
+
+ chunk = (struct sctp_data_chunk *)sctp_m_getptr(*m, offset,
+ sizeof(struct sctp_data_chunk), (uint8_t *)&chunk_buf);
+ chk_flags = chunk->ch.chunk_flags;
clen = sizeof(struct sctp_data_chunk);
+ tsn = ntohl(chunk->dp.tsn);
+ sid = ntohs(chunk->dp.sid);
+ mid = (uint32_t)(ntohs(chunk->dp.ssn));
fsn = tsn;
- mid = (uint32_t) (ntohs(ch->dp.ssn));
- nch = NULL;
+ ppid = chunk->dp.ppid;
}
- chunk_flags = ch->ch.chunk_flags;
if ((size_t)chk_length == clen) {
/*
* Need to send an abort since we had a empty data chunk.
*/
- op_err = sctp_generate_no_user_data_cause(ch->dp.tsn);
+ op_err = sctp_generate_no_user_data_cause(tsn);
stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_14;
sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED);
*abort_flag = 1;
return (0);
}
- if ((chunk_flags & SCTP_DATA_SACK_IMMEDIATELY) == SCTP_DATA_SACK_IMMEDIATELY) {
+ if ((chk_flags & SCTP_DATA_SACK_IMMEDIATELY) == SCTP_DATA_SACK_IMMEDIATELY) {
asoc->send_sack = 1;
}
- ordered = ((chunk_flags & SCTP_DATA_UNORDERED) == 0);
+ ordered = ((chk_flags & SCTP_DATA_UNORDERED) == 0);
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) {
sctp_log_map(tsn, asoc->cumulative_tsn, asoc->highest_tsn_inside_map, SCTP_MAP_TSN_ENTERS);
}
if (stcb == NULL) {
return (0);
}
- SCTP_LTRACE_CHK(stcb->sctp_ep, stcb, ch->ch.chunk_type, tsn);
+ SCTP_LTRACE_CHK(stcb->sctp_ep, stcb, chk_type, tsn);
if (SCTP_TSN_GE(asoc->cumulative_tsn, tsn)) {
/* It is a duplicate */
SCTP_STAT_INCR(sctps_recvdupdata);
@@ -1647,7 +1678,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
/* Can't hold the bit in the mapping at max array, toss it */
return (0);
}
- if (gap >= (uint32_t) (asoc->mapping_array_size << 3)) {
+ if (gap >= (uint32_t)(asoc->mapping_array_size << 3)) {
SCTP_TCB_LOCK_ASSERT(stcb);
if (sctp_expand_mapping_array(asoc, gap)) {
/* Can't expand, drop it */
@@ -1692,8 +1723,6 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
*/
/* Is the stream valid? */
- sid = ntohs(ch->dp.sid);
-
if (sid >= asoc->streamincnt) {
struct sctp_error_invalid_stream *cause;
@@ -1711,7 +1740,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
SCTP_BUF_LEN(op_err) = sizeof(struct sctp_error_invalid_stream);
cause->cause.code = htons(SCTP_CAUSE_INVALID_STREAM);
cause->cause.length = htons(sizeof(struct sctp_error_invalid_stream));
- cause->stream_id = ch->dp.sid;
+ cause->stream_id = htons(sid);
cause->reserved = htons(0);
sctp_queue_op_err(stcb, op_err);
}
@@ -1727,13 +1756,12 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
}
return (0);
}
- strm = &asoc->strmin[sid];
/*
* If its a fragmented message, lets see if we can find the control
* on the reassembly queues.
*/
- if ((chtype == SCTP_IDATA) &&
- ((chunk_flags & SCTP_DATA_FIRST_FRAG) == 0) &&
+ if ((chk_type == SCTP_IDATA) &&
+ ((chk_flags & SCTP_DATA_FIRST_FRAG) == 0) &&
(fsn == 0)) {
/*
* The first *must* be fsn 0, and other (middle/end) pieces
@@ -1741,13 +1769,13 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
* wrap around. Ignore is for now.
*/
snprintf(msg, sizeof(msg), "FSN zero for MID=%8.8x, but flags=%2.2x",
- mid, chunk_flags);
+ mid, chk_flags);
goto err_out;
}
- control = sctp_find_reasm_entry(strm, mid, ordered, asoc->idata_supported);
+ control = sctp_find_reasm_entry(&asoc->strmin[sid], mid, ordered, asoc->idata_supported);
SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags:0x%x look for control on queues %p\n",
- chunk_flags, control);
- if ((chunk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) {
+ chk_flags, control);
+ if ((chk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) {
/* See if we can find the re-assembly entity */
if (control != NULL) {
/* We found something, does it belong? */
@@ -1761,15 +1789,19 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
return (0);
}
if (ordered && ((control->sinfo_flags >> 8) & SCTP_DATA_UNORDERED)) {
- /* We can't have a switched order with an
- * unordered chunk */
+ /*
+ * We can't have a switched order with an
+ * unordered chunk
+ */
snprintf(msg, sizeof(msg), "All fragments of a user message must be ordered or unordered (TSN=%8.8x)",
tsn);
goto err_out;
}
if (!ordered && (((control->sinfo_flags >> 8) & SCTP_DATA_UNORDERED) == 0)) {
- /* We can't have a switched unordered with a
- * ordered chunk */
+ /*
+ * We can't have a switched unordered with a
+ * ordered chunk
+ */
snprintf(msg, sizeof(msg), "All fragments of a user message must be ordered or unordered (TSN=%8.8x)",
tsn);
goto err_out;
@@ -1784,7 +1816,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
if (control != NULL) {
if (ordered || asoc->idata_supported) {
SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags: 0x%x dup detected on MID: %u\n",
- chunk_flags, mid);
+ chk_flags, mid);
snprintf(msg, sizeof(msg), "Duplicate MID=%8.8x detected.", mid);
goto err_out;
} else {
@@ -1830,7 +1862,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
#endif
}
/* now is it in the mapping array of what we have accepted? */
- if (nch == NULL) {
+ if (chk_type == SCTP_DATA) {
if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_map) &&
SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) {
/* Nope not in the valid range dump it */
@@ -1878,9 +1910,9 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
* way our stream sequence numbers could have wrapped. We of course
* only validate the FIRST fragment so the bit must be set.
*/
- if ((chunk_flags & SCTP_DATA_FIRST_FRAG) &&
+ if ((chk_flags & SCTP_DATA_FIRST_FRAG) &&
(TAILQ_EMPTY(&asoc->resetHead)) &&
- (chunk_flags & SCTP_DATA_UNORDERED) == 0 &&
+ (chk_flags & SCTP_DATA_UNORDERED) == 0 &&
SCTP_MID_GE(asoc->idata_supported, asoc->strmin[sid].last_mid_delivered, mid)) {
/* The incoming sseq is behind where we last delivered? */
SCTPDBG(SCTP_DEBUG_INDATA1, "EVIL/Broken-Dup S-SEQ: %u delivered: %u from peer, Abort!\n",
@@ -1894,10 +1926,10 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
mid);
} else {
snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
- (uint16_t) asoc->strmin[sid].last_mid_delivered,
+ (uint16_t)asoc->strmin[sid].last_mid_delivered,
tsn,
sid,
- (uint16_t) mid);
+ (uint16_t)mid);
}
op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_16;
@@ -1905,17 +1937,13 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
*abort_flag = 1;
return (0);
}
- /************************************
- * From here down we may find ch-> invalid
- * so its a good idea NOT to use it.
- *************************************/
- if (nch) {
+ if (chk_type == SCTP_IDATA) {
the_len = (chk_length - sizeof(struct sctp_idata_chunk));
} else {
the_len = (chk_length - sizeof(struct sctp_data_chunk));
}
if (last_chunk == 0) {
- if (nch) {
+ if (chk_type == SCTP_IDATA) {
dmbuf = SCTP_M_COPYM(*m,
(offset + sizeof(struct sctp_idata_chunk)),
the_len, M_NOWAIT);
@@ -1935,7 +1963,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
dmbuf = *m;
/* lop off the top part */
- if (nch) {
+ if (chk_type == SCTP_IDATA) {
m_adj(dmbuf, (offset + sizeof(struct sctp_idata_chunk)));
} else {
m_adj(dmbuf, (offset + sizeof(struct sctp_data_chunk)));
@@ -1964,7 +1992,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
return (0);
}
/*
- * Now no matter what we need a control, get one if we don't have
+ * Now no matter what, we need a control, get one if we don't have
* one (we may have gotten it above when we found the message was
* fragmented
*/
@@ -1973,23 +2001,26 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
sctp_build_readq_entry_mac(control, stcb, asoc->context, net, tsn,
ppid,
sid,
- chunk_flags,
+ chk_flags,
NULL, fsn, mid);
if (control == NULL) {
SCTP_STAT_INCR(sctps_nomem);
return (0);
}
- if ((chunk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
+ if ((chk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
control->data = dmbuf;
control->tail_mbuf = NULL;
- control->end_added = control->last_frag_seen = control->first_frag_seen = 1;
- control->top_fsn = control->fsn_included = fsn;
+ control->end_added = 1;
+ control->last_frag_seen = 1;
+ control->first_frag_seen = 1;
+ control->fsn_included = fsn;
+ control->top_fsn = fsn;
}
created_control = 1;
}
SCTPDBG(SCTP_DEBUG_XXX, "chunk_flags: 0x%x ordered: %d MID: %u control: %p\n",
- chunk_flags, ordered, mid, control);
- if ((chunk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG &&
+ chk_flags, ordered, mid, control);
+ if ((chk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG &&
TAILQ_EMPTY(&asoc->resetHead) &&
((ordered == 0) ||
(SCTP_MID_EQ(asoc->idata_supported, asoc->strmin[sid].last_mid_delivered + 1, mid) &&
@@ -2013,9 +2044,9 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
control, &stcb->sctp_socket->so_rcv,
1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED);
- if ((chunk_flags & SCTP_DATA_UNORDERED) == 0) {
+ if ((chk_flags & SCTP_DATA_UNORDERED) == 0) {
/* for ordered, bump what we delivered */
- strm->last_mid_delivered++;
+ asoc->strmin[sid].last_mid_delivered++;
}
SCTP_STAT_INCR(sctps_recvexpress);
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_STR_LOGGING_ENABLE) {
@@ -2026,7 +2057,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
goto finish_express_del;
}
/* Now will we need a chunk too? */
- if ((chunk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) {
+ if ((chk_flags & SCTP_DATA_NOT_FRAG) != SCTP_DATA_NOT_FRAG) {
sctp_alloc_a_chunk(stcb, chk);
if (chk == NULL) {
/* No memory so we drop the chunk */
@@ -2045,7 +2076,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
chk->rec.data.ppid = ppid;
chk->rec.data.context = stcb->asoc.context;
chk->rec.data.doing_fast_retransmit = 0;
- chk->rec.data.rcv_flags = chunk_flags;
+ chk->rec.data.rcv_flags = chk_flags;
chk->asoc = asoc;
chk->send_size = the_len;
chk->whoTo = net;
@@ -2068,7 +2099,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
}
}
/* Now is it complete (i.e. not fragmented)? */
- if ((chunk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
+ if ((chk_flags & SCTP_DATA_NOT_FRAG) == SCTP_DATA_NOT_FRAG) {
/*
* Special check for when streams are resetting. We could be
* more smart about this and check the actual stream to see
@@ -2112,7 +2143,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
}
goto finish_express_del;
}
- if (chunk_flags & SCTP_DATA_UNORDERED) {
+ if (chk_flags & SCTP_DATA_UNORDERED) {
/* queue directly into socket buffer */
SCTPDBG(SCTP_DEBUG_XXX, "Unordered data to be read control: %p MID: %u\n",
control, mid);
@@ -2125,7 +2156,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
} else {
SCTPDBG(SCTP_DEBUG_XXX, "Queue control: %p for reordering MID: %u\n", control,
mid);
- sctp_queue_data_to_stream(stcb, strm, asoc, control, abort_flag, &need_reasm_check);
+ sctp_queue_data_to_stream(stcb, asoc, control, abort_flag, &need_reasm_check);
if (*abort_flag) {
if (last_chunk) {
*m = NULL;
@@ -2140,7 +2171,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
SCTPDBG(SCTP_DEBUG_XXX,
"Queue data to stream for reasm control: %p MID: %u\n",
control, mid);
- sctp_queue_data_for_reasm(stcb, asoc, strm, control, chk, created_control, abort_flag, tsn);
+ sctp_queue_data_for_reasm(stcb, asoc, control, chk, created_control, abort_flag, tsn);
if (*abort_flag) {
/*
* the assoc is now gone and chk was put onto the reasm
@@ -2174,6 +2205,10 @@ finish_express_del:
sctp_log_map(asoc->mapping_array_base_tsn, asoc->cumulative_tsn,
asoc->highest_tsn_inside_map, SCTP_MAP_PREPARE_SLIDE);
}
+ if (need_reasm_check) {
+ (void)sctp_deliver_reasm_check(stcb, asoc, &asoc->strmin[sid], SCTP_READ_LOCK_NOT_HELD);
+ need_reasm_check = 0;
+ }
/* check the special flag for stream resets */
if (((liste = TAILQ_FIRST(&asoc->resetHead)) != NULL) &&
SCTP_TSN_GE(asoc->cumulative_tsn, liste->tsn)) {
@@ -2195,10 +2230,14 @@ finish_express_del:
/* All can be removed */
TAILQ_FOREACH_SAFE(ctl, &asoc->pending_reply_queue, next, nctl) {
TAILQ_REMOVE(&asoc->pending_reply_queue, ctl, next);
- sctp_queue_data_to_stream(stcb, strm, asoc, ctl, abort_flag, &need_reasm_check);
+ sctp_queue_data_to_stream(stcb, asoc, ctl, abort_flag, &need_reasm_check);
if (*abort_flag) {
return (0);
}
+ if (need_reasm_check) {
+ (void)sctp_deliver_reasm_check(stcb, asoc, &asoc->strmin[ctl->sinfo_stream], SCTP_READ_LOCK_NOT_HELD);
+ need_reasm_check = 0;
+ }
}
} else {
TAILQ_FOREACH_SAFE(ctl, &asoc->pending_reply_queue, next, nctl) {
@@ -2211,22 +2250,16 @@ finish_express_del:
* ctl->sinfo_tsn > liste->tsn
*/
TAILQ_REMOVE(&asoc->pending_reply_queue, ctl, next);
- sctp_queue_data_to_stream(stcb, strm, asoc, ctl, abort_flag, &need_reasm_check);
+ sctp_queue_data_to_stream(stcb, asoc, ctl, abort_flag, &need_reasm_check);
if (*abort_flag) {
return (0);
}
+ if (need_reasm_check) {
+ (void)sctp_deliver_reasm_check(stcb, asoc, &asoc->strmin[ctl->sinfo_stream], SCTP_READ_LOCK_NOT_HELD);
+ need_reasm_check = 0;
+ }
}
}
- /*
- * Now service re-assembly to pick up anything that has been
- * held on reassembly queue?
- */
- (void)sctp_deliver_reasm_check(stcb, asoc, strm, SCTP_READ_LOCK_NOT_HELD);
- need_reasm_check = 0;
- }
- if (need_reasm_check) {
- /* Another one waits ? */
- (void)sctp_deliver_reasm_check(stcb, asoc, strm, SCTP_READ_LOCK_NOT_HELD);
}
return (1);
}
@@ -2389,8 +2422,8 @@ sctp_slide_mapping_arrays(struct sctp_tcb *stcb)
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) {
sctp_log_map(old_base, old_cumack, old_highest,
SCTP_MAP_PREPARE_SLIDE);
- sctp_log_map((uint32_t) slide_from, (uint32_t) slide_end,
- (uint32_t) lgap, SCTP_MAP_SLIDE_FROM);
+ sctp_log_map((uint32_t)slide_from, (uint32_t)slide_end,
+ (uint32_t)lgap, SCTP_MAP_SLIDE_FROM);
}
if (distance + slide_from > asoc->mapping_array_size ||
distance < 0) {
@@ -2402,8 +2435,8 @@ sctp_slide_mapping_arrays(struct sctp_tcb *stcb)
*/
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) {
- sctp_log_map((uint32_t) distance, (uint32_t) slide_from,
- (uint32_t) asoc->mapping_array_size,
+ sctp_log_map((uint32_t)distance, (uint32_t)slide_from,
+ (uint32_t)asoc->mapping_array_size,
SCTP_MAP_SLIDE_NONE);
}
} else {
@@ -2439,13 +2472,17 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap)
{
struct sctp_association *asoc;
uint32_t highest_tsn;
+ int is_a_gap;
+ sctp_slide_mapping_arrays(stcb);
asoc = &stcb->asoc;
if (SCTP_TSN_GT(asoc->highest_tsn_inside_nr_map, asoc->highest_tsn_inside_map)) {
highest_tsn = asoc->highest_tsn_inside_nr_map;
} else {
highest_tsn = asoc->highest_tsn_inside_map;
}
+ /* Is there a gap now? */
+ is_a_gap = SCTP_TSN_GT(highest_tsn, stcb->asoc.cumulative_tsn);
/*
* Now we need to see if we need to queue a sack or just start the
@@ -2464,13 +2501,10 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap)
}
sctp_send_shutdown(stcb,
((stcb->asoc.alternate) ? stcb->asoc.alternate : stcb->asoc.primary_destination));
- sctp_send_sack(stcb, SCTP_SO_NOT_LOCKED);
+ if (is_a_gap) {
+ sctp_send_sack(stcb, SCTP_SO_NOT_LOCKED);
+ }
} else {
- int is_a_gap;
-
- /* is there a gap now ? */
- is_a_gap = SCTP_TSN_GT(highest_tsn, stcb->asoc.cumulative_tsn);
-
/*
* CMT DAC algorithm: increase number of packets received
* since last ack
@@ -2484,7 +2518,8 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap)
(stcb->asoc.numduptsns) || /* we have dup's */
(is_a_gap) || /* is still a gap */
(stcb->asoc.delayed_ack == 0) || /* Delayed sack disabled */
- (stcb->asoc.data_pkts_seen >= stcb->asoc.sack_freq) /* hit limit of pkts */ ) {
+ (stcb->asoc.data_pkts_seen >= stcb->asoc.sack_freq) /* hit limit of pkts */
+ ) {
if ((stcb->asoc.sctp_cmt_on_off > 0) &&
(SCTP_BASE_SYSCTL(sctp_cmt_use_dac)) &&
@@ -2527,7 +2562,7 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap)
int
sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length,
struct sctp_inpcb *inp, struct sctp_tcb *stcb,
- struct sctp_nets *net, uint32_t * high_tsn)
+ struct sctp_nets *net, uint32_t *high_tsn)
{
struct sctp_chunkhdr *ch, chunk_buf;
struct sctp_association *asoc;
@@ -2588,7 +2623,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length,
}
/* get pointer to the first chunk header */
ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset,
- sizeof(struct sctp_chunkhdr), (uint8_t *) & chunk_buf);
+ sizeof(struct sctp_chunkhdr), (uint8_t *)&chunk_buf);
if (ch == NULL) {
return (1);
}
@@ -2733,7 +2768,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length,
if (op_err != NULL) {
cause = mtod(op_err, struct sctp_gen_error_cause *);
cause->code = htons(SCTP_CAUSE_UNRECOG_CHUNK);
- cause->length = htons((uint16_t) (chk_length + sizeof(struct sctp_gen_error_cause)));
+ cause->length = htons((uint16_t)(chk_length + sizeof(struct sctp_gen_error_cause)));
SCTP_BUF_LEN(op_err) = sizeof(struct sctp_gen_error_cause);
SCTP_BUF_NEXT(op_err) = SCTP_M_COPYM(m, *offset, chk_length, M_NOWAIT);
if (SCTP_BUF_NEXT(op_err) != NULL) {
@@ -2747,7 +2782,8 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length,
/* discard the rest of this packet */
stop_proc = 1;
} /* else skip this bad chunk and
- * continue... */ break;
+ * continue... */
+ break;
} /* switch of chunk type */
}
*offset += SCTP_SIZE32(chk_length);
@@ -2757,7 +2793,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length,
continue;
}
ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset,
- sizeof(struct sctp_chunkhdr), (uint8_t *) & chunk_buf);
+ sizeof(struct sctp_chunkhdr), (uint8_t *)&chunk_buf);
if (ch == NULL) {
*offset = length;
stop_proc = 1;
@@ -2800,8 +2836,8 @@ static int
sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1, uint32_t last_tsn,
uint16_t frag_strt, uint16_t frag_end, int nr_sacking,
int *num_frs,
- uint32_t * biggest_newly_acked_tsn,
- uint32_t * this_sack_lowest_newack,
+ uint32_t *biggest_newly_acked_tsn,
+ uint32_t *this_sack_lowest_newack,
int *rto_ok)
{
struct sctp_tmit_chunk *tp1;
@@ -2922,7 +2958,7 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1
sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_GAP,
tp1->whoTo->flight_size,
tp1->book_size,
- (uint32_t) (uintptr_t) tp1->whoTo,
+ (uint32_t)(uintptr_t)tp1->whoTo,
tp1->rec.data.tsn);
}
sctp_flight_size_decrease(tp1);
@@ -3004,8 +3040,10 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1
}
tp1->sent = SCTP_DATAGRAM_NR_ACKED;
if (tp1->data) {
- /* sa_ignore
- * NO_NULL_CHK */
+ /*
+ * sa_ignore
+ * NO_NULL_CHK
+ */
sctp_free_bufspace(stcb, &stcb->asoc, tp1, 1);
sctp_m_freem(tp1->data);
tp1->data = NULL;
@@ -3014,7 +3052,8 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1
}
}
break;
- } /* if (tp1->tsn == theTSN) */ if (SCTP_TSN_GT(tp1->rec.data.tsn, theTSN)) {
+ } /* if (tp1->tsn == theTSN) */
+ if (SCTP_TSN_GT(tp1->rec.data.tsn, theTSN)) {
break;
}
tp1 = TAILQ_NEXT(tp1, sctp_next);
@@ -3036,8 +3075,8 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1
static int
sctp_handle_segments(struct mbuf *m, int *offset, struct sctp_tcb *stcb, struct sctp_association *asoc,
- uint32_t last_tsn, uint32_t * biggest_tsn_acked,
- uint32_t * biggest_newly_acked_tsn, uint32_t * this_sack_lowest_newack,
+ uint32_t last_tsn, uint32_t *biggest_tsn_acked,
+ uint32_t *biggest_newly_acked_tsn, uint32_t *this_sack_lowest_newack,
int num_seg, int num_nr_seg, int *rto_ok)
{
struct sctp_gap_ack_block *frag, block;
@@ -3058,7 +3097,7 @@ sctp_handle_segments(struct mbuf *m, int *offset, struct sctp_tcb *stcb, struct
tp1 = TAILQ_FIRST(&asoc->sent_queue);
}
frag = (struct sctp_gap_ack_block *)sctp_m_getptr(m, *offset,
- sizeof(struct sctp_gap_ack_block), (uint8_t *) & block);
+ sizeof(struct sctp_gap_ack_block), (uint8_t *)&block);
*offset += sizeof(block);
if (frag == NULL) {
return (chunk_freed);
@@ -3128,7 +3167,7 @@ sctp_check_for_revoked(struct sctp_tcb *stcb,
sctp_misc_ints(SCTP_FLIGHT_LOG_UP_REVOKE,
tp1->whoTo->flight_size,
tp1->book_size,
- (uint32_t) (uintptr_t) tp1->whoTo,
+ (uint32_t)(uintptr_t)tp1->whoTo,
tp1->rec.data.tsn);
}
sctp_flight_size_increase(tp1);
@@ -3442,7 +3481,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_RSND,
(tp1->whoTo ? (tp1->whoTo->flight_size) : 0),
tp1->book_size,
- (uint32_t) (uintptr_t) tp1->whoTo,
+ (uint32_t)(uintptr_t)tp1->whoTo,
tp1->rec.data.tsn);
}
if (tp1->whoTo) {
@@ -3465,8 +3504,10 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
if ((stcb->asoc.prsctp_supported) &&
(PR_SCTP_RTX_ENABLED(tp1->flags))) {
- /* Has it been retransmitted tv_sec times? -
- * we store the retran count there. */
+ /*
+ * Has it been retransmitted tv_sec times? -
+ * we store the retran count there.
+ */
if (tp1->snd_count > tp1->rec.data.timetodrop.tv_sec) {
/* Yes, so drop it */
if (tp1->data != NULL) {
@@ -3478,8 +3519,10 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
continue;
}
}
- /* SCTP_PRINTF("OK, we are now ready to FR this
- * guy\n"); */
+ /*
+ * SCTP_PRINTF("OK, we are now ready to FR this
+ * guy\n");
+ */
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
sctp_log_fr(tp1->rec.data.tsn, tp1->snd_count,
0, SCTP_FR_MARKED);
@@ -3499,14 +3542,18 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
alt = tp1->whoTo;
/* sa_ignore NO_NULL_CHK */
if (asoc->sctp_cmt_pf > 0) {
- /* JRS 5/18/07 - If CMT PF is on,
+ /*
+ * JRS 5/18/07 - If CMT PF is on,
* use the PF version of
- * find_alt_net() */
+ * find_alt_net()
+ */
alt = sctp_find_alternate_net(stcb, alt, 2);
} else {
- /* JRS 5/18/07 - If only CMT is on,
+ /*
+ * JRS 5/18/07 - If only CMT is on,
* use the CMT version of
- * find_alt_net() */
+ * find_alt_net()
+ */
/* sa_ignore NO_NULL_CHK */
alt = sctp_find_alternate_net(stcb, alt, 1);
}
@@ -3744,7 +3791,7 @@ sctp_window_probe_recovery(struct sctp_tcb *stcb,
sctp_misc_ints(SCTP_FLIGHT_LOG_DWN_WP_FWD,
tp1->whoTo ? tp1->whoTo->flight_size : 0,
tp1->book_size,
- (uint32_t) (uintptr_t) tp1->whoTo,
+ (uint32_t)(uintptr_t)tp1->whoTo,
tp1->rec.data.tsn);
return;
}
@@ -3763,7 +3810,7 @@ sctp_window_probe_recovery(struct sctp_tcb *stcb,
sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_WP,
tp1->whoTo->flight_size,
tp1->book_size,
- (uint32_t) (uintptr_t) tp1->whoTo,
+ (uint32_t)(uintptr_t)tp1->whoTo,
tp1->rec.data.tsn);
}
}
@@ -3802,7 +3849,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
} else if (asoc->last_acked_seq == cumack) {
/* Window update sack */
asoc->peers_rwnd = sctp_sbspace_sub(rwnd,
- (uint32_t) (asoc->total_flight + (asoc->total_flight_count * SCTP_BASE_SYSCTL(sctp_peer_chunk_oh))));
+ (uint32_t)(asoc->total_flight + (asoc->total_flight_count * SCTP_BASE_SYSCTL(sctp_peer_chunk_oh))));
if (asoc->peers_rwnd < stcb->sctp_ep->sctp_ep.sctp_sws_sender) {
/* SWS sender side engages */
asoc->peers_rwnd = 0;
@@ -3879,7 +3926,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_CA,
tp1->whoTo->flight_size,
tp1->book_size,
- (uint32_t) (uintptr_t) tp1->whoTo,
+ (uint32_t)(uintptr_t)tp1->whoTo,
tp1->rec.data.tsn);
}
sctp_flight_size_decrease(tp1);
@@ -4037,8 +4084,10 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
}
if (net == stcb->asoc.primary_destination) {
if (stcb->asoc.alternate) {
- /* release the alternate,
- * primary is good */
+ /*
+ * release the alternate,
+ * primary is good
+ */
sctp_free_remote_addr(stcb->asoc.alternate);
stcb->asoc.alternate = NULL;
}
@@ -4078,7 +4127,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
}
/* RWND update */
asoc->peers_rwnd = sctp_sbspace_sub(rwnd,
- (uint32_t) (asoc->total_flight + (asoc->total_flight_count * SCTP_BASE_SYSCTL(sctp_peer_chunk_oh))));
+ (uint32_t)(asoc->total_flight + (asoc->total_flight_count * SCTP_BASE_SYSCTL(sctp_peer_chunk_oh))));
if (asoc->peers_rwnd < stcb->sctp_ep->sctp_ep.sctp_sws_sender) {
/* SWS sender side engages */
asoc->peers_rwnd = 0;
@@ -4121,8 +4170,10 @@ again:
}
} else {
if (net->window_probe) {
- /* In window probes we must assure a timer
- * is still running there */
+ /*
+ * In window probes we must assure a timer
+ * is still running there
+ */
net->window_probe = 0;
if (!SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) {
SCTP_OS_TIMER_START(&net->rxt_timer.timer, to_ticks,
@@ -4361,8 +4412,8 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
uint32_t *dupdata, dblock;
for (i = 0; i < num_dup; i++) {
- dupdata = (uint32_t *) sctp_m_getptr(m, offset_dup + i * sizeof(uint32_t),
- sizeof(uint32_t), (uint8_t *) & dblock);
+ dupdata = (uint32_t *)sctp_m_getptr(m, offset_dup + i * sizeof(uint32_t),
+ sizeof(uint32_t), (uint8_t *)&dblock);
if (dupdata == NULL) {
break;
}
@@ -4493,7 +4544,7 @@ hopeless_peer:
sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_CA,
tp1->whoTo->flight_size,
tp1->book_size,
- (uint32_t) (uintptr_t) tp1->whoTo,
+ (uint32_t)(uintptr_t)tp1->whoTo,
tp1->rec.data.tsn);
}
sctp_flight_size_decrease(tp1);
@@ -4764,7 +4815,7 @@ hopeless_peer:
sctp_misc_ints(SCTP_FLIGHT_LOG_UP_REVOKE,
tp1->whoTo->flight_size,
tp1->book_size,
- (uint32_t) (uintptr_t) tp1->whoTo,
+ (uint32_t)(uintptr_t)tp1->whoTo,
tp1->rec.data.tsn);
}
sctp_flight_size_increase(tp1);
@@ -4807,8 +4858,10 @@ hopeless_peer:
}
if (net == stcb->asoc.primary_destination) {
if (stcb->asoc.alternate) {
- /* release the alternate,
- * primary is good */
+ /*
+ * release the alternate,
+ * primary is good
+ */
sctp_free_remote_addr(stcb->asoc.alternate);
stcb->asoc.alternate = NULL;
}
@@ -4977,7 +5030,7 @@ hopeless_peer:
asoc->peers_rwnd, asoc->total_flight, (asoc->total_flight_count * SCTP_BASE_SYSCTL(sctp_peer_chunk_oh)), a_rwnd);
}
asoc->peers_rwnd = sctp_sbspace_sub(a_rwnd,
- (uint32_t) (asoc->total_flight + (asoc->total_flight_count * SCTP_BASE_SYSCTL(sctp_peer_chunk_oh))));
+ (uint32_t)(asoc->total_flight + (asoc->total_flight_count * SCTP_BASE_SYSCTL(sctp_peer_chunk_oh))));
if (asoc->peers_rwnd < stcb->sctp_ep->sctp_ep.sctp_sws_sender) {
/* SWS sender side engages */
asoc->peers_rwnd = 0;
@@ -5019,8 +5072,10 @@ again:
}
} else {
if (net->window_probe) {
- /* In window probes we must assure a timer
- * is still running there */
+ /*
+ * In window probes we must assure a timer
+ * is still running there
+ */
if (!SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) {
sctp_timer_start(SCTP_TIMER_TYPE_SEND,
stcb->sctp_ep, stcb, net);
@@ -5171,8 +5226,10 @@ sctp_kick_prsctp_reorder_queue(struct sctp_tcb *stcb,
} else {
/* Its a fragmented message */
if (ctl->first_frag_seen) {
- /* Make it so this is next to
- * deliver, we restore later */
+ /*
+ * Make it so this is next to
+ * deliver, we restore later
+ */
strmin->last_mid_delivered = ctl->mid - 1;
need_reasm_check = 1;
break;
@@ -5236,8 +5293,10 @@ sctp_kick_prsctp_reorder_queue(struct sctp_tcb *stcb,
} else {
/* Its a fragmented message */
if (ctl->first_frag_seen) {
- /* Make it so this is next to
- * deliver */
+ /*
+ * Make it so this is next to
+ * deliver
+ */
strmin->last_mid_delivered = ctl->mid - 1;
need_reasm_check = 1;
break;
@@ -5466,7 +5525,7 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb,
if (asoc->idata_supported) {
stseq_m = (struct sctp_strseq_mid *)sctp_m_getptr(m, offset,
sizeof(struct sctp_strseq_mid),
- (uint8_t *) & strseqbuf_m);
+ (uint8_t *)&strseqbuf_m);
offset += sizeof(struct sctp_strseq_mid);
if (stseq_m == NULL) {
break;
@@ -5482,13 +5541,13 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb,
} else {
stseq = (struct sctp_strseq *)sctp_m_getptr(m, offset,
sizeof(struct sctp_strseq),
- (uint8_t *) & strseqbuf);
+ (uint8_t *)&strseqbuf);
offset += sizeof(struct sctp_strseq);
if (stseq == NULL) {
break;
}
sid = ntohs(stseq->sid);
- mid = (uint32_t) ntohs(stseq->ssn);
+ mid = (uint32_t)ntohs(stseq->ssn);
ordered = 1;
}
/* Convert */
diff --git a/freebsd/sys/netinet/sctp_indata.h b/freebsd/sys/netinet/sctp_indata.h
index e277ae88..badd269d 100644
--- a/freebsd/sys/netinet/sctp_indata.h
+++ b/freebsd/sys/netinet/sctp_indata.h
@@ -79,7 +79,7 @@ sctp_build_ctl_nchunk(struct sctp_inpcb *inp,
void sctp_set_rwnd(struct sctp_tcb *, struct sctp_association *);
uint32_t
-sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc);
+ sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc);
void
sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
diff --git a/freebsd/sys/netinet/sctp_input.c b/freebsd/sys/netinet/sctp_input.c
index 3c596c48..7e84ebd1 100644
--- a/freebsd/sys/netinet/sctp_input.c
+++ b/freebsd/sys/netinet/sctp_input.c
@@ -462,7 +462,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset,
return (-1);
}
asoc = &stcb->asoc;
- asoc->peer_supports_nat = (uint8_t) nat_friendly;
+ asoc->peer_supports_nat = (uint8_t)nat_friendly;
/* process the peer's parameters in the INIT-ACK */
retval = sctp_process_init((struct sctp_init_chunk *)cp, stcb);
if (retval < 0) {
@@ -534,7 +534,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset,
if (retval == -3) {
uint16_t len;
- len = (uint16_t) (sizeof(struct sctp_error_missing_param) + sizeof(uint16_t));
+ len = (uint16_t)(sizeof(struct sctp_error_missing_param) + sizeof(uint16_t));
/* We abort with an error of missing mandatory param */
op_err = sctp_get_mbuf_for_msg(len, 0, M_NOWAIT, 1, MT_DATA);
if (op_err != NULL) {
@@ -709,8 +709,10 @@ sctp_handle_nat_colliding_state(struct sctp_tcb *stcb)
LIST_REMOVE(stcb, sctp_asocs);
stcb->asoc.my_vtag = sctp_select_a_tag(stcb->sctp_ep, stcb->sctp_ep->sctp_lport, stcb->rport, 1);
head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(stcb->asoc.my_vtag, SCTP_BASE_INFO(hashasocmark))];
- /* put it in the bucket in the vtag hash of assoc's for the
- * system */
+ /*
+ * put it in the bucket in the vtag hash of assoc's for the
+ * system
+ */
LIST_INSERT_HEAD(head, stcb, sctp_asocs);
sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
return (1);
@@ -728,8 +730,10 @@ sctp_handle_nat_colliding_state(struct sctp_tcb *stcb)
sctp_toss_old_cookies(stcb, &stcb->asoc);
stcb->asoc.my_vtag = sctp_select_a_tag(stcb->sctp_ep, stcb->sctp_ep->sctp_lport, stcb->rport, 1);
head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(stcb->asoc.my_vtag, SCTP_BASE_INFO(hashasocmark))];
- /* put it in the bucket in the vtag hash of assoc's for the
- * system */
+ /*
+ * put it in the bucket in the vtag hash of assoc's for the
+ * system
+ */
LIST_INSERT_HEAD(head, stcb, sctp_asocs);
sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
return (1);
@@ -939,8 +943,10 @@ sctp_handle_shutdown(struct sctp_shutdown_chunk *cp,
(SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT)) {
SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_RECEIVED);
SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
- /* notify upper layer that peer has initiated a
- * shutdown */
+ /*
+ * notify upper layer that peer has initiated a
+ * shutdown
+ */
sctp_ulp_notify(SCTP_NOTIFY_PEER_SHUTDOWN, stcb, 0, NULL, SCTP_SO_NOT_LOCKED);
/* reset time */
@@ -1101,7 +1107,7 @@ sctp_process_unrecog_chunk(struct sctp_tcb *stcb, struct sctp_paramhdr *phdr,
default:
SCTPDBG(SCTP_DEBUG_INPUT2,
"Peer does not support chunk type %d(%x)??\n",
- chk->chunk_type, (uint32_t) chk->chunk_type);
+ chk->chunk_type, (uint32_t)chk->chunk_type);
break;
}
}
@@ -1144,7 +1150,7 @@ sctp_process_unrecog_param(struct sctp_tcb *stcb, struct sctp_paramhdr *phdr)
default:
SCTPDBG(SCTP_DEBUG_INPUT2,
"Peer does not support param type %d(%x)??\n",
- pbad->param_type, (uint32_t) pbad->param_type);
+ pbad->param_type, (uint32_t)pbad->param_type);
break;
}
}
@@ -1514,7 +1520,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
init_cp = (struct sctp_init_chunk *)
sctp_m_getptr(m, init_offset, sizeof(struct sctp_init_chunk),
- (uint8_t *) & init_buf);
+ (uint8_t *)&init_buf);
if (init_cp == NULL) {
/* could not pull a INIT chunk in cookie */
return (NULL);
@@ -1529,7 +1535,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
initack_offset = init_offset + SCTP_SIZE32(ntohs(init_cp->ch.chunk_length));
initack_cp = (struct sctp_init_ack_chunk *)
sctp_m_getptr(m, initack_offset, sizeof(struct sctp_init_ack_chunk),
- (uint8_t *) & initack_buf);
+ (uint8_t *)&initack_buf);
if (initack_cp == NULL) {
/* could not pull INIT-ACK chunk in cookie */
return (NULL);
@@ -2063,7 +2069,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset,
init_offset = offset + sizeof(struct sctp_cookie_echo_chunk);
init_cp = (struct sctp_init_chunk *)
sctp_m_getptr(m, init_offset, sizeof(struct sctp_init_chunk),
- (uint8_t *) & init_buf);
+ (uint8_t *)&init_buf);
if (init_cp == NULL) {
/* could not pull a INIT chunk in cookie */
SCTPDBG(SCTP_DEBUG_INPUT1,
@@ -2081,7 +2087,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset,
*/
initack_cp = (struct sctp_init_ack_chunk *)
sctp_m_getptr(m, initack_offset, sizeof(struct sctp_init_ack_chunk),
- (uint8_t *) & initack_buf);
+ (uint8_t *)&initack_buf);
if (initack_cp == NULL) {
/* could not pull INIT-ACK chunk in cookie */
SCTPDBG(SCTP_DEBUG_INPUT1, "process_cookie_new: could not pull INIT-ACK chunk hdr\n");
@@ -2491,17 +2497,17 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
(ep->current_secret_number != ep->last_secret_number)) {
/* it's the old cookie */
(void)sctp_hmac_m(SCTP_HMAC,
- (uint8_t *) ep->secret_key[(int)ep->last_secret_number],
+ (uint8_t *)ep->secret_key[(int)ep->last_secret_number],
SCTP_SECRET_SIZE, m, cookie_offset, calc_sig, 0);
} else {
/* it's the current cookie */
(void)sctp_hmac_m(SCTP_HMAC,
- (uint8_t *) ep->secret_key[(int)ep->current_secret_number],
+ (uint8_t *)ep->secret_key[(int)ep->current_secret_number],
SCTP_SECRET_SIZE, m, cookie_offset, calc_sig, 0);
}
/* get the signature */
SCTP_INP_RUNLOCK(l_inp);
- sig = (uint8_t *) sctp_m_getptr(m_sig, 0, SCTP_SIGNATURE_SIZE, (uint8_t *) & tmp_sig);
+ sig = (uint8_t *)sctp_m_getptr(m_sig, 0, SCTP_SIGNATURE_SIZE, (uint8_t *)&tmp_sig);
if (sig == NULL) {
/* couldn't find signature */
sctp_m_freem(m_sig);
@@ -2514,7 +2520,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
(ep->current_secret_number != ep->last_secret_number)) {
/* compute digest with old */
(void)sctp_hmac_m(SCTP_HMAC,
- (uint8_t *) ep->secret_key[(int)ep->last_secret_number],
+ (uint8_t *)ep->secret_key[(int)ep->last_secret_number],
SCTP_SECRET_SIZE, m, cookie_offset, calc_sig, 0);
/* compare */
if (memcmp(calc_sig, sig, SCTP_SIGNATURE_SIZE) == 0)
@@ -2542,7 +2548,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
SCTPDBG(SCTP_DEBUG_INPUT2, "handle_cookie_echo: cookie signature validation failed!\n");
SCTPDBG(SCTP_DEBUG_INPUT2,
"offset = %u, cookie_offset = %u, sig_offset = %u\n",
- (uint32_t) offset, cookie_offset, sig_offset);
+ (uint32_t)offset, cookie_offset, sig_offset);
return (NULL);
}
/*
@@ -2863,8 +2869,10 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
sctp_ulp_notify(SCTP_NOTIFY_INTERFACE_CONFIRMED,
(*stcb), 0, (void *)netl, SCTP_SO_NOT_LOCKED);
}
- /* Pull it from the incomplete queue and wake the
- * guy */
+ /*
+ * Pull it from the incomplete queue and wake the
+ * guy
+ */
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
atomic_add_int(&(*stcb)->asoc.refcnt, 1);
SCTP_TCB_UNLOCK((*stcb));
@@ -3076,8 +3084,10 @@ sctp_handle_ecn_echo(struct sctp_ecne_chunk *cp,
}
if (SCTP_TSN_GT(tsn, net->cwr_window_tsn) &&
((override_bit & SCTP_CWR_REDUCE_OVERRIDE) == 0)) {
- /* JRS - Use the congestion control given in the pluggable
- * CC module */
+ /*
+ * JRS - Use the congestion control given in the pluggable
+ * CC module
+ */
stcb->asoc.cc_functions.sctp_cwnd_update_after_ecn_echo(stcb, net, 0, pkt_cnt);
/*
* We reduce once every RTT. So we will only lower cwnd at
@@ -3273,7 +3283,7 @@ process_chunk_drop(struct sctp_tcb *stcb, struct sctp_chunk_desc *desc,
SCTP_STAT_INCR(sctps_pdrpdizrw);
return (0);
}
- ddp = (uint8_t *) (mtod(tp1->data, caddr_t)+
+ ddp = (uint8_t *)(mtod(tp1->data, caddr_t)+
sizeof(struct sctp_data_chunk));
{
unsigned int iii;
@@ -3328,7 +3338,7 @@ process_chunk_drop(struct sctp_tcb *stcb, struct sctp_chunk_desc *desc,
sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PDRP,
tp1->whoTo->flight_size,
tp1->book_size,
- (uint32_t) (uintptr_t) stcb,
+ (uint32_t)(uintptr_t)stcb,
tp1->rec.data.tsn);
}
if (tp1->sent < SCTP_DATAGRAM_RESEND) {
@@ -3400,8 +3410,10 @@ process_chunk_drop(struct sctp_tcb *stcb, struct sctp_chunk_desc *desc,
case SCTP_HEARTBEAT_REQUEST:
/* resend a demand HB */
if ((stcb->asoc.overall_error_count + 3) < stcb->asoc.max_send_times) {
- /* Only retransmit if we KNOW we wont destroy the
- * tcb */
+ /*
+ * Only retransmit if we KNOW we wont destroy the
+ * tcb
+ */
sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED);
}
break;
@@ -3457,7 +3469,7 @@ process_chunk_drop(struct sctp_tcb *stcb, struct sctp_chunk_desc *desc,
}
void
-sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t * list)
+sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t *list)
{
uint32_t i;
uint16_t temp;
@@ -3485,7 +3497,7 @@ sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t *
}
static void
-sctp_reset_out_streams(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t * list)
+sctp_reset_out_streams(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t *list)
{
uint32_t i;
uint16_t temp;
@@ -3510,7 +3522,7 @@ sctp_reset_out_streams(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t
}
static void
-sctp_reset_clear_pending(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t * list)
+sctp_reset_clear_pending(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t *list)
{
uint32_t i;
uint16_t temp;
@@ -3642,8 +3654,10 @@ sctp_handle_stream_reset_response(struct sctp_tcb *stcb,
} else if (action == SCTP_STREAM_RESET_RESULT_DENIED) {
sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_DENIED_OUT, stcb, number_entries, req_out_param->list_of_streams, SCTP_SO_NOT_LOCKED);
} else if (action == SCTP_STREAM_RESET_RESULT_IN_PROGRESS) {
- /* Set it up so we don't stop
- * retransmitting */
+ /*
+ * Set it up so we don't stop
+ * retransmitting
+ */
asoc->stream_reset_outstanding++;
stcb->asoc.str_reset_seq_out--;
asoc->stream_reset_out_is_outstanding = 1;
@@ -3745,8 +3759,8 @@ sctp_handle_stream_reset_response(struct sctp_tcb *stcb,
stcb->asoc.sending_seq = ntohl(resp->receivers_next_tsn);
stcb->asoc.last_acked_seq = stcb->asoc.cumulative_tsn;
- sctp_reset_out_streams(stcb, 0, (uint16_t *) NULL);
- sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL);
+ sctp_reset_out_streams(stcb, 0, (uint16_t *)NULL);
+ sctp_reset_in_stream(stcb, 0, (uint16_t *)NULL);
sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), 0);
} else if (action == SCTP_STREAM_RESET_RESULT_DENIED) {
sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1),
@@ -3879,8 +3893,8 @@ sctp_handle_str_reset_request_tsn(struct sctp_tcb *stcb,
asoc->last_sending_seq[0] = asoc->sending_seq;
asoc->last_base_tsnsent[1] = asoc->last_base_tsnsent[0];
asoc->last_base_tsnsent[0] = asoc->mapping_array_base_tsn;
- sctp_reset_out_streams(stcb, 0, (uint16_t *) NULL);
- sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL);
+ sctp_reset_out_streams(stcb, 0, (uint16_t *)NULL);
+ sctp_reset_in_stream(stcb, 0, (uint16_t *)NULL);
asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED;
sctp_notify_stream_reset_tsn(stcb, asoc->sending_seq, (asoc->mapping_array_base_tsn + 1), 0);
}
@@ -4129,9 +4143,9 @@ sctp_handle_str_reset_add_out_strm(struct sctp_tcb *stcb, struct sctp_tmit_chunk
#ifdef __GNUC__
__attribute__((noinline))
#endif
- static int
- sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset,
- struct sctp_chunkhdr *ch_req)
+static int
+sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset,
+ struct sctp_chunkhdr *ch_req)
{
uint16_t remaining_length, param_len, ptype;
struct sctp_paramhdr pstore;
@@ -4185,7 +4199,7 @@ strres_nochunk:
SCTP_BUF_LEN(chk->data) = SCTP_SIZE32(chk->send_size);
offset += sizeof(struct sctp_chunkhdr);
while (remaining_length >= sizeof(struct sctp_paramhdr)) {
- ph = (struct sctp_paramhdr *)sctp_m_getptr(m, offset, sizeof(pstore), (uint8_t *) & pstore);
+ ph = (struct sctp_paramhdr *)sctp_m_getptr(m, offset, sizeof(pstore), (uint8_t *)&pstore);
if (ph == NULL) {
/* TSNH */
break;
@@ -4197,7 +4211,7 @@ strres_nochunk:
break;
}
ph = (struct sctp_paramhdr *)sctp_m_getptr(m, offset, min(param_len, sizeof(cstore)),
- (uint8_t *) & cstore);
+ (uint8_t *)&cstore);
if (ph == NULL) {
/* TSNH */
break;
@@ -4330,7 +4344,7 @@ sctp_handle_packet_dropped(struct sctp_pktdrop_chunk *cp,
/* XXX possible chlen underflow */
memset(&desc, 0, sizeof(desc));
}
- trunc_len = (uint16_t) ntohs(cp->trunc_len);
+ trunc_len = (uint16_t)ntohs(cp->trunc_len);
if (trunc_len > limit) {
trunc_len = limit;
}
@@ -4376,7 +4390,7 @@ sctp_handle_packet_dropped(struct sctp_pktdrop_chunk *cp,
unsigned int iii;
dcp = (struct sctp_data_chunk *)ch;
- ddp = (uint8_t *) (dcp + 1);
+ ddp = (uint8_t *)(dcp + 1);
for (iii = 0; iii < sizeof(desc.data_bytes); iii++) {
desc.data_bytes[iii] = ddp[iii];
}
@@ -4467,13 +4481,13 @@ sctp_handle_packet_dropped(struct sctp_pktdrop_chunk *cp,
#ifdef __GNUC__
__attribute__((noinline))
#endif
- static struct sctp_tcb *
- sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length,
- struct sockaddr *src, struct sockaddr *dst,
- struct sctphdr *sh, struct sctp_chunkhdr *ch, struct sctp_inpcb *inp,
- struct sctp_tcb *stcb, struct sctp_nets **netp, int *fwd_tsn_seen,
- uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum,
- uint32_t vrf_id, uint16_t port)
+static struct sctp_tcb *
+sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length,
+ struct sockaddr *src, struct sockaddr *dst,
+ struct sctphdr *sh, struct sctp_chunkhdr *ch, struct sctp_inpcb *inp,
+ struct sctp_tcb *stcb, struct sctp_nets **netp, int *fwd_tsn_seen,
+ uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum,
+ uint32_t vrf_id, uint16_t port)
{
struct sctp_association *asoc;
struct mbuf *op_err;
@@ -4697,8 +4711,10 @@ __attribute__((noinline))
return (NULL);
}
}
- } /* end if !SCTP_COOKIE_ECHO *//* process all
- * control chunks... */
+ } /* end if !SCTP_COOKIE_ECHO */
+ /*
+ * process all control chunks...
+ */
if (((ch->chunk_type == SCTP_SELECTIVE_ACK) ||
(ch->chunk_type == SCTP_NR_SELECTIVE_ACK) ||
(ch->chunk_type == SCTP_HEARTBEAT_REQUEST)) &&
@@ -4945,7 +4961,7 @@ process_control_chunks:
cum_ack = ntohl(sack->sack.cum_tsn_ack);
num_seg = ntohs(sack->sack.num_gap_ack_blks);
num_dup = ntohs(sack->sack.num_dup_tsns);
- a_rwnd = (uint32_t) ntohl(sack->sack.a_rwnd);
+ a_rwnd = (uint32_t)ntohl(sack->sack.a_rwnd);
if (sizeof(struct sctp_sack_chunk) +
num_seg * sizeof(struct sctp_gap_ack_block) +
num_dup * sizeof(uint32_t) != chk_length) {
@@ -4992,8 +5008,10 @@ process_control_chunks:
}
}
break;
- /* EY - nr_sack: If the received chunk is an
- * nr_sack chunk */
+ /*
+ * EY - nr_sack: If the received chunk is an
+ * nr_sack chunk
+ */
case SCTP_NR_SELECTIVE_ACK:
{
struct sctp_nr_sack_chunk *nr_sack;
@@ -5030,7 +5048,7 @@ process_control_chunks:
num_seg = ntohs(nr_sack->nr_sack.num_gap_ack_blks);
num_nr_seg = ntohs(nr_sack->nr_sack.num_nr_gap_ack_blks);
num_dup = ntohs(nr_sack->nr_sack.num_dup_tsns);
- a_rwnd = (uint32_t) ntohl(nr_sack->nr_sack.a_rwnd);
+ a_rwnd = (uint32_t)ntohl(nr_sack->nr_sack.a_rwnd);
if (sizeof(struct sctp_nr_sack_chunk) +
(num_seg + num_nr_seg) * sizeof(struct sctp_gap_ack_block) +
num_dup * sizeof(uint32_t) != chk_length) {
@@ -5589,10 +5607,10 @@ process_control_chunks:
op_err = sctp_get_mbuf_for_msg(sizeof(struct sctp_gen_error_cause),
0, M_NOWAIT, 1, MT_DATA);
if (op_err != NULL) {
- len = min(SCTP_SIZE32(chk_length), (uint32_t) (length - *offset));
+ len = min(SCTP_SIZE32(chk_length), (uint32_t)(length - *offset));
cause = mtod(op_err, struct sctp_gen_error_cause *);
cause->code = htons(SCTP_CAUSE_UNRECOG_CHUNK);
- cause->length = htons((uint16_t) (len + sizeof(struct sctp_gen_error_cause)));
+ cause->length = htons((uint16_t)(len + sizeof(struct sctp_gen_error_cause)));
SCTP_BUF_LEN(op_err) = sizeof(struct sctp_gen_error_cause);
SCTP_BUF_NEXT(op_err) = SCTP_M_COPYM(m, *offset, len, M_NOWAIT);
if (SCTP_BUF_NEXT(op_err) != NULL) {
@@ -5611,7 +5629,8 @@ process_control_chunks:
/* discard this packet */
*offset = length;
return (stcb);
- } /* else skip this bad chunk and continue... */ break;
+ } /* else skip this bad chunk and continue... */
+ break;
} /* switch (ch->chunk_type) */
diff --git a/freebsd/sys/netinet/sctp_input.h b/freebsd/sys/netinet/sctp_input.h
index 148864b6..25df0f3b 100644
--- a/freebsd/sys/netinet/sctp_input.h
+++ b/freebsd/sys/netinet/sctp_input.h
@@ -54,7 +54,7 @@ sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq,
void
sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries,
- uint16_t * list);
+ uint16_t *list);
int sctp_is_there_unsent_data(struct sctp_tcb *stcb, int so_locked);
diff --git a/freebsd/sys/netinet/sctp_output.c b/freebsd/sys/netinet/sctp_output.c
index 94f9d866..a27f2a3e 100644
--- a/freebsd/sys/netinet/sctp_output.c
+++ b/freebsd/sys/netinet/sctp_output.c
@@ -1939,7 +1939,7 @@ sctp_is_address_in_scope(struct sctp_ifa *ifa,
}
static struct mbuf *
-sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa, uint16_t * len)
+sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa, uint16_t *len)
{
#if defined(INET) || defined(INET6)
struct sctp_paramhdr *parmh;
@@ -1950,12 +1950,12 @@ sctp_add_addr_to_mbuf(struct mbuf *m, struct sctp_ifa *ifa, uint16_t * len)
switch (ifa->address.sa.sa_family) {
#ifdef INET
case AF_INET:
- plen = (uint16_t) sizeof(struct sctp_ipv4addr_param);
+ plen = (uint16_t)sizeof(struct sctp_ipv4addr_param);
break;
#endif
#ifdef INET6
case AF_INET6:
- plen = (uint16_t) sizeof(struct sctp_ipv6addr_param);
+ plen = (uint16_t)sizeof(struct sctp_ipv6addr_param);
break;
#endif
default:
@@ -2030,7 +2030,7 @@ struct mbuf *
sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
struct sctp_scoping *scope,
struct mbuf *m_at, int cnt_inits_to,
- uint16_t * padding_len, uint16_t * chunk_len)
+ uint16_t *padding_len, uint16_t *chunk_len)
{
struct sctp_vrf *vrf = NULL;
int cnt, limit_out = 0, total_count;
@@ -2140,8 +2140,10 @@ skip_count:
cnt++;
total_count++;
if (cnt >= 2) {
- /* two from each
- * address */
+ /*
+ * two from each
+ * address
+ */
break;
}
if (total_count > SCTP_ADDRESS_LIMIT) {
@@ -2452,7 +2454,7 @@ sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
static struct sctp_ifa *
sctp_choose_boundspecific_inp(struct sctp_inpcb *inp,
- sctp_route_t * ro,
+ sctp_route_t *ro,
uint32_t vrf_id,
int non_asoc_addr_ok,
uint8_t dest_is_priv,
@@ -2584,7 +2586,7 @@ once_again_too:
static struct sctp_ifa *
sctp_choose_boundspecific_stcb(struct sctp_inpcb *inp,
struct sctp_tcb *stcb,
- sctp_route_t * ro,
+ sctp_route_t *ro,
uint32_t vrf_id,
uint8_t dest_is_priv,
uint8_t dest_is_loop,
@@ -2778,7 +2780,7 @@ sctp_select_nth_preferred_addr_from_ifn_boundall(struct sctp_ifn *ifn,
uint8_t dest_is_priv,
int addr_wanted,
sa_family_t fam,
- sctp_route_t * ro
+ sctp_route_t *ro
)
{
struct sctp_ifa *ifa, *sifa;
@@ -2827,8 +2829,10 @@ sctp_select_nth_preferred_addr_from_ifn_boundall(struct sctp_ifn *ifn,
if (fam == AF_INET6 &&
IN6_IS_ADDR_LINKLOCAL(&sifa->address.sin6.sin6_addr) &&
IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr)) {
- /* link-local <-> link-local must belong to the same
- * scope. */
+ /*
+ * link-local <-> link-local must belong to the same
+ * scope.
+ */
memcpy(&lsa6, &sifa->address.sin6, sizeof(struct sockaddr_in6));
(void)sa6_recoverscope(&lsa6);
if (sin6.sin6_scope_id != lsa6.sin6_scope_id) {
@@ -2949,7 +2953,7 @@ static struct sctp_ifa *
sctp_choose_boundall(struct sctp_inpcb *inp,
struct sctp_tcb *stcb,
struct sctp_nets *net,
- sctp_route_t * ro,
+ sctp_route_t *ro,
uint32_t vrf_id,
uint8_t dest_is_priv,
uint8_t dest_is_loop,
@@ -3302,7 +3306,7 @@ out:
struct sctp_ifa *
sctp_source_address_selection(struct sctp_inpcb *inp,
struct sctp_tcb *stcb,
- sctp_route_t * ro,
+ sctp_route_t *ro,
struct sctp_nets *net,
int non_asoc_addr_ok, uint32_t vrf_id)
{
@@ -3810,7 +3814,7 @@ sctp_findassociation_cmsgs(struct sctp_inpcb **inp_p,
static struct mbuf *
sctp_add_cookie(struct mbuf *init, int init_offset,
- struct mbuf *initack, int initack_offset, struct sctp_state_cookie *stc_in, uint8_t ** signature)
+ struct mbuf *initack, int initack_offset, struct sctp_state_cookie *stc_in, uint8_t **signature)
{
struct mbuf *copy_init, *copy_initack, *m_at, *sig, *mret;
struct sctp_state_cookie *stc;
@@ -3889,7 +3893,7 @@ sctp_add_cookie(struct mbuf *init, int init_offset,
SCTP_BUF_LEN(sig) = 0;
SCTP_BUF_NEXT(m_at) = sig;
sig_offset = 0;
- foo = (uint8_t *) (mtod(sig, caddr_t)+sig_offset);
+ foo = (uint8_t *)(mtod(sig, caddr_t)+sig_offset);
memset(foo, 0, SCTP_SIGNATURE_SIZE);
*signature = foo;
SCTP_BUF_LEN(sig) += SCTP_SIGNATURE_SIZE;
@@ -4102,7 +4106,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
memset(&iproute, 0, sizeof(iproute));
memcpy(&ro->ro_dst, to, to->sa_len);
} else {
- ro = (sctp_route_t *) & net->ro;
+ ro = (sctp_route_t *)&net->ro;
}
/* Now the address selection part */
ip->ip_dst.s_addr = ((struct sockaddr_in *)to)->sin_addr.s_addr;
@@ -4165,7 +4169,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
udp = (struct udphdr *)((caddr_t)ip + sizeof(struct ip));
udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port));
udp->uh_dport = port;
- udp->uh_ulen = htons((uint16_t) (packet_length - sizeof(struct ip)));
+ udp->uh_ulen = htons((uint16_t)(packet_length - sizeof(struct ip)));
if (V_udp_cksum) {
udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP));
} else {
@@ -4203,9 +4207,9 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
memcpy(&iproute, ro, sizeof(*ro));
}
SCTPDBG(SCTP_DEBUG_OUTPUT3, "Calling ipv4 output routine from low level src addr:%x\n",
- (uint32_t) (ntohl(ip->ip_src.s_addr)));
+ (uint32_t)(ntohl(ip->ip_src.s_addr)));
SCTPDBG(SCTP_DEBUG_OUTPUT3, "Destination is %x\n",
- (uint32_t) (ntohl(ip->ip_dst.s_addr)));
+ (uint32_t)(ntohl(ip->ip_dst.s_addr)));
SCTPDBG(SCTP_DEBUG_OUTPUT3, "RTP route is %p through\n",
(void *)ro->ro_rt);
@@ -4266,8 +4270,10 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
/* free tempy routes */
RO_RTFREE(ro);
} else {
- /* PMTU check versus smallest asoc MTU goes
- * here */
+ /*
+ * PMTU check versus smallest asoc MTU goes
+ * here
+ */
if ((ro->ro_rt != NULL) &&
(net->ro._s_addr)) {
uint32_t mtu;
@@ -4359,10 +4365,10 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
}
if (net == NULL) {
memset(&ip6route, 0, sizeof(ip6route));
- ro = (sctp_route_t *) & ip6route;
+ ro = (sctp_route_t *)&ip6route;
memcpy(&ro->ro_dst, sin6, sin6->sin6_len);
} else {
- ro = (sctp_route_t *) & net->ro;
+ ro = (sctp_route_t *)&net->ro;
}
/*
* We assume here that inp_flow is in host byte
@@ -4391,7 +4397,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
} else {
ip6h->ip6_nxt = IPPROTO_SCTP;
}
- ip6h->ip6_plen = (uint16_t) (packet_length - sizeof(struct ip6_hdr));
+ ip6h->ip6_plen = (uint16_t)(packet_length - sizeof(struct ip6_hdr));
ip6h->ip6_dst = sin6->sin6_addr;
/*
@@ -4510,7 +4516,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
udp = (struct udphdr *)((caddr_t)ip6h + sizeof(struct ip6_hdr));
udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port));
udp->uh_dport = port;
- udp->uh_ulen = htons((uint16_t) (packet_length - sizeof(struct ip6_hdr)));
+ udp->uh_ulen = htons((uint16_t)(packet_length - sizeof(struct ip6_hdr)));
udp->uh_sum = 0;
sctphdr = (struct sctphdr *)((caddr_t)udp + sizeof(struct udphdr));
} else {
@@ -4542,8 +4548,10 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
SCTPDBG_ADDR(SCTP_DEBUG_OUTPUT3, (struct sockaddr *)sin6);
if (net) {
sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
- /* preserve the port and scope for link
- * local send */
+ /*
+ * preserve the port and scope for link
+ * local send
+ */
prev_scope = sin6->sin6_scope_id;
prev_port = sin6->sin6_port;
}
@@ -4609,8 +4617,10 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
/* Now if we had a temp route free it */
RO_RTFREE(ro);
} else {
- /* PMTU check versus smallest asoc MTU goes
- * here */
+ /*
+ * PMTU check versus smallest asoc MTU goes
+ * here
+ */
if (ro->ro_rt == NULL) {
/* Route was freed */
if (net->ro._s_addr &&
@@ -4670,7 +4680,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
struct sctp_supported_chunk_types_param *pr_supported;
struct sctp_paramhdr *ph;
int cnt_inits_to = 0;
- int ret;
+ int error;
uint16_t num_ext, chunk_len, padding_len, parameter_len;
/* INIT's always go to the primary (and usually ONLY address) */
@@ -4713,7 +4723,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - mbuf?\n");
return;
}
- chunk_len = (uint16_t) sizeof(struct sctp_init_chunk);
+ chunk_len = (uint16_t)sizeof(struct sctp_init_chunk);
padding_len = 0;
/* Now lets put the chunk header in place */
init = mtod(m, struct sctp_init_chunk *);
@@ -4733,7 +4743,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
/* Adaptation layer indication parameter */
if (inp->sctp_ep.adaptation_layer_indicator_provided) {
- parameter_len = (uint16_t) sizeof(struct sctp_adaptation_layer_indication);
+ parameter_len = (uint16_t)sizeof(struct sctp_adaptation_layer_indication);
ali = (struct sctp_adaptation_layer_indication *)(mtod(m, caddr_t)+chunk_len);
ali->ph.param_type = htons(SCTP_ULP_ADAPTATION);
ali->ph.param_length = htons(parameter_len);
@@ -4742,7 +4752,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
}
/* ECN parameter */
if (stcb->asoc.ecn_supported == 1) {
- parameter_len = (uint16_t) sizeof(struct sctp_paramhdr);
+ parameter_len = (uint16_t)sizeof(struct sctp_paramhdr);
ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+chunk_len);
ph->param_type = htons(SCTP_ECN_CAPABLE);
ph->param_length = htons(parameter_len);
@@ -4750,7 +4760,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
}
/* PR-SCTP supported parameter */
if (stcb->asoc.prsctp_supported == 1) {
- parameter_len = (uint16_t) sizeof(struct sctp_paramhdr);
+ parameter_len = (uint16_t)sizeof(struct sctp_paramhdr);
ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+chunk_len);
ph->param_type = htons(SCTP_PRSCTP_SUPPORTED);
ph->param_length = htons(parameter_len);
@@ -4758,7 +4768,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
}
/* Add NAT friendly parameter. */
if (SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly)) {
- parameter_len = (uint16_t) sizeof(struct sctp_paramhdr);
+ parameter_len = (uint16_t)sizeof(struct sctp_paramhdr);
ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+chunk_len);
ph->param_type = htons(SCTP_HAS_NAT_SUPPORT);
ph->param_length = htons(parameter_len);
@@ -4793,7 +4803,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
pr_supported->chunk_types[num_ext++] = SCTP_PACKET_DROPPED;
}
if (num_ext > 0) {
- parameter_len = (uint16_t) sizeof(struct sctp_supported_chunk_types_param) + num_ext;
+ parameter_len = (uint16_t)sizeof(struct sctp_supported_chunk_types_param) + num_ext;
pr_supported->ph.param_type = htons(SCTP_SUPPORTED_CHUNK_EXT);
pr_supported->ph.param_length = htons(parameter_len);
padding_len = SCTP_SIZE32(parameter_len) - parameter_len;
@@ -4811,7 +4821,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
padding_len = 0;
}
randp = (struct sctp_auth_random *)(mtod(m, caddr_t)+chunk_len);
- parameter_len = (uint16_t) sizeof(struct sctp_auth_random) + stcb->asoc.authinfo.random_len;
+ parameter_len = (uint16_t)sizeof(struct sctp_auth_random) + stcb->asoc.authinfo.random_len;
/* random key already contains the header */
memcpy(randp, stcb->asoc.authinfo.random->key, parameter_len);
padding_len = SCTP_SIZE32(parameter_len) - parameter_len;
@@ -4827,11 +4837,11 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
padding_len = 0;
}
hmacs = (struct sctp_auth_hmac_algo *)(mtod(m, caddr_t)+chunk_len);
- parameter_len = (uint16_t) (sizeof(struct sctp_auth_hmac_algo) +
+ parameter_len = (uint16_t)(sizeof(struct sctp_auth_hmac_algo) +
stcb->asoc.local_hmacs->num_algo * sizeof(uint16_t));
hmacs->ph.param_type = htons(SCTP_HMAC_LIST);
hmacs->ph.param_length = htons(parameter_len);
- sctp_serialize_hmaclist(stcb->asoc.local_hmacs, (uint8_t *) hmacs->hmac_ids);
+ sctp_serialize_hmaclist(stcb->asoc.local_hmacs, (uint8_t *)hmacs->hmac_ids);
padding_len = SCTP_SIZE32(parameter_len) - parameter_len;
chunk_len += parameter_len;
}
@@ -4845,7 +4855,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
padding_len = 0;
}
chunks = (struct sctp_auth_chunk_list *)(mtod(m, caddr_t)+chunk_len);
- parameter_len = (uint16_t) (sizeof(struct sctp_auth_chunk_list) +
+ parameter_len = (uint16_t)(sizeof(struct sctp_auth_chunk_list) +
sctp_auth_get_chklist_size(stcb->asoc.local_auth_chunks));
chunks->ph.param_type = htons(SCTP_CHUNK_LIST);
chunks->ph.param_length = htons(parameter_len);
@@ -4863,7 +4873,7 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
chunk_len += padding_len;
padding_len = 0;
}
- parameter_len = (uint16_t) sizeof(struct sctp_cookie_perserve_param);
+ parameter_len = (uint16_t)sizeof(struct sctp_cookie_perserve_param);
cookie_preserve = (struct sctp_cookie_perserve_param *)(mtod(m, caddr_t)+chunk_len);
cookie_preserve->ph.param_type = htons(SCTP_COOKIE_PRESERVE);
cookie_preserve->ph.param_length = htons(parameter_len);
@@ -4879,12 +4889,12 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
chunk_len += padding_len;
padding_len = 0;
}
- parameter_len = (uint16_t) sizeof(struct sctp_paramhdr);
+ parameter_len = (uint16_t)sizeof(struct sctp_paramhdr);
if (stcb->asoc.scope.ipv4_addr_legal) {
- parameter_len += (uint16_t) sizeof(uint16_t);
+ parameter_len += (uint16_t)sizeof(uint16_t);
}
if (stcb->asoc.scope.ipv6_addr_legal) {
- parameter_len += (uint16_t) sizeof(uint16_t);
+ parameter_len += (uint16_t)sizeof(uint16_t);
}
sup_addr = (struct sctp_supported_addr_param *)(mtod(m, caddr_t)+chunk_len);
sup_addr->ph.param_type = htons(SCTP_SUPPORTED_ADDRTYPE);
@@ -4919,14 +4929,21 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
}
}
SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - calls lowlevel_output\n");
- ret = sctp_lowlevel_chunk_output(inp, stcb, net,
+ if ((error = sctp_lowlevel_chunk_output(inp, stcb, net,
(struct sockaddr *)&net->ro._l_addr,
m, 0, NULL, 0, 0, 0, 0,
inp->sctp_lport, stcb->rport, htonl(0),
net->port, NULL,
0, 0,
- so_locked);
- SCTPDBG(SCTP_DEBUG_OUTPUT4, "lowlevel_output - %d\n", ret);
+ so_locked))) {
+ SCTPDBG(SCTP_DEBUG_OUTPUT4, "Gak send error %d\n", error);
+ if (error == ENOBUFS) {
+ stcb->asoc.ifp_had_enobuf = 1;
+ SCTP_STAT_INCR(sctps_lowlevelerr);
+ }
+ } else {
+ stcb->asoc.ifp_had_enobuf = 0;
+ }
SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
(void)SCTP_GETTIME_TIMEVAL(&net->last_sent_time);
}
@@ -5494,6 +5511,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
uint16_t his_limit, i_want;
int abort_flag;
int nat_friendly = 0;
+ int error;
struct socket *so;
uint16_t num_ext, chunk_len, padding_len, parameter_len;
@@ -5563,7 +5581,7 @@ do_a_abort:
sctp_m_freem(op_err);
return;
}
- chunk_len = (uint16_t) sizeof(struct sctp_init_ack_chunk);
+ chunk_len = (uint16_t)sizeof(struct sctp_init_ack_chunk);
padding_len = 0;
/*
@@ -5680,8 +5698,10 @@ do_a_abort:
* show up in our scoped count.
*/
cnt_inits_to = 1;
- /* pull out the scope_id from
- * incoming pkt */
+ /*
+ * pull out the scope_id from
+ * incoming pkt
+ */
} else if (IN6_IS_ADDR_SITELOCAL(&src6->sin6_addr) ||
IN6_IS_ADDR_SITELOCAL(&dst6->sin6_addr)) {
/*
@@ -5743,7 +5763,7 @@ do_a_abort:
* did the selection.
*/
net->ro._s_addr = sctp_source_address_selection(inp,
- stcb, (sctp_route_t *) & net->ro,
+ stcb, (sctp_route_t *)&net->ro,
net, 0, vrf_id);
if (net->ro._s_addr == NULL)
return;
@@ -5773,7 +5793,7 @@ do_a_abort:
* done the selection.
*/
net->ro._s_addr = sctp_source_address_selection(inp,
- stcb, (sctp_route_t *) & net->ro,
+ stcb, (sctp_route_t *)&net->ro,
net, 0, vrf_id);
if (net->ro._s_addr == NULL)
return;
@@ -5881,7 +5901,7 @@ do_a_abort:
/* adaptation layer indication parameter */
if (inp->sctp_ep.adaptation_layer_indicator_provided) {
- parameter_len = (uint16_t) sizeof(struct sctp_adaptation_layer_indication);
+ parameter_len = (uint16_t)sizeof(struct sctp_adaptation_layer_indication);
ali = (struct sctp_adaptation_layer_indication *)(mtod(m, caddr_t)+chunk_len);
ali->ph.param_type = htons(SCTP_ULP_ADAPTATION);
ali->ph.param_length = htons(parameter_len);
@@ -5891,7 +5911,7 @@ do_a_abort:
/* ECN parameter */
if (((asoc != NULL) && (asoc->ecn_supported == 1)) ||
((asoc == NULL) && (inp->ecn_supported == 1))) {
- parameter_len = (uint16_t) sizeof(struct sctp_paramhdr);
+ parameter_len = (uint16_t)sizeof(struct sctp_paramhdr);
ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+chunk_len);
ph->param_type = htons(SCTP_ECN_CAPABLE);
ph->param_length = htons(parameter_len);
@@ -5900,7 +5920,7 @@ do_a_abort:
/* PR-SCTP supported parameter */
if (((asoc != NULL) && (asoc->prsctp_supported == 1)) ||
((asoc == NULL) && (inp->prsctp_supported == 1))) {
- parameter_len = (uint16_t) sizeof(struct sctp_paramhdr);
+ parameter_len = (uint16_t)sizeof(struct sctp_paramhdr);
ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+chunk_len);
ph->param_type = htons(SCTP_PRSCTP_SUPPORTED);
ph->param_length = htons(parameter_len);
@@ -5908,7 +5928,7 @@ do_a_abort:
}
/* Add NAT friendly parameter */
if (nat_friendly) {
- parameter_len = (uint16_t) sizeof(struct sctp_paramhdr);
+ parameter_len = (uint16_t)sizeof(struct sctp_paramhdr);
ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+chunk_len);
ph->param_type = htons(SCTP_HAS_NAT_SUPPORT);
ph->param_length = htons(parameter_len);
@@ -5951,7 +5971,7 @@ do_a_abort:
pr_supported->chunk_types[num_ext++] = SCTP_PACKET_DROPPED;
}
if (num_ext > 0) {
- parameter_len = (uint16_t) sizeof(struct sctp_supported_chunk_types_param) + num_ext;
+ parameter_len = (uint16_t)sizeof(struct sctp_supported_chunk_types_param) + num_ext;
pr_supported->ph.param_type = htons(SCTP_SUPPORTED_CHUNK_EXT);
pr_supported->ph.param_length = htons(parameter_len);
padding_len = SCTP_SIZE32(parameter_len) - parameter_len;
@@ -5971,7 +5991,7 @@ do_a_abort:
}
/* generate and add RANDOM parameter */
randp = (struct sctp_auth_random *)(mtod(m, caddr_t)+chunk_len);
- parameter_len = (uint16_t) sizeof(struct sctp_auth_random) +
+ parameter_len = (uint16_t)sizeof(struct sctp_auth_random) +
SCTP_AUTH_RANDOM_SIZE_DEFAULT;
randp->ph.param_type = htons(SCTP_RANDOM);
randp->ph.param_length = htons(parameter_len);
@@ -5986,9 +6006,9 @@ do_a_abort:
}
/* add HMAC_ALGO parameter */
hmacs = (struct sctp_auth_hmac_algo *)(mtod(m, caddr_t)+chunk_len);
- parameter_len = (uint16_t) sizeof(struct sctp_auth_hmac_algo) +
+ parameter_len = (uint16_t)sizeof(struct sctp_auth_hmac_algo) +
sctp_serialize_hmaclist(inp->sctp_ep.local_hmacs,
- (uint8_t *) hmacs->hmac_ids);
+ (uint8_t *)hmacs->hmac_ids);
hmacs->ph.param_type = htons(SCTP_HMAC_LIST);
hmacs->ph.param_length = htons(parameter_len);
padding_len = SCTP_SIZE32(parameter_len) - parameter_len;
@@ -6001,7 +6021,7 @@ do_a_abort:
}
/* add CHUNKS parameter */
chunks = (struct sctp_auth_chunk_list *)(mtod(m, caddr_t)+chunk_len);
- parameter_len = (uint16_t) sizeof(struct sctp_auth_chunk_list) +
+ parameter_len = (uint16_t)sizeof(struct sctp_auth_chunk_list) +
sctp_serialize_auth_chunks(inp->sctp_ep.local_auth_chunks,
chunks->chunk_types);
chunks->ph.param_type = htons(SCTP_CHUNK_LIST);
@@ -6087,9 +6107,9 @@ do_a_abort:
* though thus we set trailer.
*/
(void)sctp_hmac_m(SCTP_HMAC,
- (uint8_t *) inp->sctp_ep.secret_key[(int)(inp->sctp_ep.current_secret_number)],
+ (uint8_t *)inp->sctp_ep.secret_key[(int)(inp->sctp_ep.current_secret_number)],
SCTP_SECRET_SIZE, m_cookie, sizeof(struct sctp_paramhdr),
- (uint8_t *) signature, SCTP_SIGNATURE_SIZE);
+ (uint8_t *)signature, SCTP_SIGNATURE_SIZE);
/*
* We sifa 0 here to NOT set IP_DF if its IPv4, we ignore the return
* here since the timer will drive a retranmission.
@@ -6106,12 +6126,24 @@ do_a_abort:
over_addr = NULL;
}
- (void)sctp_lowlevel_chunk_output(inp, NULL, NULL, to, m, 0, NULL, 0, 0,
+ if ((error = sctp_lowlevel_chunk_output(inp, NULL, NULL, to, m, 0, NULL, 0, 0,
0, 0,
inp->sctp_lport, sh->src_port, init_chk->init.initiate_tag,
port, over_addr,
mflowtype, mflowid,
- SCTP_SO_NOT_LOCKED);
+ SCTP_SO_NOT_LOCKED))) {
+ SCTPDBG(SCTP_DEBUG_OUTPUT4, "Gak send error %d\n", error);
+ if (error == ENOBUFS) {
+ if (asoc != NULL) {
+ asoc->ifp_had_enobuf = 1;
+ }
+ SCTP_STAT_INCR(sctps_lowlevelerr);
+ }
+ } else {
+ if (asoc != NULL) {
+ asoc->ifp_had_enobuf = 0;
+ }
+ }
SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
}
@@ -6167,9 +6199,9 @@ sctp_prune_prsctp(struct sctp_tcb *stcb,
if (freed_spc >= dataout) {
return;
}
- } /* if chunk was present */
- } /* if of sufficient priority */
- } /* if chunk has enabled */
+ } /* if chunk was present */
+ } /* if of sufficient priority */
+ } /* if chunk has enabled */
} /* tailqforeach */
TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
@@ -6190,11 +6222,11 @@ sctp_prune_prsctp(struct sctp_tcb *stcb,
if (freed_spc >= dataout) {
return;
}
- } /* end if chk->data */
- } /* end if right class */
- } /* end if chk pr-sctp */
+ } /* end if chk->data */
+ } /* end if right class */
+ } /* end if chk pr-sctp */
} /* tailqforeachsafe (chk) */
- } /* if enabled in asoc */
+ } /* if enabled in asoc */
}
int
@@ -6437,8 +6469,10 @@ error_out:
/* get the prepend space */
SCTP_BUF_RESV_UF(outchain, (SCTP_FIRST_MBUF_RESV + 4));
} else {
- /* We really should not get a NULL
- * in endofchain */
+ /*
+ * We really should not get a NULL
+ * in endofchain
+ */
/* find end */
m = outchain;
while (m) {
@@ -6450,8 +6484,10 @@ error_out:
}
/* sanity */
if (*endofchain == NULL) {
- /* huh, TSNH XXX maybe we
- * should panic */
+ /*
+ * huh, TSNH XXX maybe we
+ * should panic
+ */
sctp_m_freem(outchain);
goto new_mbuf;
}
@@ -6614,7 +6650,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr,
ph = mtod(m, struct sctp_paramhdr *);
ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT);
- ph->param_length = htons((uint16_t) (sizeof(struct sctp_paramhdr) + ca->sndlen));
+ ph->param_length = htons((uint16_t)(sizeof(struct sctp_paramhdr) + ca->sndlen));
}
/*
* We add one here to keep the assoc from dis-appearing on
@@ -6650,13 +6686,17 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr,
if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete) (stcb, asoc)) {
goto abort_anyway;
}
- /* there is nothing queued to send, so I'm
- * done... */
+ /*
+ * there is nothing queued to send, so I'm
+ * done...
+ */
if ((SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) &&
(SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
(SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
- /* only send SHUTDOWN the first time
- * through */
+ /*
+ * only send SHUTDOWN the first time
+ * through
+ */
if (SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
@@ -6979,7 +7019,7 @@ all_done:
sctp_misc_ints(SCTP_FLIGHT_LOG_UP,
data_list[i]->whoTo->flight_size,
data_list[i]->book_size,
- (uint32_t) (uintptr_t) data_list[i]->whoTo,
+ (uint32_t)(uintptr_t)data_list[i]->whoTo,
data_list[i]->rec.data.tsn);
}
sctp_flight_size_increase(data_list[i]);
@@ -6989,7 +7029,7 @@ all_done:
asoc->peers_rwnd, data_list[i]->send_size, SCTP_BASE_SYSCTL(sctp_peer_chunk_oh));
}
asoc->peers_rwnd = sctp_sbspace_sub(asoc->peers_rwnd,
- (uint32_t) (data_list[i]->send_size + SCTP_BASE_SYSCTL(sctp_peer_chunk_oh)));
+ (uint32_t)(data_list[i]->send_size + SCTP_BASE_SYSCTL(sctp_peer_chunk_oh)));
if (asoc->peers_rwnd < stcb->sctp_ep->sctp_ep.sctp_sws_sender) {
/* SWS sender side engages */
asoc->peers_rwnd = 0;
@@ -7287,8 +7327,10 @@ re_look:
SCTP_TCB_SEND_LOCK(stcb);
send_lock_up = 1;
if (sp->msg_is_complete) {
- /* the sender finished the
- * msg */
+ /*
+ * the sender finished the
+ * msg
+ */
goto re_look;
}
}
@@ -7480,10 +7522,10 @@ dont_do_it:
}
if (stcb->asoc.idata_supported == 0) {
sctp_snd_sb_alloc(stcb, sizeof(struct sctp_data_chunk));
- chk->book_size = chk->send_size = (uint16_t) (to_move + sizeof(struct sctp_data_chunk));
+ chk->book_size = chk->send_size = (uint16_t)(to_move + sizeof(struct sctp_data_chunk));
} else {
sctp_snd_sb_alloc(stcb, sizeof(struct sctp_idata_chunk));
- chk->book_size = chk->send_size = (uint16_t) (to_move + sizeof(struct sctp_idata_chunk));
+ chk->book_size = chk->send_size = (uint16_t)(to_move + sizeof(struct sctp_idata_chunk));
}
chk->book_size_scale = 0;
chk->sent = SCTP_DATAGRAM_UNSENT;
@@ -7537,8 +7579,8 @@ dont_do_it:
chk->rec.data.tsn = atomic_fetchadd_int(&asoc->sending_seq, 1);
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOG_AT_SEND_2_OUTQ) {
sctp_misc_ints(SCTP_STRMOUT_LOG_SEND,
- (uint32_t) (uintptr_t) stcb, sp->length,
- (uint32_t) ((chk->rec.data.sid << 16) | (0x0000ffff & chk->rec.data.mid)),
+ (uint32_t)(uintptr_t)stcb, sp->length,
+ (uint32_t)((chk->rec.data.sid << 16) | (0x0000ffff & chk->rec.data.mid)),
chk->rec.data.tsn);
}
if (stcb->asoc.idata_supported == 0) {
@@ -7572,7 +7614,7 @@ dont_do_it:
dchkh->ch.chunk_flags = chk->rec.data.rcv_flags;
dchkh->dp.tsn = htonl(chk->rec.data.tsn);
dchkh->dp.sid = htons(strq->sid);
- dchkh->dp.ssn = htons((uint16_t) chk->rec.data.mid);
+ dchkh->dp.ssn = htons((uint16_t)chk->rec.data.mid);
dchkh->dp.ppid = chk->rec.data.ppid;
dchkh->ch.chunk_length = htons(chk->send_size);
} else {
@@ -8177,8 +8219,10 @@ again_one_more_time:
net->port, NULL,
0, 0,
so_locked))) {
- /* error, we could not
- * output */
+ /*
+ * error, we could not
+ * output
+ */
SCTPDBG(SCTP_DEBUG_OUTPUT3, "Gak send error %d\n", error);
if (from_where == 0) {
SCTP_STAT_INCR(sctps_lowlevelerrusr);
@@ -8251,12 +8295,16 @@ again_one_more_time:
* to where the sack is going..
*/
if (chk->whoTo == net) {
- /* Don't transmit it to where its
- * going (current net) */
+ /*
+ * Don't transmit it to where its
+ * going (current net)
+ */
continue;
} else if (sack_goes_to == net) {
- /* But do transmit it to this
- * address */
+ /*
+ * But do transmit it to this
+ * address
+ */
goto skip_net_check;
}
}
@@ -8449,8 +8497,10 @@ again_one_more_time:
net->port, NULL,
0, 0,
so_locked))) {
- /* error, we could not
- * output */
+ /*
+ * error, we could not
+ * output
+ */
SCTPDBG(SCTP_DEBUG_OUTPUT3, "Gak send error %d\n", error);
if (from_where == 0) {
SCTP_STAT_INCR(sctps_lowlevelerrusr);
@@ -8647,13 +8697,17 @@ again_one_more_time:
override_ok = 0;
SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
} else if (override_ok) {
- /* use this data's
- * keyid */
+ /*
+ * use this data's
+ * keyid
+ */
auth_keyid = chk->auth_keyid;
override_ok = 0;
} else if (auth_keyid != chk->auth_keyid) {
- /* different keyid,
- * so done bundling */
+ /*
+ * different keyid,
+ * so done bundling
+ */
break;
}
}
@@ -8732,7 +8786,8 @@ again_one_more_time:
break;
}
} /* for (chunk gather loop for this net) */
-} /* if asoc.state OPEN */ no_data_fill:
+ } /* if asoc.state OPEN */
+no_data_fill:
/* Is there something to send for this destination? */
if (outchain) {
/* We may need to start a control timer or two */
@@ -8788,8 +8843,8 @@ again_one_more_time:
SCTP_STAT_INCR(sctps_lowlevelerrusr);
}
if (error == ENOBUFS) {
- SCTP_STAT_INCR(sctps_lowlevelerr);
asoc->ifp_had_enobuf = 1;
+ SCTP_STAT_INCR(sctps_lowlevelerr);
}
if (error == EHOSTUNREACH) {
/*
@@ -8912,7 +8967,7 @@ sctp_queue_op_err(struct sctp_tcb *stcb, struct mbuf *op_err)
return;
}
chk->copy_by_ref = 0;
- chk->send_size = (uint16_t) chunk_length;
+ chk->send_size = (uint16_t)chunk_length;
chk->sent = SCTP_DATAGRAM_UNSENT;
chk->snd_count = 0;
chk->asoc = &stcb->asoc;
@@ -9166,40 +9221,61 @@ sctp_send_shutdown(struct sctp_tcb *stcb, struct sctp_nets *net)
struct sctp_shutdown_chunk *shutdown_cp;
struct sctp_tmit_chunk *chk;
- m_shutdown = sctp_get_mbuf_for_msg(sizeof(struct sctp_shutdown_chunk), 0, M_NOWAIT, 1, MT_HEADER);
- if (m_shutdown == NULL) {
- /* no mbuf's */
- return;
+ TAILQ_FOREACH(chk, &stcb->asoc.control_send_queue, sctp_next) {
+ if (chk->rec.chunk_id.id == SCTP_SHUTDOWN) {
+ /* We already have a SHUTDOWN queued. Reuse it. */
+ if (chk->whoTo) {
+ sctp_free_remote_addr(chk->whoTo);
+ chk->whoTo = NULL;
+ }
+ break;
+ }
}
- SCTP_BUF_RESV_UF(m_shutdown, SCTP_MIN_OVERHEAD);
- sctp_alloc_a_chunk(stcb, chk);
if (chk == NULL) {
- /* no memory */
- sctp_m_freem(m_shutdown);
- return;
- }
- chk->copy_by_ref = 0;
- chk->rec.chunk_id.id = SCTP_SHUTDOWN;
- chk->rec.chunk_id.can_take_data = 1;
- chk->flags = 0;
- chk->send_size = sizeof(struct sctp_shutdown_chunk);
- chk->sent = SCTP_DATAGRAM_UNSENT;
- chk->snd_count = 0;
- chk->flags = 0;
- chk->asoc = &stcb->asoc;
- chk->data = m_shutdown;
- chk->whoTo = net;
- if (chk->whoTo) {
- atomic_add_int(&chk->whoTo->ref_count, 1);
+ m_shutdown = sctp_get_mbuf_for_msg(sizeof(struct sctp_shutdown_chunk), 0, M_NOWAIT, 1, MT_HEADER);
+ if (m_shutdown == NULL) {
+ /* no mbuf's */
+ return;
+ }
+ SCTP_BUF_RESV_UF(m_shutdown, SCTP_MIN_OVERHEAD);
+ sctp_alloc_a_chunk(stcb, chk);
+ if (chk == NULL) {
+ /* no memory */
+ sctp_m_freem(m_shutdown);
+ return;
+ }
+ chk->copy_by_ref = 0;
+ chk->rec.chunk_id.id = SCTP_SHUTDOWN;
+ chk->rec.chunk_id.can_take_data = 1;
+ chk->flags = 0;
+ chk->send_size = sizeof(struct sctp_shutdown_chunk);
+ chk->sent = SCTP_DATAGRAM_UNSENT;
+ chk->snd_count = 0;
+ chk->flags = 0;
+ chk->asoc = &stcb->asoc;
+ chk->data = m_shutdown;
+ chk->whoTo = net;
+ if (chk->whoTo) {
+ atomic_add_int(&chk->whoTo->ref_count, 1);
+ }
+ shutdown_cp = mtod(m_shutdown, struct sctp_shutdown_chunk *);
+ shutdown_cp->ch.chunk_type = SCTP_SHUTDOWN;
+ shutdown_cp->ch.chunk_flags = 0;
+ shutdown_cp->ch.chunk_length = htons(chk->send_size);
+ shutdown_cp->cumulative_tsn_ack = htonl(stcb->asoc.cumulative_tsn);
+ SCTP_BUF_LEN(m_shutdown) = chk->send_size;
+ TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
+ chk->asoc->ctrl_queue_cnt++;
+ } else {
+ TAILQ_REMOVE(&stcb->asoc.control_send_queue, chk, sctp_next);
+ chk->whoTo = net;
+ if (chk->whoTo) {
+ atomic_add_int(&chk->whoTo->ref_count, 1);
+ }
+ shutdown_cp = mtod(chk->data, struct sctp_shutdown_chunk *);
+ shutdown_cp->cumulative_tsn_ack = htonl(stcb->asoc.cumulative_tsn);
+ TAILQ_INSERT_TAIL(&stcb->asoc.control_send_queue, chk, sctp_next);
}
- shutdown_cp = mtod(m_shutdown, struct sctp_shutdown_chunk *);
- shutdown_cp->ch.chunk_type = SCTP_SHUTDOWN;
- shutdown_cp->ch.chunk_flags = 0;
- shutdown_cp->ch.chunk_length = htons(chk->send_size);
- shutdown_cp->cumulative_tsn_ack = htonl(stcb->asoc.cumulative_tsn);
- SCTP_BUF_LEN(m_shutdown) = chk->send_size;
- TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next);
- chk->asoc->ctrl_queue_cnt++;
return;
}
@@ -9455,8 +9531,14 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp,
chk->whoTo->port, NULL,
0, 0,
so_locked))) {
- SCTP_STAT_INCR(sctps_lowlevelerr);
+ SCTPDBG(SCTP_DEBUG_OUTPUT3, "Gak send error %d\n", error);
+ if (error == ENOBUFS) {
+ asoc->ifp_had_enobuf = 1;
+ SCTP_STAT_INCR(sctps_lowlevelerr);
+ }
return (error);
+ } else {
+ asoc->ifp_had_enobuf = 0;
}
endofchain = NULL;
auth = NULL;
@@ -9672,8 +9754,10 @@ one_chunk_around:
auth_keyid = fwd->auth_keyid;
override_ok = 0;
} else if (fwd->auth_keyid != auth_keyid) {
- /* different keyid,
- * so done bundling */
+ /*
+ * different keyid,
+ * so done bundling
+ */
break;
}
}
@@ -9725,8 +9809,14 @@ one_chunk_around:
0, 0,
so_locked))) {
/* error, we could not output */
- SCTP_STAT_INCR(sctps_lowlevelerr);
+ SCTPDBG(SCTP_DEBUG_OUTPUT3, "Gak send error %d\n", error);
+ if (error == ENOBUFS) {
+ asoc->ifp_had_enobuf = 1;
+ SCTP_STAT_INCR(sctps_lowlevelerr);
+ }
return (error);
+ } else {
+ asoc->ifp_had_enobuf = 0;
}
endofchain = NULL;
auth = NULL;
@@ -9795,14 +9885,14 @@ one_chunk_around:
asoc->peers_rwnd, data_list[i]->send_size, SCTP_BASE_SYSCTL(sctp_peer_chunk_oh));
}
asoc->peers_rwnd = sctp_sbspace_sub(asoc->peers_rwnd,
- (uint32_t) (data_list[i]->send_size +
+ (uint32_t)(data_list[i]->send_size +
SCTP_BASE_SYSCTL(sctp_peer_chunk_oh)));
}
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FLIGHT_LOGGING_ENABLE) {
sctp_misc_ints(SCTP_FLIGHT_LOG_UP_RSND,
data_list[i]->whoTo->flight_size,
data_list[i]->book_size,
- (uint32_t) (uintptr_t) data_list[i]->whoTo,
+ (uint32_t)(uintptr_t)data_list[i]->whoTo,
data_list[i]->rec.data.tsn);
}
sctp_flight_size_increase(data_list[i]);
@@ -10049,9 +10139,11 @@ do_it_again:
if (asoc->max_burst > 0) {
if (SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst)) {
if ((net->flight_size + (asoc->max_burst * net->mtu)) < net->cwnd) {
- /* JRS - Use the congestion
+ /*
+ * JRS - Use the congestion
* control given in the
- * congestion control module */
+ * congestion control module
+ */
asoc->cc_functions.sctp_cwnd_update_after_output(stcb, net, asoc->max_burst);
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOG_MAXBURST_ENABLE) {
sctp_log_maxburst(stcb, net, 0, asoc->max_burst, SCTP_MAX_BURST_APPLIED);
@@ -10061,8 +10153,10 @@ do_it_again:
net->fast_retran_ip = 0;
} else {
if (net->flight_size == 0) {
- /* Should be decaying the
- * cwnd here */
+ /*
+ * Should be decaying the
+ * cwnd here
+ */
;
}
}
@@ -10392,7 +10486,7 @@ sctp_fill_in_rest:
strseq_m++;
} else {
strseq->sid = htons(at->rec.data.sid);
- strseq->ssn = htons((uint16_t) at->rec.data.mid);
+ strseq->ssn = htons((uint16_t)at->rec.data.mid);
strseq++;
}
i++;
@@ -10747,7 +10841,7 @@ sctp_send_sack(struct sctp_tcb *stcb, int so_locked
}
/* now we must add any dups we are going to report. */
if ((limit_reached == 0) && (asoc->numduptsns)) {
- dup = (uint32_t *) gap_descriptor;
+ dup = (uint32_t *)gap_descriptor;
for (i = 0; i < asoc->numduptsns; i++) {
*dup = htonl(asoc->dup_tsns[i]);
dup++;
@@ -10764,7 +10858,7 @@ sctp_send_sack(struct sctp_tcb *stcb, int so_locked
* queue.
*/
if (type == SCTP_SELECTIVE_ACK) {
- a_chk->send_size = (uint16_t) (sizeof(struct sctp_sack_chunk) +
+ a_chk->send_size = (uint16_t)(sizeof(struct sctp_sack_chunk) +
(num_gap_blocks + num_nr_gap_blocks) * sizeof(struct sctp_gap_ack_block) +
num_dups * sizeof(int32_t));
SCTP_BUF_LEN(a_chk->data) = a_chk->send_size;
@@ -10776,7 +10870,7 @@ sctp_send_sack(struct sctp_tcb *stcb, int so_locked
sack->ch.chunk_flags = flags;
sack->ch.chunk_length = htons(a_chk->send_size);
} else {
- a_chk->send_size = (uint16_t) (sizeof(struct sctp_nr_sack_chunk) +
+ a_chk->send_size = (uint16_t)(sizeof(struct sctp_nr_sack_chunk) +
(num_gap_blocks + num_nr_gap_blocks) * sizeof(struct sctp_gap_ack_block) +
num_dups * sizeof(int32_t));
SCTP_BUF_LEN(a_chk->data) = a_chk->send_size;
@@ -10812,6 +10906,7 @@ sctp_send_abort_tcb(struct sctp_tcb *stcb, struct mbuf *operr, int so_locked
struct sctp_nets *net;
uint32_t vtag;
uint32_t auth_offset = 0;
+ int error;
uint16_t cause_len, chunk_len, padding_len;
SCTP_TCB_LOCK_ASSERT(stcb);
@@ -10842,13 +10937,13 @@ sctp_send_abort_tcb(struct sctp_tcb *stcb, struct mbuf *operr, int so_locked
cause_len = 0;
m_last = NULL;
for (m = operr; m; m = SCTP_BUF_NEXT(m)) {
- cause_len += (uint16_t) SCTP_BUF_LEN(m);
+ cause_len += (uint16_t)SCTP_BUF_LEN(m);
if (SCTP_BUF_NEXT(m) == NULL) {
m_last = m;
}
}
SCTP_BUF_LEN(m_abort) = sizeof(struct sctp_abort_chunk);
- chunk_len = (uint16_t) sizeof(struct sctp_abort_chunk) + cause_len;
+ chunk_len = (uint16_t)sizeof(struct sctp_abort_chunk) + cause_len;
padding_len = SCTP_SIZE32(chunk_len) - chunk_len;
if (m_out == NULL) {
/* NO Auth chunk prepended, so reserve space in front */
@@ -10883,13 +10978,21 @@ sctp_send_abort_tcb(struct sctp_tcb *stcb, struct mbuf *operr, int so_locked
return;
}
}
- (void)sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
+ if ((error = sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
(struct sockaddr *)&net->ro._l_addr,
m_out, auth_offset, auth, stcb->asoc.authinfo.active_keyid, 1, 0, 0,
stcb->sctp_ep->sctp_lport, stcb->rport, htonl(vtag),
stcb->asoc.primary_destination->port, NULL,
0, 0,
- so_locked);
+ so_locked))) {
+ SCTPDBG(SCTP_DEBUG_OUTPUT3, "Gak send error %d\n", error);
+ if (error == ENOBUFS) {
+ stcb->asoc.ifp_had_enobuf = 1;
+ SCTP_STAT_INCR(sctps_lowlevelerr);
+ }
+ } else {
+ stcb->asoc.ifp_had_enobuf = 0;
+ }
SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
}
@@ -10902,6 +11005,7 @@ sctp_send_shutdown_complete(struct sctp_tcb *stcb,
struct mbuf *m_shutdown_comp;
struct sctp_shutdown_complete_chunk *shutdown_complete;
uint32_t vtag;
+ int error;
uint8_t flags;
m_shutdown_comp = sctp_get_mbuf_for_msg(sizeof(struct sctp_chunkhdr), 0, M_NOWAIT, 1, MT_HEADER);
@@ -10921,14 +11025,22 @@ sctp_send_shutdown_complete(struct sctp_tcb *stcb,
shutdown_complete->ch.chunk_flags = flags;
shutdown_complete->ch.chunk_length = htons(sizeof(struct sctp_shutdown_complete_chunk));
SCTP_BUF_LEN(m_shutdown_comp) = sizeof(struct sctp_shutdown_complete_chunk);
- (void)sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
+ if ((error = sctp_lowlevel_chunk_output(stcb->sctp_ep, stcb, net,
(struct sockaddr *)&net->ro._l_addr,
m_shutdown_comp, 0, NULL, 0, 1, 0, 0,
stcb->sctp_ep->sctp_lport, stcb->rport,
htonl(vtag),
net->port, NULL,
0, 0,
- SCTP_SO_NOT_LOCKED);
+ SCTP_SO_NOT_LOCKED))) {
+ SCTPDBG(SCTP_DEBUG_OUTPUT3, "Gak send error %d\n", error);
+ if (error == ENOBUFS) {
+ stcb->asoc.ifp_had_enobuf = 1;
+ SCTP_STAT_INCR(sctps_lowlevelerr);
+ }
+ } else {
+ stcb->asoc.ifp_had_enobuf = 0;
+ }
SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
return;
}
@@ -11081,7 +11193,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst,
udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port));
udp->uh_dport = port;
udp->uh_sum = 0;
- udp->uh_ulen = htons((uint16_t) (sizeof(struct udphdr) +
+ udp->uh_ulen = htons((uint16_t)(sizeof(struct udphdr) +
sizeof(struct sctphdr) +
sizeof(struct sctp_chunkhdr) +
cause_len + padding_len));
@@ -11107,7 +11219,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst,
} else {
ch->chunk_flags = SCTP_HAD_NO_TCB;
}
- ch->chunk_length = htons((uint16_t) (sizeof(struct sctp_chunkhdr) + cause_len));
+ ch->chunk_length = htons((uint16_t)(sizeof(struct sctp_chunkhdr) + cause_len));
len += sizeof(struct sctp_chunkhdr);
len += cause_len + padding_len;
@@ -11156,7 +11268,7 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst,
#endif
#ifdef INET6
case AF_INET6:
- ip6->ip6_plen = (uint16_t) (len - sizeof(struct ip6_hdr));
+ ip6->ip6_plen = (uint16_t)(len - sizeof(struct ip6_hdr));
if (port) {
#if defined(SCTP_WITH_NO_CSUM)
SCTP_STAT_INCR(sctps_sendnocrc);
@@ -11272,7 +11384,7 @@ sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets *net, int so_locked
hb->heartbeat.hb_info.time_value_1 = now.tv_sec;
hb->heartbeat.hb_info.time_value_2 = now.tv_usec;
/* Did our user request this one, put it in */
- hb->heartbeat.hb_info.addr_family = (uint8_t) net->ro._l_addr.sa.sa_family;
+ hb->heartbeat.hb_info.addr_family = (uint8_t)net->ro._l_addr.sa.sa_family;
hb->heartbeat.hb_info.addr_len = net->ro._l_addr.sa.sa_len;
if (net->dest_state & SCTP_ADDR_UNCONFIRMED) {
/*
@@ -11423,7 +11535,7 @@ sctp_send_packet_dropped(struct sctp_tcb *stcb, struct sctp_nets *net,
/* Validate that we do not have an ABORT in here. */
offset = iphlen + sizeof(struct sctphdr);
ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset,
- sizeof(*ch), (uint8_t *) & chunk_buf);
+ sizeof(*ch), (uint8_t *)&chunk_buf);
while (ch != NULL) {
chk_length = ntohs(ch->chunk_length);
if (chk_length < sizeof(*ch)) {
@@ -11447,7 +11559,7 @@ sctp_send_packet_dropped(struct sctp_tcb *stcb, struct sctp_nets *net,
}
offset += SCTP_SIZE32(chk_length);
ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset,
- sizeof(*ch), (uint8_t *) & chunk_buf);
+ sizeof(*ch), (uint8_t *)&chunk_buf);
}
if ((len + SCTP_MAX_OVERHEAD + sizeof(struct sctp_pktdrop_chunk)) >
@@ -11483,7 +11595,7 @@ jump_out:
* Len is already adjusted to size minus overhead above take
* out the pkt_drop chunk itself from it.
*/
- chk->send_size = (uint16_t) (len - sizeof(struct sctp_pktdrop_chunk));
+ chk->send_size = (uint16_t)(len - sizeof(struct sctp_pktdrop_chunk));
len = chk->send_size;
} else {
/* no truncation needed */
@@ -11544,8 +11656,10 @@ sctp_send_cwr(struct sctp_tcb *stcb, struct sctp_nets *net, uint32_t high_tsn, u
asoc = &stcb->asoc;
TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
if ((chk->rec.chunk_id.id == SCTP_ECN_CWR) && (net == chk->whoTo)) {
- /* found a previous CWR queued to same destination
- * update it if needed */
+ /*
+ * found a previous CWR queued to same destination
+ * update it if needed
+ */
uint32_t ctsn;
cwr = mtod(chk->data, struct sctp_cwr_chunk *);
@@ -11621,7 +11735,7 @@ sctp_add_stream_reset_out(struct sctp_tcb *stcb, struct sctp_tmit_chunk *chk,
if (number_entries > SCTP_MAX_STREAMS_AT_ONCE_RESET) {
number_entries = SCTP_MAX_STREAMS_AT_ONCE_RESET;
}
- len = (uint16_t) (sizeof(struct sctp_stream_reset_out_request) + (sizeof(uint16_t) * number_entries));
+ len = (uint16_t)(sizeof(struct sctp_stream_reset_out_request) + (sizeof(uint16_t) * number_entries));
req_out->ph.param_type = htons(SCTP_STR_RESET_OUT_REQUEST);
req_out->ph.param_length = htons(len);
req_out->request_seq = htonl(seq);
@@ -11665,7 +11779,7 @@ sctp_add_stream_reset_out(struct sctp_tcb *stcb, struct sctp_tmit_chunk *chk,
static void
sctp_add_stream_reset_in(struct sctp_tmit_chunk *chk,
- int number_entries, uint16_t * list,
+ int number_entries, uint16_t *list,
uint32_t seq)
{
uint16_t len, old_len, i;
@@ -11678,7 +11792,7 @@ sctp_add_stream_reset_in(struct sctp_tmit_chunk *chk,
/* get to new offset for the param. */
req_in = (struct sctp_stream_reset_in_request *)((caddr_t)ch + len);
/* now how long will this param be? */
- len = (uint16_t) (sizeof(struct sctp_stream_reset_in_request) + (sizeof(uint16_t) * number_entries));
+ len = (uint16_t)(sizeof(struct sctp_stream_reset_in_request) + (sizeof(uint16_t) * number_entries));
req_in->ph.param_type = htons(SCTP_STR_RESET_IN_REQUEST);
req_in->ph.param_length = htons(len);
req_in->request_seq = htonl(seq);
@@ -11994,7 +12108,7 @@ sctp_send_stream_reset_out_if_possible(struct sctp_tcb *stcb, int so_locked)
int
sctp_send_str_reset_req(struct sctp_tcb *stcb,
- uint16_t number_entries, uint16_t * list,
+ uint16_t number_entries, uint16_t *list,
uint8_t send_in_req,
uint8_t send_tsn_req,
uint8_t add_stream,
@@ -12122,8 +12236,10 @@ sctp_send_str_reset_req(struct sctp_tcb *stcb,
stcb->asoc.strmout[i].sid = i;
stcb->asoc.strmout[i].state = oldstream[i].state;
/* FIX ME FIX ME */
- /* This should be a SS_COPY operation FIX ME STREAM
- * SCHEDULER EXPERT */
+ /*
+ * This should be a SS_COPY operation FIX ME STREAM
+ * SCHEDULER EXPERT
+ */
stcb->asoc.ss_functions.sctp_ss_init_stream(stcb, &stcb->asoc.strmout[i], &oldstream[i]);
/* now anything on those queues? */
TAILQ_FOREACH_SAFE(sp, &oldstream[i].outqueue, next, nsp) {
@@ -12227,7 +12343,7 @@ sctp_copy_resume(struct uio *uio,
int max_send_len,
int user_marks_eor,
int *error,
- uint32_t * sndout,
+ uint32_t *sndout,
struct mbuf **new_tail)
{
struct mbuf *m;
@@ -12308,8 +12424,8 @@ sctp_copy_it_in(struct sctp_tcb *stcb,
(void)SCTP_GETTIME_TIMEVAL(&sp->ts);
sp->sid = srcv->sinfo_stream;
- sp->length = (uint32_t) min(uio->uio_resid, max_send_len);
- if ((sp->length == (uint32_t) uio->uio_resid) &&
+ sp->length = (uint32_t)min(uio->uio_resid, max_send_len);
+ if ((sp->length == (uint32_t)uio->uio_resid) &&
((user_marks_eor == 0) ||
(srcv->sinfo_flags & SCTP_EOF) ||
(user_marks_eor && (srcv->sinfo_flags & SCTP_EOR)))) {
@@ -12653,8 +12769,10 @@ sctp_lower_sosend(struct socket *so,
}
if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) {
stcb->sctp_ep->sctp_flags |= SCTP_PCB_FLAGS_CONNECTED;
- /* Set the connected flag so we can queue
- * data */
+ /*
+ * Set the connected flag so we can queue
+ * data
+ */
soisconnecting(so);
}
hold_tcblock = 1;
@@ -12664,8 +12782,10 @@ sctp_lower_sosend(struct socket *so,
} else {
SCTP_PRINTF("Huh-3? create lock should have been on??\n");
}
- /* Turn on queue only flag to prevent data from
- * being sent */
+ /*
+ * Turn on queue only flag to prevent data from
+ * being sent
+ */
queue_only = 1;
asoc = &stcb->asoc;
SCTP_SET_STATE(asoc, SCTP_STATE_COOKIE_WAIT);
@@ -12865,7 +12985,7 @@ sctp_lower_sosend(struct socket *so,
/* now move forward the data pointer */
ph = mtod(mm, struct sctp_paramhdr *);
ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT);
- ph->param_length = htons((uint16_t) (sizeof(struct sctp_paramhdr) + tot_out));
+ ph->param_length = htons((uint16_t)(sizeof(struct sctp_paramhdr) + tot_out));
ph++;
SCTP_BUF_LEN(mm) = tot_out + sizeof(struct sctp_paramhdr);
if (top == NULL) {
@@ -13160,8 +13280,10 @@ skip_preblock:
}
/* PR-SCTP? */
if ((asoc->prsctp_supported) && (asoc->sent_queue_cnt_removeable > 0)) {
- /* This is ugly but we must assure locking
- * order */
+ /*
+ * This is ugly but we must assure locking
+ * order
+ */
if (hold_tcblock == 0) {
SCTP_TCB_LOCK(stcb);
hold_tcblock = 1;
@@ -13438,8 +13560,10 @@ dataless_eof:
msg);
sctp_abort_an_association(stcb->sctp_ep, stcb,
op_err, SCTP_SO_LOCKED);
- /* now relock the stcb so everything
- * is sane */
+ /*
+ * now relock the stcb so everything
+ * is sane
+ */
hold_tcblock = 0;
stcb = NULL;
goto out;
@@ -13513,8 +13637,10 @@ skip_out_eof:
if ((queue_only == 0) && (nagle_applies == 0) && (stcb->asoc.peers_rwnd && un_sent)) {
/* we can attempt to send too. */
if (hold_tcblock == 0) {
- /* If there is activity recv'ing sacks no need to
- * send */
+ /*
+ * If there is activity recv'ing sacks no need to
+ * send
+ */
if (SCTP_TCB_TRYLOCK(stcb)) {
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_USR_SEND, SCTP_SO_LOCKED);
hold_tcblock = 1;
@@ -13588,7 +13714,7 @@ out_unlocked:
*/
struct mbuf *
sctp_add_auth_chunk(struct mbuf *m, struct mbuf **m_end,
- struct sctp_auth_chunk **auth_ret, uint32_t * offset,
+ struct sctp_auth_chunk **auth_ret, uint32_t *offset,
struct sctp_tcb *stcb, uint8_t chunk)
{
struct mbuf *m_auth;
@@ -13643,7 +13769,7 @@ sctp_add_auth_chunk(struct mbuf *m, struct mbuf **m_end,
#ifdef INET6
int
-sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t * ro)
+sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro)
{
struct nd_prefix *pfx = NULL;
struct nd_pfxrouter *pfxrtr = NULL;
@@ -13695,7 +13821,7 @@ sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t * ro)
#endif
int
-sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t * ro)
+sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro)
{
#ifdef INET
struct sockaddr_in *sin, *mask;
diff --git a/freebsd/sys/netinet/sctp_output.h b/freebsd/sys/netinet/sctp_output.h
index b2441a6f..cd90b7d7 100644
--- a/freebsd/sys/netinet/sctp_output.h
+++ b/freebsd/sys/netinet/sctp_output.h
@@ -47,7 +47,7 @@ sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp,
struct sctp_scoping *scope,
struct mbuf *m_at,
int cnt_inits_to,
- uint16_t * padding_len, uint16_t * chunk_len);
+ uint16_t *padding_len, uint16_t *chunk_len);
int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
@@ -64,13 +64,13 @@ int
struct sctp_ifa *
sctp_source_address_selection(struct sctp_inpcb *inp,
struct sctp_tcb *stcb,
- sctp_route_t * ro, struct sctp_nets *net,
+ sctp_route_t *ro, struct sctp_nets *net,
int non_asoc_addr_ok, uint32_t vrf_id);
int
- sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t * ro);
+ sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro);
int
- sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t * ro);
+ sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro);
void
sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int
diff --git a/freebsd/sys/netinet/sctp_pcb.c b/freebsd/sys/netinet/sctp_pcb.c
index ca86a139..4cd7bf0b 100644
--- a/freebsd/sys/netinet/sctp_pcb.c
+++ b/freebsd/sys/netinet/sctp_pcb.c
@@ -1214,8 +1214,10 @@ sctp_tcb_special_locate(struct sctp_inpcb **inp_p, struct sockaddr *from,
if (netp != NULL) {
*netp = net;
}
- /* Update the endpoint
- * pointer */
+ /*
+ * Update the endpoint
+ * pointer
+ */
*inp_p = inp;
SCTP_INP_RUNLOCK(inp);
return (stcb);
@@ -1236,8 +1238,10 @@ sctp_tcb_special_locate(struct sctp_inpcb **inp_p, struct sockaddr *from,
if (netp != NULL) {
*netp = net;
}
- /* Update the endpoint
- * pointer */
+ /*
+ * Update the endpoint
+ * pointer
+ */
*inp_p = inp;
SCTP_INP_RUNLOCK(inp);
return (stcb);
@@ -1565,7 +1569,7 @@ sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int
SCTP_PRINTF("TSNH ep_associd0\n");
return (NULL);
}
- id = (uint32_t) asoc_id;
+ id = (uint32_t)asoc_id;
head = &inp->sctp_asocidhash[SCTP_PCBHASH_ASOC(id, inp->hashasocidmark)];
if (head == NULL) {
/* invalid id TSNH */
@@ -1664,8 +1668,10 @@ sctp_endpoint_probe(struct sockaddr *nam, struct sctppcbhead *head,
case AF_INET:
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
SCTP_IPV6_V6ONLY(inp)) {
- /* IPv4 on a IPv6 socket with ONLY
- * IPv6 set */
+ /*
+ * IPv4 on a IPv6 socket with ONLY
+ * IPv6 set
+ */
SCTP_INP_RUNLOCK(inp);
continue;
}
@@ -1678,8 +1684,10 @@ sctp_endpoint_probe(struct sockaddr *nam, struct sctppcbhead *head,
#endif
#ifdef INET6
case AF_INET6:
- /* A V6 address and the endpoint is NOT
- * bound V6 */
+ /*
+ * A V6 address and the endpoint is NOT
+ * bound V6
+ */
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) {
SCTP_INP_RUNLOCK(inp);
continue;
@@ -2177,8 +2185,10 @@ sctp_findassoc_by_vtag(struct sockaddr *from, struct sockaddr *to, uint32_t vtag
continue;
}
if (remote_tag) {
- /* If we have both vtags that's all we match
- * on */
+ /*
+ * If we have both vtags that's all we match
+ * on
+ */
if (stcb->asoc.peer_vtag == remote_tag) {
/*
* If both tags match we consider it
@@ -2311,7 +2321,7 @@ sctp_findassociation_ep_asconf(struct mbuf *m, int offset,
__func__);
return NULL;
}
- ptype = (int)((uint32_t) ntohs(phdr->param_type));
+ ptype = (int)((uint32_t)ntohs(phdr->param_type));
/* get the correlation address */
switch (ptype) {
#ifdef INET6
@@ -2443,13 +2453,13 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)
inp->sctp_frag_point = SCTP_DEFAULT_MAXSEGMENT;
inp->max_cwnd = 0;
inp->sctp_cmt_on_off = SCTP_BASE_SYSCTL(sctp_cmt_on_off);
- inp->ecn_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_ecn_enable);
- inp->prsctp_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_pr_enable);
- inp->auth_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_auth_enable);
- inp->asconf_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_asconf_enable);
- inp->reconfig_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_reconfig_enable);
- inp->nrsack_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_nrsack_enable);
- inp->pktdrop_supported = (uint8_t) SCTP_BASE_SYSCTL(sctp_pktdrop_enable);
+ inp->ecn_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_ecn_enable);
+ inp->prsctp_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_pr_enable);
+ inp->auth_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_auth_enable);
+ inp->asconf_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_asconf_enable);
+ inp->reconfig_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_reconfig_enable);
+ inp->nrsack_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_nrsack_enable);
+ inp->pktdrop_supported = (uint8_t)SCTP_BASE_SYSCTL(sctp_pktdrop_enable);
inp->idata_supported = 0;
inp->fibnum = so->so_fibnum;
@@ -2871,8 +2881,10 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
#ifdef INET6
case AF_INET6:
{
- /* Only for pure IPv6 Address. (No IPv4
- * Mapped!) */
+ /*
+ * Only for pure IPv6 Address. (No IPv4
+ * Mapped!)
+ */
struct sockaddr_in6 *sin6;
sin6 = (struct sockaddr_in6 *)addr;
@@ -2949,8 +2961,10 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
/* unlock info */
if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
(sctp_is_feature_on(inp_tmp, SCTP_PCB_FLAGS_PORTREUSE))) {
- /* Ok, must be one-2-one and
- * allowing port re-use */
+ /*
+ * Ok, must be one-2-one and
+ * allowing port re-use
+ */
port_reuse_active = 1;
goto continue_anyway;
}
@@ -2973,8 +2987,10 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
/* unlock info */
if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) &&
(sctp_is_feature_on(inp_tmp, SCTP_PCB_FLAGS_PORTREUSE))) {
- /* Ok, must be one-2-one and
- * allowing port re-use */
+ /*
+ * Ok, must be one-2-one and
+ * allowing port re-use
+ */
port_reuse_active = 1;
goto continue_anyway;
}
@@ -3273,8 +3289,10 @@ sctp_iterator_inp_being_freed(struct sctp_inpcb *inp)
SCTP_INP_INCR_REF(it->inp);
}
}
- /* When its put in the refcnt is incremented so decr
- * it */
+ /*
+ * When its put in the refcnt is incremented so decr
+ * it
+ */
SCTP_INP_DECR_REF(inp);
}
}
@@ -3933,7 +3951,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
sin6->sin6_scope_id = 0;
}
#endif
- SCTP_RTALLOC((sctp_route_t *) & net->ro,
+ SCTP_RTALLOC((sctp_route_t *)&net->ro,
stcb->asoc.vrf_id,
stcb->sctp_ep->fibnum);
@@ -3941,7 +3959,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
/* Get source address */
net->ro._s_addr = sctp_source_address_selection(stcb->sctp_ep,
stcb,
- (sctp_route_t *) & net->ro,
+ (sctp_route_t *)&net->ro,
net,
0,
stcb->asoc.vrf_id);
@@ -3959,8 +3977,10 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
rmtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, net->ro.ro_rt);
if (rmtu == 0) {
- /* Start things off to match mtu of
- * interface please. */
+ /*
+ * Start things off to match mtu of
+ * interface please.
+ */
SCTP_SET_MTU_OF_ROUTE(&net->ro._l_addr.sa,
net->ro.ro_rt, net->mtu);
} else {
@@ -3993,7 +4013,7 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
}
#if defined(INET) || defined(INET6)
if (net->port) {
- net->mtu -= (uint32_t) sizeof(struct udphdr);
+ net->mtu -= (uint32_t)sizeof(struct udphdr);
}
#endif
if (from == SCTP_ALLOC_ASOC) {
@@ -4127,7 +4147,7 @@ try_again:
}
id = inp->sctp_associd_counter;
inp->sctp_associd_counter++;
- lstcb = sctp_findasoc_ep_asocid_locked(inp, (sctp_assoc_t) id, 0);
+ lstcb = sctp_findasoc_ep_asocid_locked(inp, (sctp_assoc_t)id, 0);
if (lstcb) {
goto try_again;
}
@@ -5451,8 +5471,10 @@ sctp_del_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa)
if (stcb->asoc.last_used_address == laddr)
/* delete this address */
stcb->asoc.last_used_address = NULL;
- /* Now spin through all the nets and purge any ref
- * to laddr */
+ /*
+ * Now spin through all the nets and purge any ref
+ * to laddr
+ */
TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
if (net->ro._s_addr == laddr->ifa) {
/* Yep, purge src address selected */
@@ -5749,12 +5771,12 @@ sctp_pcb_init()
(void)SCTP_GETTIME_TIMEVAL(&tv);
#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
bzero(SCTP_BASE_STATS, (sizeof(struct sctpstat) * (mp_maxid + 1)));
- SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_sec = (uint32_t) tv.tv_sec;
- SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_usec = (uint32_t) tv.tv_usec;
+ SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_sec = (uint32_t)tv.tv_sec;
+ SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_usec = (uint32_t)tv.tv_usec;
#else
bzero(&SCTP_BASE_STATS, sizeof(struct sctpstat));
- SCTP_BASE_STAT(sctps_discontinuitytime).tv_sec = (uint32_t) tv.tv_sec;
- SCTP_BASE_STAT(sctps_discontinuitytime).tv_usec = (uint32_t) tv.tv_usec;
+ SCTP_BASE_STAT(sctps_discontinuitytime).tv_sec = (uint32_t)tv.tv_sec;
+ SCTP_BASE_STAT(sctps_discontinuitytime).tv_usec = (uint32_t)tv.tv_usec;
#endif
/* init the empty list of (All) Endpoints */
LIST_INIT(&SCTP_BASE_INFO(listhead));
@@ -6228,8 +6250,10 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
struct mbuf *op_err;
char msg[SCTP_DIAG_INFO_LEN];
- /* in setup state we
- * abort this guy */
+ /*
+ * in setup state we
+ * abort this guy
+ */
snprintf(msg, sizeof(msg),
"%s:%d at %s", __FILE__, __LINE__, __func__);
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
@@ -6271,8 +6295,10 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
goto next_param;
}
if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr)) {
- /* Link local make no sense without
- * scope */
+ /*
+ * Link local make no sense without
+ * scope
+ */
goto next_param;
}
sa = (struct sockaddr *)&sin6;
@@ -6323,8 +6349,10 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
struct mbuf *op_err;
char msg[SCTP_DIAG_INFO_LEN];
- /* in setup state we
- * abort this guy */
+ /*
+ * in setup state we
+ * abort this guy
+ */
snprintf(msg, sizeof(msg),
"%s:%d at %s", __FILE__, __LINE__, __func__);
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
diff --git a/freebsd/sys/netinet/sctp_pcb.h b/freebsd/sys/netinet/sctp_pcb.h
index a2a1e7d7..86fae1f4 100644
--- a/freebsd/sys/netinet/sctp_pcb.h
+++ b/freebsd/sys/netinet/sctp_pcb.h
@@ -379,8 +379,10 @@ struct sctp_inpcb {
/* list of addrs in use by the EP, NULL if bound-all */
struct sctpladdr sctp_addr_list;
- /* used for source address selection rotation when we are subset
- * bound */
+ /*
+ * used for source address selection rotation when we are subset
+ * bound
+ */
struct sctp_laddr *next_addr_touse;
/* back pointer to our socket */
diff --git a/freebsd/sys/netinet/sctp_structs.h b/freebsd/sys/netinet/sctp_structs.h
index 22a3c736..f7371748 100644
--- a/freebsd/sys/netinet/sctp_structs.h
+++ b/freebsd/sys/netinet/sctp_structs.h
@@ -715,7 +715,7 @@ struct sctp_cc_functions {
struct sctp_nets *net, int in_window, int num_pkt_lost);
void (*sctp_cwnd_update_after_packet_dropped) (struct sctp_tcb *stcb,
struct sctp_nets *net, struct sctp_pktdrop_chunk *cp,
- uint32_t * bottle_bw, uint32_t * on_queue);
+ uint32_t *bottle_bw, uint32_t *on_queue);
void (*sctp_cwnd_update_after_output) (struct sctp_tcb *stcb,
struct sctp_nets *net, int burst_limit);
void (*sctp_cwnd_update_packet_transmitted) (struct sctp_tcb *stcb,
@@ -752,7 +752,7 @@ struct sctp_ss_functions {
void (*sctp_ss_packet_done) (struct sctp_tcb *stcb, struct sctp_nets *net,
struct sctp_association *asoc);
int (*sctp_ss_get_value) (struct sctp_tcb *stcb, struct sctp_association *asoc,
- struct sctp_stream_out *strq, uint16_t * value);
+ struct sctp_stream_out *strq, uint16_t *value);
int (*sctp_ss_set_value) (struct sctp_tcb *stcb, struct sctp_association *asoc,
struct sctp_stream_out *strq, uint16_t value);
int (*sctp_ss_is_user_msgs_incomplete) (struct sctp_tcb *stcb, struct sctp_association *asoc);
@@ -881,8 +881,10 @@ struct sctp_association {
/* JRS - the congestion control functions are in this struct */
struct sctp_cc_functions cc_functions;
- /* JRS - value to store the currently loaded congestion control
- * module */
+ /*
+ * JRS - value to store the currently loaded congestion control
+ * module
+ */
uint32_t congestion_control_module;
/* RS - the stream scheduling functions are in this struct */
struct sctp_ss_functions ss_functions;
diff --git a/freebsd/sys/netinet/sctp_sysctl.c b/freebsd/sys/netinet/sctp_sysctl.c
index 152a2996..ea3b3d9c 100644
--- a/freebsd/sys/netinet/sctp_sysctl.c
+++ b/freebsd/sys/netinet/sctp_sysctl.c
@@ -312,8 +312,8 @@ sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *st
continue;
memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore));
- xladdr.start_time.tv_sec = (uint32_t) laddr->start_time.tv_sec;
- xladdr.start_time.tv_usec = (uint32_t) laddr->start_time.tv_usec;
+ xladdr.start_time.tv_sec = (uint32_t)laddr->start_time.tv_sec;
+ xladdr.start_time.tv_usec = (uint32_t)laddr->start_time.tv_usec;
SCTP_INP_RUNLOCK(inp);
SCTP_INP_INFO_RUNLOCK();
error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
@@ -418,10 +418,10 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS)
} else {
xinpcb.qlen = so->so_qlen;
xinpcb.qlen_old = so->so_qlen > USHRT_MAX ?
- USHRT_MAX : (uint16_t) so->so_qlen;
+ USHRT_MAX : (uint16_t)so->so_qlen;
xinpcb.maxqlen = so->so_qlimit;
xinpcb.maxqlen_old = so->so_qlimit > USHRT_MAX ?
- USHRT_MAX : (uint16_t) so->so_qlimit;
+ USHRT_MAX : (uint16_t)so->so_qlimit;
}
SCTP_INP_INCR_REF(inp);
SCTP_INP_RUNLOCK(inp);
@@ -448,7 +448,7 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS)
if (stcb->asoc.primary_destination != NULL)
xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr;
xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay;
- xstcb.state = (uint32_t) sctp_map_assoc_state(stcb->asoc.state);
+ xstcb.state = (uint32_t)sctp_map_assoc_state(stcb->asoc.state);
/* 7.0 does not support these */
xstcb.assoc_id = sctp_get_associd(stcb);
xstcb.peers_rwnd = stcb->asoc.peers_rwnd;
@@ -460,10 +460,10 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS)
xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie;
xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack;
xstcb.retransmitted_tsns = stcb->asoc.marked_retrans;
- xstcb.start_time.tv_sec = (uint32_t) stcb->asoc.start_time.tv_sec;
- xstcb.start_time.tv_usec = (uint32_t) stcb->asoc.start_time.tv_usec;
- xstcb.discontinuity_time.tv_sec = (uint32_t) stcb->asoc.discontinuity_time.tv_sec;
- xstcb.discontinuity_time.tv_usec = (uint32_t) stcb->asoc.discontinuity_time.tv_usec;
+ xstcb.start_time.tv_sec = (uint32_t)stcb->asoc.start_time.tv_sec;
+ xstcb.start_time.tv_usec = (uint32_t)stcb->asoc.start_time.tv_usec;
+ xstcb.discontinuity_time.tv_sec = (uint32_t)stcb->asoc.discontinuity_time.tv_sec;
+ xstcb.discontinuity_time.tv_usec = (uint32_t)stcb->asoc.discontinuity_time.tv_usec;
xstcb.total_sends = stcb->total_sends;
xstcb.total_recvs = stcb->total_recvs;
xstcb.local_tag = stcb->asoc.my_vtag;
@@ -507,8 +507,8 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS)
xraddr.rtt = net->rtt / 1000;
xraddr.heartbeat_interval = net->heart_beat_delay;
xraddr.ssthresh = net->ssthresh;
- xraddr.start_time.tv_sec = (uint32_t) net->start_time.tv_sec;
- xraddr.start_time.tv_usec = (uint32_t) net->start_time.tv_usec;
+ xraddr.start_time.tv_sec = (uint32_t)net->start_time.tv_sec;
+ xraddr.start_time.tv_usec = (uint32_t)net->start_time.tv_usec;
SCTP_INP_RUNLOCK(inp);
SCTP_INP_INFO_RUNLOCK();
error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
diff --git a/freebsd/sys/netinet/sctp_timer.c b/freebsd/sys/netinet/sctp_timer.c
index 2d427e48..6b4b0be0 100644
--- a/freebsd/sys/netinet/sctp_timer.c
+++ b/freebsd/sys/netinet/sctp_timer.c
@@ -145,8 +145,8 @@ sctp_threshold_management(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
SCTPDBG(SCTP_DEBUG_TIMER4, "Overall error count for %p now %d thresh:%u state:%x\n",
(void *)&stcb->asoc, stcb->asoc.overall_error_count,
- (uint32_t) threshold,
- ((net == NULL) ? (uint32_t) 0 : (uint32_t) net->dest_state));
+ (uint32_t)threshold,
+ ((net == NULL) ? (uint32_t)0 : (uint32_t)net->dest_state));
/*
* We specifically do not do >= to give the assoc one more change
* before we fail it.
@@ -195,8 +195,10 @@ sctp_find_alternate_net(struct sctp_tcb *stcb,
*/
if (mode == 2) {
TAILQ_FOREACH(mnet, &stcb->asoc.nets, sctp_next) {
- /* JRS 5/14/07 - If the destination is unreachable
- * or unconfirmed, skip it. */
+ /*
+ * JRS 5/14/07 - If the destination is unreachable
+ * or unconfirmed, skip it.
+ */
if (((mnet->dest_state & SCTP_ADDR_REACHABLE) != SCTP_ADDR_REACHABLE) ||
(mnet->dest_state & SCTP_ADDR_UNCONFIRMED)) {
continue;
@@ -287,7 +289,7 @@ sctp_find_alternate_net(struct sctp_tcb *stcb,
return (max_cwnd_net);
}
} /* JRS 5/14/07 - If mode is set to 1, use the
- * CMT policy for choosing an alternate net. */
+ * CMT policy for choosing an alternate net. */
else if (mode == 1) {
TAILQ_FOREACH(mnet, &stcb->asoc.nets, sctp_next) {
if (((mnet->dest_state & SCTP_ADDR_REACHABLE) != SCTP_ADDR_REACHABLE) ||
@@ -658,7 +660,7 @@ start_again:
sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_RSND_TO,
chk->whoTo->flight_size,
chk->book_size,
- (uint32_t) (uintptr_t) chk->whoTo,
+ (uint32_t)(uintptr_t)chk->whoTo,
chk->rec.data.tsn);
}
sctp_flight_size_decrease(chk);
@@ -786,7 +788,7 @@ start_again:
sctp_misc_ints(SCTP_FLIGHT_LOG_UP,
chk->whoTo->flight_size,
chk->book_size,
- (uint32_t) (uintptr_t) chk->whoTo,
+ (uint32_t)(uintptr_t)chk->whoTo,
chk->rec.data.tsn);
}
sctp_flight_size_increase(chk);
@@ -1433,8 +1435,8 @@ sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
SCTP_GETTIME_TIMEVAL(&diff);
timevalsub(&diff, &net->last_sent_time);
- ms_gone_by = (uint32_t) (diff.tv_sec * 1000) +
- (uint32_t) (diff.tv_usec / 1000);
+ ms_gone_by = (uint32_t)(diff.tv_sec * 1000) +
+ (uint32_t)(diff.tv_usec / 1000);
} else {
ms_gone_by = 0xffffffff;
}
@@ -1475,7 +1477,7 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp,
net->ro._s_addr = sctp_source_address_selection(inp,
stcb,
- (sctp_route_t *) & net->ro,
+ (sctp_route_t *)&net->ro,
net, 0, stcb->asoc.vrf_id);
#if defined(INET6) && defined(SCTP_EMBEDDED_V6_SCOPE)
if (net->ro._l_addr.sa.sa_family == AF_INET6) {
diff --git a/freebsd/sys/netinet/sctp_usrreq.c b/freebsd/sys/netinet/sctp_usrreq.c
index e3e398d4..ebaa58d4 100644
--- a/freebsd/sys/netinet/sctp_usrreq.c
+++ b/freebsd/sys/netinet/sctp_usrreq.c
@@ -72,9 +72,9 @@ sctp_init(void)
* Allow a user to take no more than 1/2 the number of clusters or
* the SB_MAX whichever is smaller for the send window.
*/
- sb_max_adj = (u_long)((u_quad_t) (SB_MAX) * MCLBYTES / (MSIZE + MCLBYTES));
+ sb_max_adj = (u_long)((u_quad_t)(SB_MAX) * MCLBYTES / (MSIZE + MCLBYTES));
SCTP_BASE_SYSCTL(sctp_sendspace) = min(sb_max_adj,
- (((uint32_t) nmbclusters / 2) * SCTP_DEFAULT_MAXSEGMENT));
+ (((uint32_t)nmbclusters / 2) * SCTP_DEFAULT_MAXSEGMENT));
/*
* Now for the recv window, should we take the same amount? or
* should I do 1/2 the SB_MAX instead in the SB_MAX min above. For
@@ -136,7 +136,7 @@ sctp_pathmtu_adjustment(struct sctp_tcb *stcb, uint16_t nxtsz)
sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PMTU,
chk->whoTo->flight_size,
chk->book_size,
- (uint32_t) (uintptr_t) chk->whoTo,
+ (uint32_t)(uintptr_t)chk->whoTo,
chk->rec.data.tsn);
}
/* Clear any time so NO RTT is being done */
@@ -977,8 +977,10 @@ sctp_shutdown(struct socket *so)
}
}
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, netp);
- /* XXX: Why do this in the case where we have still data
- * queued? */
+ /*
+ * XXX: Why do this in the case where we have still data
+ * queued?
+ */
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CLOSING, SCTP_SO_LOCKED);
SCTP_TCB_UNLOCK(stcb);
SCTP_INP_RUNLOCK(inp);
@@ -1481,7 +1483,7 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
SCTP_FROM_SCTP_USRREQ + SCTP_LOC_7);
goto out_now;
}
- a_id = (sctp_assoc_t *) optval;
+ a_id = (sctp_assoc_t *)optval;
*a_id = sctp_get_associd(stcb);
/* initialize authentication parameters for the assoc */
@@ -1813,8 +1815,10 @@ flags_out:
}
SCTP_TCB_UNLOCK(stcb);
} else {
- /* Can't get stream value without
- * association */
+ /*
+ * Can't get stream value without
+ * association
+ */
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
}
@@ -2178,7 +2182,7 @@ flags_out:
SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize);
/* FIXME MT: change to sctp_assoc_value? */
- SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t) * value);
+ SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t)*value);
if (stcb) {
size = 0;
@@ -2208,7 +2212,7 @@ flags_out:
}
}
SCTP_TCB_UNLOCK(stcb);
- *value = (uint32_t) size;
+ *value = (uint32_t)size;
*optsize = sizeof(uint32_t);
} else {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTCONN);
@@ -2934,7 +2938,7 @@ flags_out:
} else {
/* copy in the chunks */
(void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks);
- sac->gauth_number_of_chunks = (uint32_t) size;
+ sac->gauth_number_of_chunks = (uint32_t)size;
*optsize = sizeof(struct sctp_authchunks) + size;
}
SCTP_TCB_UNLOCK(stcb);
@@ -2953,7 +2957,7 @@ flags_out:
} else {
/* copy in the chunks */
(void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks);
- sac->gauth_number_of_chunks = (uint32_t) size;
+ sac->gauth_number_of_chunks = (uint32_t)size;
*optsize = sizeof(struct sctp_authchunks) + size;
}
SCTP_INP_RUNLOCK(inp);
@@ -2984,7 +2988,7 @@ flags_out:
} else {
/* copy in the chunks */
(void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks);
- sac->gauth_number_of_chunks = (uint32_t) size;
+ sac->gauth_number_of_chunks = (uint32_t)size;
*optsize = sizeof(struct sctp_authchunks) + size;
}
SCTP_TCB_UNLOCK(stcb);
@@ -3590,14 +3594,14 @@ flags_out:
SCTP_FIND_STCB(inp, stcb, av->assoc_id);
if (stcb) {
- av->assoc_value = (uint32_t) stcb->asoc.local_strreset_support;
+ av->assoc_value = (uint32_t)stcb->asoc.local_strreset_support;
SCTP_TCB_UNLOCK(stcb);
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
(av->assoc_id == SCTP_FUTURE_ASSOC)) {
SCTP_INP_RLOCK(inp);
- av->assoc_value = (uint32_t) inp->local_strreset_support;
+ av->assoc_value = (uint32_t)inp->local_strreset_support;
SCTP_INP_RUNLOCK(inp);
} else {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
@@ -3889,10 +3893,12 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
(sctp_is_feature_on(inp, SCTP_PCB_FLAGS_INTERLEAVE_STRMS))) {
inp->idata_supported = 1;
} else {
- /* Must have Frag
+ /*
+ * Must have Frag
* interleave and
* stream interleave
- * on */
+ * on
+ */
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
}
@@ -4103,8 +4109,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
SCTP_INP_RUNLOCK(inp);
} else {
- /* Can't set stream value without
- * association */
+ /*
+ * Can't set stream value without
+ * association
+ */
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
}
@@ -4270,7 +4278,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
* insert/replace it
*/
if (size > 0) {
- key = sctp_set_key(sca->sca_key, (uint32_t) size);
+ key = sctp_set_key(sca->sca_key, (uint32_t)size);
if (key == NULL) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOMEM);
error = ENOMEM;
@@ -4307,7 +4315,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
* insert/replace it
*/
if (size > 0) {
- key = sctp_set_key(sca->sca_key, (uint32_t) size);
+ key = sctp_set_key(sca->sca_key, (uint32_t)size);
if (key == NULL) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOMEM);
error = ENOMEM;
@@ -4334,15 +4342,17 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
shared_keys = &stcb->asoc.shared_keys;
- /* clear the cached keys for
- * this key id */
+ /*
+ * clear the cached keys for
+ * this key id
+ */
sctp_clear_cachedkeys(stcb, sca->sca_keynumber);
/*
* create the new shared key
* and insert/replace it
*/
if (size > 0) {
- key = sctp_set_key(sca->sca_key, (uint32_t) size);
+ key = sctp_set_key(sca->sca_key, (uint32_t)size);
if (key == NULL) {
SCTP_TCB_UNLOCK(stcb);
continue;
@@ -4378,7 +4388,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
error = EINVAL;
break;
}
- hmaclist = sctp_alloc_hmaclist((uint16_t) shmac->shmac_number_of_idents);
+ hmaclist = sctp_alloc_hmaclist((uint16_t)shmac->shmac_number_of_idents);
if (hmaclist == NULL) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOMEM);
error = ENOMEM;
@@ -4549,7 +4559,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
SCTP_FIND_STCB(inp, stcb, av->assoc_id);
if (stcb) {
- stcb->asoc.local_strreset_support = (uint8_t) av->assoc_value;
+ stcb->asoc.local_strreset_support = (uint8_t)av->assoc_value;
SCTP_TCB_UNLOCK(stcb);
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
@@ -4557,7 +4567,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
(av->assoc_id == SCTP_FUTURE_ASSOC) ||
(av->assoc_id == SCTP_ALL_ASSOC)) {
SCTP_INP_WLOCK(inp);
- inp->local_strreset_support = (uint8_t) av->assoc_value;
+ inp->local_strreset_support = (uint8_t)av->assoc_value;
SCTP_INP_WUNLOCK(inp);
}
if ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
@@ -4565,7 +4575,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
- stcb->asoc.local_strreset_support = (uint8_t) av->assoc_value;
+ stcb->asoc.local_strreset_support = (uint8_t)av->assoc_value;
SCTP_TCB_UNLOCK(stcb);
}
SCTP_INP_RUNLOCK(inp);
@@ -4734,8 +4744,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
int cnt;
addstream |= 2;
- /* We allocate inside
- * sctp_send_str_reset_req() */
+ /*
+ * We allocate inside
+ * sctp_send_str_reset_req()
+ */
add_i_strmcnt = stradd->sas_instrms;
cnt = add_i_strmcnt;
cnt += stcb->asoc.streamincnt;
@@ -4762,7 +4774,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
uint32_t *value;
SCTP_CHECK_AND_CAST(value, optval, uint32_t, optsize);
- SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t) * value);
+ SCTP_FIND_STCB(inp, stcb, (sctp_assoc_t)*value);
if (stcb == NULL) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT);
error = ENOENT;
@@ -4783,8 +4795,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_TCB_UNLOCK(stcb);
break;
}
- /* Is there any data pending in the send or sent
- * queues? */
+ /*
+ * Is there any data pending in the send or sent
+ * queues?
+ */
if (!TAILQ_EMPTY(&stcb->asoc.send_queue) ||
!TAILQ_EMPTY(&stcb->asoc.sent_queue)) {
busy_out:
@@ -4930,8 +4944,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
(av->assoc_id == SCTP_FUTURE_ASSOC)) {
SCTP_INP_WLOCK(inp);
- /* FIXME MT: I think this is not in
- * tune with the API ID */
+ /*
+ * FIXME MT: I think this is not in
+ * tune with the API ID
+ */
if (av->assoc_value) {
inp->sctp_frag_point = (av->assoc_value + ovh);
} else {
@@ -5074,8 +5090,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
SCTP_TCB_UNLOCK(stcb);
}
- /* Send up the sender dry event only for 1-to-1
- * style sockets. */
+ /*
+ * Send up the sender dry event only for 1-to-1
+ * style sockets.
+ */
if (events->sctp_sender_dry_event) {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
@@ -5786,8 +5804,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
goto out_of_it;
}
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) {
- /* Must validate the ifa found is in
- * our ep */
+ /*
+ * Must validate the ifa found is in
+ * our ep
+ */
struct sctp_laddr *laddr;
int found = 0;
@@ -6543,8 +6563,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
(av->assoc_id == SCTP_FUTURE_ASSOC)) {
if ((av->assoc_value == 0) &&
(inp->asconf_supported == 1)) {
- /* AUTH is required for
- * ASCONF */
+ /*
+ * AUTH is required for
+ * ASCONF
+ */
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
} else {
@@ -6580,8 +6602,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
(av->assoc_id == SCTP_FUTURE_ASSOC)) {
if ((av->assoc_value != 0) &&
(inp->auth_supported == 0)) {
- /* AUTH is required for
- * ASCONF */
+ /*
+ * AUTH is required for
+ * ASCONF
+ */
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
} else {
@@ -7013,8 +7037,10 @@ sctp_listen(struct socket *so, int backlog, struct thread *p)
((tinp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) == 0) &&
((tinp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) &&
(tinp->sctp_socket->so_qlimit)) {
- /* we have a listener already and
- * its not this inp. */
+ /*
+ * we have a listener already and
+ * its not this inp.
+ */
SCTP_INP_DECR_REF(tinp);
return (EADDRINUSE);
} else if (tinp) {
@@ -7055,8 +7081,10 @@ sctp_listen(struct socket *so, int backlog, struct thread *p)
((tinp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) == 0) &&
((tinp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) &&
(tinp->sctp_socket->so_qlimit)) {
- /* we have a listener already and its not
- * this inp. */
+ /*
+ * we have a listener already and its not
+ * this inp.
+ */
SCTP_INP_DECR_REF(tinp);
return (EADDRINUSE);
} else if (tinp) {
@@ -7296,7 +7324,7 @@ sctp_ingetaddr(struct socket *so, struct sockaddr **addr)
vrf_id = inp->def_vrf_id;
sctp_ifa = sctp_source_address_selection(inp,
stcb,
- (sctp_route_t *) & net->ro,
+ (sctp_route_t *)&net->ro,
net, 0, vrf_id);
if (sctp_ifa) {
sin->sin_addr = sctp_ifa->address.sin.sin_addr;
diff --git a/freebsd/sys/netinet/sctputil.c b/freebsd/sys/netinet/sctputil.c
index 136b4bb6..79bb0620 100644
--- a/freebsd/sys/netinet/sctputil.c
+++ b/freebsd/sys/netinet/sctputil.c
@@ -96,7 +96,7 @@ sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc)
sctp_clog.x.close.sctp_flags = inp->sctp_flags;
if (stcb) {
sctp_clog.x.close.stcb = (void *)stcb;
- sctp_clog.x.close.state = (uint16_t) stcb->asoc.state;
+ sctp_clog.x.close.state = (uint16_t)stcb->asoc.state;
} else {
sctp_clog.x.close.stcb = 0;
sctp_clog.x.close.state = 0;
@@ -229,12 +229,12 @@ sctp_log_mb(struct mbuf *m, int from)
struct sctp_cwnd_log sctp_clog;
sctp_clog.x.mb.mp = m;
- sctp_clog.x.mb.mbuf_flags = (uint8_t) (SCTP_BUF_GET_FLAGS(m));
- sctp_clog.x.mb.size = (uint16_t) (SCTP_BUF_LEN(m));
+ sctp_clog.x.mb.mbuf_flags = (uint8_t)(SCTP_BUF_GET_FLAGS(m));
+ sctp_clog.x.mb.size = (uint16_t)(SCTP_BUF_LEN(m));
sctp_clog.x.mb.data = SCTP_BUF_AT(m, 0);
if (SCTP_BUF_IS_EXTENDED(m)) {
sctp_clog.x.mb.ext = SCTP_BUF_EXTEND_BASE(m);
- sctp_clog.x.mb.refcnt = (uint8_t) (SCTP_BUF_EXTEND_REFCNT(m));
+ sctp_clog.x.mb.refcnt = (uint8_t)(SCTP_BUF_EXTEND_REFCNT(m));
} else {
sctp_clog.x.mb.ext = 0;
sctp_clog.x.mb.refcnt = 0;
@@ -270,11 +270,11 @@ sctp_log_strm_del(struct sctp_queued_to_read *control, struct sctp_queued_to_rea
}
sctp_clog.x.strlog.stcb = control->stcb;
sctp_clog.x.strlog.n_tsn = control->sinfo_tsn;
- sctp_clog.x.strlog.n_sseq = (uint16_t) control->mid;
+ sctp_clog.x.strlog.n_sseq = (uint16_t)control->mid;
sctp_clog.x.strlog.strm = control->sinfo_stream;
if (poschk != NULL) {
sctp_clog.x.strlog.e_tsn = poschk->sinfo_tsn;
- sctp_clog.x.strlog.e_sseq = (uint16_t) poschk->mid;
+ sctp_clog.x.strlog.e_sseq = (uint16_t)poschk->mid;
} else {
sctp_clog.x.strlog.e_tsn = 0;
sctp_clog.x.strlog.e_sseq = 0;
@@ -471,12 +471,12 @@ sctp_wakeup_log(struct sctp_tcb *stcb, uint32_t wake_cnt, int from)
sctp_clog.x.wake.sent_q = stcb->asoc.sent_queue_cnt;
if (stcb->asoc.stream_queue_cnt < 0xff)
- sctp_clog.x.wake.stream_qcnt = (uint8_t) stcb->asoc.stream_queue_cnt;
+ sctp_clog.x.wake.stream_qcnt = (uint8_t)stcb->asoc.stream_queue_cnt;
else
sctp_clog.x.wake.stream_qcnt = 0xff;
if (stcb->asoc.chunks_on_out_queue < 0xff)
- sctp_clog.x.wake.chunks_on_oque = (uint8_t) stcb->asoc.chunks_on_out_queue;
+ sctp_clog.x.wake.chunks_on_oque = (uint8_t)stcb->asoc.chunks_on_out_queue;
else
sctp_clog.x.wake.chunks_on_oque = 0xff;
@@ -492,7 +492,7 @@ sctp_wakeup_log(struct sctp_tcb *stcb, uint32_t wake_cnt, int from)
if (stcb->sctp_socket) {
struct socket *so = stcb->sctp_socket;
- sctp_clog.x.wake.sbflags = (uint8_t) ((so->so_snd.sb_flags & 0x00ff));
+ sctp_clog.x.wake.sbflags = (uint8_t)((so->so_snd.sb_flags & 0x00ff));
} else {
sctp_clog.x.wake.sbflags = 0xff;
}
@@ -511,12 +511,12 @@ sctp_log_block(uint8_t from, struct sctp_association *asoc, size_t sendlen)
struct sctp_cwnd_log sctp_clog;
sctp_clog.x.blk.onsb = asoc->total_output_queue_size;
- sctp_clog.x.blk.send_sent_qcnt = (uint16_t) (asoc->send_queue_cnt + asoc->sent_queue_cnt);
+ sctp_clog.x.blk.send_sent_qcnt = (uint16_t)(asoc->send_queue_cnt + asoc->sent_queue_cnt);
sctp_clog.x.blk.peer_rwnd = asoc->peers_rwnd;
- sctp_clog.x.blk.stream_qcnt = (uint16_t) asoc->stream_queue_cnt;
- sctp_clog.x.blk.chunks_on_oque = (uint16_t) asoc->chunks_on_out_queue;
- sctp_clog.x.blk.flight_size = (uint16_t) (asoc->total_flight / 1024);
- sctp_clog.x.blk.sndlen = (uint32_t) sendlen;
+ sctp_clog.x.blk.stream_qcnt = (uint16_t)asoc->stream_queue_cnt;
+ sctp_clog.x.blk.chunks_on_oque = (uint16_t)asoc->chunks_on_out_queue;
+ sctp_clog.x.blk.flight_size = (uint16_t)(asoc->total_flight / 1024);
+ sctp_clog.x.blk.sndlen = (uint32_t)sendlen;
SCTP_CTR6(KTR_SCTP, "SCTP:%d[%d]:%x-%x-%x-%x",
SCTP_LOG_EVENT_BLOCK,
from,
@@ -558,8 +558,8 @@ sctp_print_audit_report(void)
SCTP_PRINTF("\n");
cnt = 0;
}
- SCTP_PRINTF("%2.2x%2.2x ", (uint32_t) sctp_audit_data[i][0],
- (uint32_t) sctp_audit_data[i][1]);
+ SCTP_PRINTF("%2.2x%2.2x ", (uint32_t)sctp_audit_data[i][0],
+ (uint32_t)sctp_audit_data[i][1]);
cnt++;
if ((cnt % 14) == 0)
SCTP_PRINTF("\n");
@@ -577,8 +577,8 @@ sctp_print_audit_report(void)
SCTP_PRINTF("\n");
cnt = 0;
}
- SCTP_PRINTF("%2.2x%2.2x ", (uint32_t) sctp_audit_data[i][0],
- (uint32_t) sctp_audit_data[i][1]);
+ SCTP_PRINTF("%2.2x%2.2x ", (uint32_t)sctp_audit_data[i][0],
+ (uint32_t)sctp_audit_data[i][1]);
cnt++;
if ((cnt % 14) == 0)
SCTP_PRINTF("\n");
@@ -830,9 +830,9 @@ sctp_fill_random_store(struct sctp_pcb *m)
* numbers, but thats ok too since that is random as well :->
*/
m->store_at = 0;
- (void)sctp_hmac(SCTP_HMAC, (uint8_t *) m->random_numbers,
- sizeof(m->random_numbers), (uint8_t *) & m->random_counter,
- sizeof(m->random_counter), (uint8_t *) m->random_store);
+ (void)sctp_hmac(SCTP_HMAC, (uint8_t *)m->random_numbers,
+ sizeof(m->random_numbers), (uint8_t *)&m->random_counter,
+ sizeof(m->random_counter), (uint8_t *)m->random_store);
m->random_counter++;
}
@@ -869,7 +869,7 @@ retry:
sctp_fill_random_store(inp);
}
p = &inp->random_store[store_at];
- xp = (uint32_t *) p;
+ xp = (uint32_t *)p;
x = *xp;
return (x);
}
@@ -978,7 +978,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
asoc->nrsack_supported = inp->nrsack_supported;
asoc->pktdrop_supported = inp->pktdrop_supported;
asoc->idata_supported = inp->idata_supported;
- asoc->sctp_cmt_pf = (uint8_t) 0;
+ asoc->sctp_cmt_pf = (uint8_t)0;
asoc->sctp_frag_point = inp->sctp_frag_point;
asoc->sctp_features = inp->sctp_features;
asoc->default_dscp = inp->sctp_ep.default_dscp;
@@ -1484,8 +1484,10 @@ sctp_handle_addr_wq(void)
sctp_asconf_iterator_end, NULL, 0);
if (ret) {
SCTP_PRINTF("Failed to initiate iterator for handle_addr_wq\n");
- /* Freeing if we are stopping or put back on the
- * addr_wq. */
+ /*
+ * Freeing if we are stopping or put back on the
+ * addr_wq.
+ */
if (SCTP_BASE_VAR(sctp_pcb_initialized) == 0) {
sctp_asconf_iterator_end(asc, 0);
} else {
@@ -1522,7 +1524,7 @@ sctp_timeout_handler(void *t)
did_output = 1;
#ifdef SCTP_AUDITING_ENABLED
- sctp_audit_log(0xF0, (uint8_t) tmr->type);
+ sctp_audit_log(0xF0, (uint8_t)tmr->type);
sctp_auditing(3, inp, stcb, net);
#endif
@@ -1917,7 +1919,7 @@ sctp_timeout_handler(void *t)
break;
}
#ifdef SCTP_AUDITING_ENABLED
- sctp_audit_log(0xF1, (uint8_t) type);
+ sctp_audit_log(0xF1, (uint8_t)type);
if (inp)
sctp_auditing(5, inp, stcb, net);
#endif
@@ -2479,14 +2481,16 @@ sctp_calculate_rto(struct sctp_tcb *stcb,
}
timevalsub(&now, old);
/* store the current RTT in us */
- net->rtt = (uint64_t) 1000000 *(uint64_t) now.tv_sec +
- (uint64_t) now.tv_usec;
+ net->rtt = (uint64_t)1000000 *(uint64_t)now.tv_sec +
+ (uint64_t)now.tv_usec;
/* compute rtt in ms */
- rtt = (int32_t) (net->rtt / 1000);
+ rtt = (int32_t)(net->rtt / 1000);
if ((asoc->cc_functions.sctp_rtt_calculated) && (rtt_from_sack == SCTP_RTT_FROM_DATA)) {
- /* Tell the CC module that a new update has just occurred
- * from a sack */
+ /*
+ * Tell the CC module that a new update has just occurred
+ * from a sack
+ */
(*asoc->cc_functions.sctp_rtt_calculated) (stcb, net, &now);
}
/*
@@ -2562,7 +2566,7 @@ sctp_calculate_rto(struct sctp_tcb *stcb,
* is >= 'len' returns NULL if there there isn't 'len' bytes in the chain.
*/
caddr_t
-sctp_m_getptr(struct mbuf *m, int off, int len, uint8_t * in_ptr)
+sctp_m_getptr(struct mbuf *m, int off, int len, uint8_t *in_ptr)
{
uint32_t count;
uint8_t *ptr;
@@ -2611,7 +2615,7 @@ sctp_get_next_param(struct mbuf *m,
{
/* This just provides a typed signature to Peter's Pull routine */
return ((struct sctp_paramhdr *)sctp_m_getptr(m, offset, pull_limit,
- (uint8_t *) pull));
+ (uint8_t *)pull));
}
@@ -2974,7 +2978,7 @@ sctp_notify_send_failed(struct sctp_tcb *stcb, uint8_t sent, uint32_t error,
} else {
ssfe->ssfe_flags = SCTP_DATA_UNSENT;
}
- ssfe->ssfe_length = (uint32_t) (notifhdr_len + payload_len);
+ ssfe->ssfe_length = (uint32_t)(notifhdr_len + payload_len);
ssfe->ssfe_error = error;
/* not exactly what the user sent in, but should be close :) */
ssfe->ssfe_info.snd_sid = chk->rec.data.sid;
@@ -2992,11 +2996,11 @@ sctp_notify_send_failed(struct sctp_tcb *stcb, uint8_t sent, uint32_t error,
} else {
ssf->ssf_flags = SCTP_DATA_UNSENT;
}
- ssf->ssf_length = (uint32_t) (notifhdr_len + payload_len);
+ ssf->ssf_length = (uint32_t)(notifhdr_len + payload_len);
ssf->ssf_error = error;
/* not exactly what the user sent in, but should be close :) */
ssf->ssf_info.sinfo_stream = chk->rec.data.sid;
- ssf->ssf_info.sinfo_ssn = (uint16_t) chk->rec.data.mid;
+ ssf->ssf_info.sinfo_ssn = (uint16_t)chk->rec.data.mid;
ssf->ssf_info.sinfo_flags = chk->rec.data.rcv_flags;
ssf->ssf_info.sinfo_ppid = chk->rec.data.ppid;
ssf->ssf_info.sinfo_context = chk->rec.data.context;
@@ -3078,7 +3082,7 @@ sctp_notify_send_failed2(struct sctp_tcb *stcb, uint32_t error,
memset(ssfe, 0, notifhdr_len);
ssfe->ssfe_type = SCTP_SEND_FAILED_EVENT;
ssfe->ssfe_flags = SCTP_DATA_UNSENT;
- ssfe->ssfe_length = (uint32_t) (notifhdr_len + sp->length);
+ ssfe->ssfe_length = (uint32_t)(notifhdr_len + sp->length);
ssfe->ssfe_error = error;
/* not exactly what the user sent in, but should be close :) */
ssfe->ssfe_info.snd_sid = sp->sid;
@@ -3096,7 +3100,7 @@ sctp_notify_send_failed2(struct sctp_tcb *stcb, uint32_t error,
memset(ssf, 0, notifhdr_len);
ssf->ssf_type = SCTP_SEND_FAILED;
ssf->ssf_flags = SCTP_DATA_UNSENT;
- ssf->ssf_length = (uint32_t) (notifhdr_len + sp->length);
+ ssf->ssf_length = (uint32_t)(notifhdr_len + sp->length);
ssf->ssf_error = error;
/* not exactly what the user sent in, but should be close :) */
ssf->ssf_info.sinfo_stream = sp->sid;
@@ -3513,7 +3517,7 @@ sctp_notify_stream_reset_tsn(struct sctp_tcb *stcb, uint32_t sending_tsn, uint32
static void
sctp_notify_stream_reset(struct sctp_tcb *stcb,
- int number_entries, uint16_t * list, int flag)
+ int number_entries, uint16_t *list, int flag)
{
struct mbuf *m_notify;
struct sctp_queued_to_read *control;
@@ -3721,7 +3725,7 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb,
{
uint32_t val;
- val = *((uint32_t *) data);
+ val = *((uint32_t *)data);
sctp_notify_partial_delivery_indication(stcb, error, val, so_locked);
break;
@@ -3750,25 +3754,25 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb,
}
break;
case SCTP_NOTIFY_STR_RESET_SEND:
- sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_OUTGOING_SSN);
+ sctp_notify_stream_reset(stcb, error, ((uint16_t *)data), SCTP_STREAM_RESET_OUTGOING_SSN);
break;
case SCTP_NOTIFY_STR_RESET_RECV:
- sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), SCTP_STREAM_RESET_INCOMING);
+ sctp_notify_stream_reset(stcb, error, ((uint16_t *)data), SCTP_STREAM_RESET_INCOMING);
break;
case SCTP_NOTIFY_STR_RESET_FAILED_OUT:
- sctp_notify_stream_reset(stcb, error, ((uint16_t *) data),
+ sctp_notify_stream_reset(stcb, error, ((uint16_t *)data),
(SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_FAILED));
break;
case SCTP_NOTIFY_STR_RESET_DENIED_OUT:
- sctp_notify_stream_reset(stcb, error, ((uint16_t *) data),
+ sctp_notify_stream_reset(stcb, error, ((uint16_t *)data),
(SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_DENIED));
break;
case SCTP_NOTIFY_STR_RESET_FAILED_IN:
- sctp_notify_stream_reset(stcb, error, ((uint16_t *) data),
+ sctp_notify_stream_reset(stcb, error, ((uint16_t *)data),
(SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_FAILED));
break;
case SCTP_NOTIFY_STR_RESET_DENIED_IN:
- sctp_notify_stream_reset(stcb, error, ((uint16_t *) data),
+ sctp_notify_stream_reset(stcb, error, ((uint16_t *)data),
(SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_DENIED));
break;
case SCTP_NOTIFY_ASCONF_ADD_IP:
@@ -3788,17 +3792,17 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb,
break;
case SCTP_NOTIFY_AUTH_NEW_KEY:
sctp_notify_authentication(stcb, SCTP_AUTH_NEW_KEY, error,
- (uint16_t) (uintptr_t) data,
+ (uint16_t)(uintptr_t)data,
so_locked);
break;
case SCTP_NOTIFY_AUTH_FREE_KEY:
sctp_notify_authentication(stcb, SCTP_AUTH_FREE_KEY, error,
- (uint16_t) (uintptr_t) data,
+ (uint16_t)(uintptr_t)data,
so_locked);
break;
case SCTP_NOTIFY_NO_PEER_AUTH:
sctp_notify_authentication(stcb, SCTP_AUTH_NO_AUTH, error,
- (uint16_t) (uintptr_t) data,
+ (uint16_t)(uintptr_t)data,
so_locked);
break;
case SCTP_NOTIFY_SENDER_DRY:
@@ -4148,7 +4152,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset,
}
contains_init_chunk = 0;
ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset,
- sizeof(*ch), (uint8_t *) & chunk_buf);
+ sizeof(*ch), (uint8_t *)&chunk_buf);
while (ch != NULL) {
chk_length = ntohs(ch->chunk_length);
if (chk_length < sizeof(*ch)) {
@@ -4181,7 +4185,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset,
}
offset += SCTP_SIZE32(chk_length);
ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset,
- sizeof(*ch), (uint8_t *) & chunk_buf);
+ sizeof(*ch), (uint8_t *)&chunk_buf);
}
if ((SCTP_BASE_SYSCTL(sctp_blackhole) == 0) ||
((SCTP_BASE_SYSCTL(sctp_blackhole) == 1) &&
@@ -4197,7 +4201,7 @@ sctp_handle_ootb(struct mbuf *m, int iphlen, int offset,
* if there is return 1, else return 0.
*/
int
-sctp_is_there_an_abort_here(struct mbuf *m, int iphlen, uint32_t * vtagfill)
+sctp_is_there_an_abort_here(struct mbuf *m, int iphlen, uint32_t *vtagfill)
{
struct sctp_chunkhdr *ch;
struct sctp_init_chunk *init_chk, chunk_buf;
@@ -4206,7 +4210,7 @@ sctp_is_there_an_abort_here(struct mbuf *m, int iphlen, uint32_t * vtagfill)
offset = iphlen + sizeof(struct sctphdr);
ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset, sizeof(*ch),
- (uint8_t *) & chunk_buf);
+ (uint8_t *)&chunk_buf);
while (ch != NULL) {
chk_length = ntohs(ch->chunk_length);
if (chk_length < sizeof(*ch)) {
@@ -4221,7 +4225,7 @@ sctp_is_there_an_abort_here(struct mbuf *m, int iphlen, uint32_t * vtagfill)
if (ch->chunk_type == SCTP_INITIATION) {
/* need to update the Vtag */
init_chk = (struct sctp_init_chunk *)sctp_m_getptr(m,
- offset, sizeof(*init_chk), (uint8_t *) & chunk_buf);
+ offset, sizeof(*init_chk), (uint8_t *)&chunk_buf);
if (init_chk != NULL) {
*vtagfill = ntohl(init_chk->init.initiate_tag);
}
@@ -4229,7 +4233,7 @@ sctp_is_there_an_abort_here(struct mbuf *m, int iphlen, uint32_t * vtagfill)
/* Nope, move to the next chunk */
offset += SCTP_SIZE32(chk_length);
ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset,
- sizeof(*ch), (uint8_t *) & chunk_buf);
+ sizeof(*ch), (uint8_t *)&chunk_buf);
}
return (0);
}
@@ -4615,7 +4619,7 @@ sctp_generate_cause(uint16_t code, char *info)
if (info_len > (SCTP_MAX_CAUSE_LENGTH - sizeof(struct sctp_paramhdr))) {
return (NULL);
}
- len = (uint16_t) (sizeof(struct sctp_paramhdr) + info_len);
+ len = (uint16_t)(sizeof(struct sctp_paramhdr) + info_len);
m = sctp_get_mbuf_for_msg(len, 0, M_NOWAIT, 1, MT_DATA);
if (m != NULL) {
SCTP_BUF_LEN(m) = len;
@@ -4634,14 +4638,14 @@ sctp_generate_no_user_data_cause(uint32_t tsn)
struct sctp_error_no_user_data *no_user_data_cause;
uint16_t len;
- len = (uint16_t) sizeof(struct sctp_error_no_user_data);
+ len = (uint16_t)sizeof(struct sctp_error_no_user_data);
m = sctp_get_mbuf_for_msg(len, 0, M_NOWAIT, 1, MT_DATA);
if (m != NULL) {
SCTP_BUF_LEN(m) = len;
no_user_data_cause = mtod(m, struct sctp_error_no_user_data *);
no_user_data_cause->cause.code = htons(SCTP_CAUSE_NO_USER_DATA);
no_user_data_cause->cause.length = htons(len);
- no_user_data_cause->tsn = tsn; /* tsn is passed in as NBO */
+ no_user_data_cause->tsn = htonl(tsn);
}
return (m);
}
@@ -4794,8 +4798,10 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1,
do_wakeup_routine = 1;
tp1->sent = SCTP_FORWARD_TSN_SKIP;
TAILQ_REMOVE(&stcb->asoc.send_queue, tp1, sctp_next);
- /* on to the sent queue so we can wait for it to be
- * passed by. */
+ /*
+ * on to the sent queue so we can wait for it to be
+ * passed by.
+ */
TAILQ_INSERT_TAIL(&stcb->asoc.sent_queue, tp1,
sctp_next);
stcb->asoc.send_queue_cnt--;
@@ -5028,8 +5034,8 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t vrf_id, int holds_lock)
hash_head = &vrf->vrf_addr_hash[(hash_of_addr & vrf->vrf_addr_hashmark)];
if (hash_head == NULL) {
SCTP_PRINTF("hash_of_addr:%x mask:%x table:%x - ",
- hash_of_addr, (uint32_t) vrf->vrf_addr_hashmark,
- (uint32_t) (hash_of_addr & vrf->vrf_addr_hashmark));
+ hash_of_addr, (uint32_t)vrf->vrf_addr_hashmark,
+ (uint32_t)(hash_of_addr & vrf->vrf_addr_hashmark));
sctp_print_address(addr);
SCTP_PRINTF("No such bucket for address\n");
if (holds_lock == 0)
@@ -5071,7 +5077,7 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t vrf_id, int holds_lock)
}
static void
-sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t * freed_so_far, int hold_rlock,
+sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t *freed_so_far, int hold_rlock,
uint32_t rwnd_req)
{
/* User pulled some data, do we need a rwnd update? */
@@ -5233,11 +5239,11 @@ sctp_sorecvmsg(struct socket *so,
in_eeor_mode = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_EXPLICIT_EOR);
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_RECV_RWND_LOGGING_ENABLE) {
sctp_misc_ints(SCTP_SORECV_ENTER,
- rwnd_req, in_eeor_mode, so->so_rcv.sb_cc, (uint32_t) uio->uio_resid);
+ rwnd_req, in_eeor_mode, so->so_rcv.sb_cc, (uint32_t)uio->uio_resid);
}
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_RECV_RWND_LOGGING_ENABLE) {
sctp_misc_ints(SCTP_SORECV_ENTERPL,
- rwnd_req, block_allowed, so->so_rcv.sb_cc, (uint32_t) uio->uio_resid);
+ rwnd_req, block_allowed, so->so_rcv.sb_cc, (uint32_t)uio->uio_resid);
}
error = sblock(&so->so_rcv, (block_allowed ? SBL_WAIT : 0));
if (error) {
@@ -5288,8 +5294,10 @@ restart_nosblocks:
* connect.
*/
if (inp->sctp_flags & SCTP_PCB_FLAGS_WAS_ABORTED) {
- /* You were aborted, passive side
- * always hits here */
+ /*
+ * You were aborted, passive side
+ * always hits here
+ */
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, ECONNRESET);
error = ECONNRESET;
}
@@ -5388,8 +5396,10 @@ restart_nosblocks:
}
if ((control->length == 0) &&
(control->end_added == 1)) {
- /* Do we also need to check for (control->pdapi_aborted ==
- * 1)? */
+ /*
+ * Do we also need to check for (control->pdapi_aborted ==
+ * 1)?
+ */
if (hold_rlock == 0) {
hold_rlock = 1;
SCTP_INP_READ_LOCK(inp);
@@ -5530,7 +5540,7 @@ found_one:
/* First lets get off the sinfo and sockaddr info */
if ((sinfo != NULL) && (filling_sinfo != 0)) {
sinfo->sinfo_stream = control->sinfo_stream;
- sinfo->sinfo_ssn = (uint16_t) control->mid;
+ sinfo->sinfo_ssn = (uint16_t)control->mid;
sinfo->sinfo_flags = control->sinfo_flags;
sinfo->sinfo_ppid = control->sinfo_ppid;
sinfo->sinfo_context = control->sinfo_context;
@@ -5606,7 +5616,7 @@ found_one:
entry = &inp->readlog[index];
entry->vtag = control->sinfo_assoc_id;
entry->strm = control->sinfo_stream;
- entry->seq = (uint16_t) control->mid;
+ entry->seq = (uint16_t)control->mid;
entry->sz = control->length;
entry->flgs = control->sinfo_flags;
}
@@ -5732,8 +5742,10 @@ get_more_data:
atomic_subtract_int(&control->length, cp_len);
control->data = sctp_m_free(m);
m = control->data;
- /* been through it all, must hold sb
- * lock ok to null tail */
+ /*
+ * been through it all, must hold sb
+ * lock ok to null tail
+ */
if (control->data == NULL) {
#ifdef INVARIANTS
if ((control->end_added == 0) ||
@@ -5866,7 +5878,7 @@ get_more_data:
}
if ((uio->uio_resid == 0) ||
((in_eeor_mode) &&
- (copied_so_far >= (uint32_t) max(so->so_rcv.sb_lowat, 1)))) {
+ (copied_so_far >= (uint32_t)max(so->so_rcv.sb_lowat, 1)))) {
goto release;
}
/*
@@ -5952,8 +5964,10 @@ wait_some_more:
*/
SCTP_INP_READ_LOCK(inp);
if ((control->length > 0) && (control->data == NULL)) {
- /* big trouble.. we have the lock and its
- * corrupt? */
+ /*
+ * big trouble.. we have the lock and its
+ * corrupt?
+ */
#ifdef INVARIANTS
panic("Impossible data==NULL length !=0");
#endif
@@ -6084,13 +6098,13 @@ out:
if (stcb) {
sctp_misc_ints(SCTP_SORECV_DONE,
freed_so_far,
- (uint32_t) ((uio) ? (slen - uio->uio_resid) : slen),
+ (uint32_t)((uio) ? (slen - uio->uio_resid) : slen),
stcb->asoc.my_rwnd,
so->so_rcv.sb_cc);
} else {
sctp_misc_ints(SCTP_SORECV_DONE,
freed_so_far,
- (uint32_t) ((uio) ? (slen - uio->uio_resid) : slen),
+ (uint32_t)((uio) ? (slen - uio->uio_resid) : slen),
0,
so->so_rcv.sb_cc);
}
@@ -6668,8 +6682,10 @@ sctp_local_addr_count(struct sctp_tcb *stcb)
sin = &sctp_ifa->address.sin;
if (sin->sin_addr.s_addr == 0) {
- /* skip unspecified
- * addrs */
+ /*
+ * skip unspecified
+ * addrs
+ */
continue;
}
if (prison_check_ip4(stcb->sctp_ep->ip_inp.inp.inp_cred,
@@ -7099,7 +7115,7 @@ sctp_recv_icmp6_tunneled_packet(int cmd, struct sockaddr *sa, void *d, void *ctx
code = ICMP6_PARAMPROB_NEXTHEADER;
}
sctp6_notify(inp, stcb, net, type, code,
- (uint16_t) ntohl(ip6cp->ip6c_icmp6->icmp6_mtu));
+ (uint16_t)ntohl(ip6cp->ip6c_icmp6->icmp6_mtu));
} else {
if ((stcb == NULL) && (inp != NULL)) {
/* reduce inp's ref-count */
diff --git a/freebsd/sys/netinet/sctputil.h b/freebsd/sys/netinet/sctputil.h
index a3a4f3c6..dd45e49a 100644
--- a/freebsd/sys/netinet/sctputil.h
+++ b/freebsd/sys/netinet/sctputil.h
@@ -65,10 +65,10 @@ void
* Function prototypes
*/
int32_t
-sctp_map_assoc_state(int);
+ sctp_map_assoc_state(int);
uint32_t
-sctp_get_ifa_hash_val(struct sockaddr *addr);
+ sctp_get_ifa_hash_val(struct sockaddr *addr);
struct sctp_ifa *
sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct sockaddr *addr, int hold_lock);
diff --git a/freebsd/sys/netinet/tcp_hostcache.c b/freebsd/sys/netinet/tcp_hostcache.c
index e0c4b493..d26688e5 100644
--- a/freebsd/sys/netinet/tcp_hostcache.c
+++ b/freebsd/sys/netinet/tcp_hostcache.c
@@ -71,10 +71,12 @@ __FBSDID("$FreeBSD$");
#include <rtems/bsd/sys/param.h>
#include <sys/systm.h>
+#include <sys/jail.h>
#include <sys/kernel.h>
#include <rtems/bsd/sys/lock.h>
#include <sys/mutex.h>
#include <sys/malloc.h>
+#include <sys/proc.h>
#include <sys/sbuf.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
@@ -627,6 +629,9 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
char ip6buf[INET6_ADDRSTRLEN];
#endif
+ if (jailed_without_vnet(curthread->td_ucred) != 0)
+ return (EPERM);
+
sbuf_new(&sb, NULL, linesize * (V_tcp_hostcache.cache_count + 1),
SBUF_INCLUDENUL);
diff --git a/freebsd/sys/netinet/tcp_input.c b/freebsd/sys/netinet/tcp_input.c
index 7e07fc0a..bc77edbc 100644
--- a/freebsd/sys/netinet/tcp_input.c
+++ b/freebsd/sys/netinet/tcp_input.c
@@ -1410,7 +1410,7 @@ tfo_socket_result:
tcp_trace(TA_INPUT, ostate, tp,
(void *)tcp_saveipgen, &tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
tcp_dooptions(&to, optp, optlen, TO_SYN);
#ifdef TCP_RFC7413
if (syncache_add(&inc, &to, th, inp, &so, m, NULL, NULL))
@@ -1458,7 +1458,7 @@ tfo_socket_result:
}
#endif
- TCP_PROBE5(receive, NULL, tp, mtod(m, const char *), tp, th);
+ TCP_PROBE5(receive, NULL, tp, m, tp, th);
/*
* Segment belongs to a connection in SYN_SENT, ESTABLISHED or later
@@ -1470,7 +1470,7 @@ tfo_socket_result:
return (IPPROTO_DONE);
dropwithreset:
- TCP_PROBE5(receive, NULL, tp, mtod(m, const char *), tp, th);
+ TCP_PROBE5(receive, NULL, tp, m, tp, th);
if (ti_locked == TI_RLOCKED) {
INP_INFO_RUNLOCK(&V_tcbinfo);
@@ -1494,7 +1494,7 @@ dropwithreset:
dropunlock:
if (m != NULL)
- TCP_PROBE5(receive, NULL, tp, mtod(m, const char *), tp, th);
+ TCP_PROBE5(receive, NULL, tp, m, tp, th);
if (ti_locked == TI_RLOCKED) {
INP_INFO_RUNLOCK(&V_tcbinfo);
@@ -1828,8 +1828,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
(void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th,
- mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
if (tp->snd_una == tp->snd_max)
tcp_timer_activate(tp, TT_REXMT, 0);
else if (!tcp_timer_active(tp, TT_PERSIST))
@@ -1875,7 +1874,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
tcp_trace(TA_INPUT, ostate, tp,
(void *)tcp_saveipgen, &tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
/*
* Automatic sizing of receive socket buffer. Often the send
@@ -2037,7 +2036,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
}
if ((thflags & (TH_ACK|TH_RST)) == (TH_ACK|TH_RST)) {
TCP_PROBE5(connect__refused, NULL, tp,
- mtod(m, const char *), tp, th);
+ m, tp, th);
tp = tcp_drop(tp, ECONNREFUSED);
}
if (thflags & TH_RST)
@@ -2090,7 +2089,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
} else {
tcp_state_change(tp, TCPS_ESTABLISHED);
TCP_PROBE5(connect__established, NULL, tp,
- mtod(m, const char *), tp, th);
+ m, tp, th);
cc_conn_init(tp);
tcp_timer_activate(tp, TT_KEEP,
TP_KEEPIDLE(tp));
@@ -2470,7 +2469,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
} else {
tcp_state_change(tp, TCPS_ESTABLISHED);
TCP_PROBE5(accept__established, NULL, tp,
- mtod(m, const char *), tp, th);
+ m, tp, th);
#ifdef TCP_RFC7413
if (tp->t_tfo_pending) {
tcp_fastopen_decrement_counter(tp->t_tfo_pending);
@@ -3204,7 +3203,7 @@ dodata: /* XXX */
tcp_trace(TA_INPUT, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
/*
* Return any desired output.
@@ -3252,7 +3251,7 @@ dropafterack:
tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
if (ti_locked == TI_RLOCKED)
INP_INFO_RUNLOCK(&V_tcbinfo);
ti_locked = TI_UNLOCKED;
@@ -3293,7 +3292,7 @@ drop:
tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- TCP_PROBE3(debug__input, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__input, tp, th, m);
if (tp != NULL)
INP_WUNLOCK(tp->t_inpcb);
m_freem(m);
diff --git a/freebsd/sys/netinet/tcp_output.c b/freebsd/sys/netinet/tcp_output.c
index a310512e..b39b0bdf 100644
--- a/freebsd/sys/netinet/tcp_output.c
+++ b/freebsd/sys/netinet/tcp_output.c
@@ -547,6 +547,11 @@ after_sack_rexmit:
* (except for the sequence number) for all generated packets. This
* makes it impossible to transmit any options which vary per generated
* segment or packet.
+ *
+ * IPv4 handling has a clear separation of ip options and ip header
+ * flags while IPv6 combines both in in6p_outputopts. ip6_optlen() does
+ * the right thing below to provide length of just ip options and thus
+ * checking for ipoptlen is enough to decide if ip options are present.
*/
#ifdef IPSEC
/*
@@ -555,14 +560,25 @@ after_sack_rexmit:
*/
ipsec_optlen = ipsec_hdrsiz_tcp(tp);
#endif
+
+#ifdef INET6
+ if (isipv6)
+ ipoptlen = ip6_optlen(tp->t_inpcb);
+ else
+#endif
+ if (tp->t_inpcb->inp_options)
+ ipoptlen = tp->t_inpcb->inp_options->m_len -
+ offsetof(struct ipoption, ipopt_list);
+ else
+ ipoptlen = 0;
+#ifdef IPSEC
+ ipoptlen += ipsec_optlen;
+#endif
+
if ((tp->t_flags & TF_TSO) && V_tcp_do_tso && len > tp->t_maxseg &&
((tp->t_flags & TF_SIGNATURE) == 0) &&
tp->rcv_numsacks == 0 && sack_rxmit == 0 &&
-#ifdef IPSEC
- ipsec_optlen == 0 &&
-#endif
- tp->t_inpcb->inp_options == NULL &&
- tp->t_inpcb->in6p_options == NULL)
+ ipoptlen == 0)
tso = 1;
if (sack_rxmit) {
@@ -835,20 +851,6 @@ send:
hdrlen += optlen = tcp_addoptions(&to, opt);
}
-#ifdef INET6
- if (isipv6)
- ipoptlen = ip6_optlen(tp->t_inpcb);
- else
-#endif
- if (tp->t_inpcb->inp_options)
- ipoptlen = tp->t_inpcb->inp_options->m_len -
- offsetof(struct ipoption, ipopt_list);
- else
- ipoptlen = 0;
-#ifdef IPSEC
- ipoptlen += ipsec_optlen;
-#endif
-
/*
* Adjust data length if insertion of options will
* bump the packet length beyond the t_maxseg length.
@@ -1339,7 +1341,7 @@ send:
ipov->ih_len = save;
}
#endif /* TCPDEBUG */
- TCP_PROBE3(debug__output, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__output, tp, th, m);
/*
* Fill in IP length and desired time to live and
diff --git a/freebsd/sys/netinet/tcp_sack.c b/freebsd/sys/netinet/tcp_sack.c
index c7e32cba..170d263e 100644
--- a/freebsd/sys/netinet/tcp_sack.c
+++ b/freebsd/sys/netinet/tcp_sack.c
@@ -472,9 +472,6 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack)
tp->snd_fack = sblkp->end;
sack_changed = 1;
}
- /* We must have at least one SACK hole in scoreboard. */
- KASSERT(!TAILQ_EMPTY(&tp->snd_holes),
- ("SACK scoreboard must not be empty"));
cur = TAILQ_LAST(&tp->snd_holes, sackhole_head); /* Last SACK hole. */
/*
* Since the incoming sack blocks are sorted, we can process them
diff --git a/freebsd/sys/netinet/tcp_subr.c b/freebsd/sys/netinet/tcp_subr.c
index 4f196a15..ae50bb3e 100644
--- a/freebsd/sys/netinet/tcp_subr.c
+++ b/freebsd/sys/netinet/tcp_subr.c
@@ -1162,12 +1162,11 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m,
if (tp == NULL || (inp->inp_socket->so_options & SO_DEBUG))
tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0);
#endif
- TCP_PROBE3(debug__output, tp, th, mtod(m, const char *));
+ TCP_PROBE3(debug__output, tp, th, m);
if (flags & TH_RST)
- TCP_PROBE5(accept__refused, NULL, NULL, mtod(m, const char *),
- tp, nth);
+ TCP_PROBE5(accept__refused, NULL, NULL, m, tp, nth);
- TCP_PROBE5(send, NULL, tp, mtod(m, const char *), tp, nth);
+ TCP_PROBE5(send, NULL, tp, m, tp, nth);
#ifdef INET6
if (isipv6)
(void) ip6_output(m, NULL, NULL, 0, NULL, NULL, inp);
diff --git a/freebsd/sys/netinet/tcp_syncache.c b/freebsd/sys/netinet/tcp_syncache.c
index 453d5ba4..6d05be85 100644
--- a/freebsd/sys/netinet/tcp_syncache.c
+++ b/freebsd/sys/netinet/tcp_syncache.c
@@ -1180,7 +1180,7 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
struct syncache_head *sch;
struct mbuf *ipopts = NULL;
u_int ltflags;
- int win, sb_hiwat, ip_ttl, ip_tos;
+ int win, ip_ttl, ip_tos;
char *s;
int rv = 0;
#ifdef INET6
@@ -1218,7 +1218,6 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
ip_ttl = inp->inp_ip_ttl;
ip_tos = inp->inp_ip_tos;
win = sbspace(&so->so_rcv);
- sb_hiwat = so->so_rcv.sb_hiwat;
ltflags = (tp->t_flags & (TF_NOOPT | TF_SIGNATURE));
#ifdef TCP_RFC7413