summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/netinet/sctp_indata.c
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/sys/netinet/sctp_indata.c')
-rw-r--r--freebsd/sys/netinet/sctp_indata.c437
1 files changed, 248 insertions, 189 deletions
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 */