diff options
author | tuexen <tuexen@FreeBSD.org> | 2010-12-30 21:32:35 +0000 |
---|---|---|
committer | tuexen <tuexen@FreeBSD.org> | 2010-12-30 21:32:35 +0000 |
commit | 12d4883ccf51c51d512fc50f38d6fba359e78fd3 (patch) | |
tree | 01d2d584408afde4e2cdf35e0cac80a0d93045d2 /sys/netinet/sctp_indata.c | |
parent | 543d6f8f19d01a1c2b2c7ae511afd03acf3176d2 (diff) | |
download | FreeBSD-src-12d4883ccf51c51d512fc50f38d6fba359e78fd3.zip FreeBSD-src-12d4883ccf51c51d512fc50f38d6fba359e78fd3.tar.gz |
Define and use SCTP_SSN_GE, SCTP_SSN_GT, SCTP_TSN_GE, SCTP_TSN_GT macros
and use them instead of the generic compare_with_wrap.
Retire compare_with_wrap.
MFC after: 3 months.
Diffstat (limited to 'sys/netinet/sctp_indata.c')
-rw-r--r-- | sys/netinet/sctp_indata.c | 240 |
1 files changed, 88 insertions, 152 deletions
diff --git a/sys/netinet/sctp_indata.c b/sys/netinet/sctp_indata.c index eb32a91..7ede155 100644 --- a/sys/netinet/sctp_indata.c +++ b/sys/netinet/sctp_indata.c @@ -298,7 +298,7 @@ sctp_mark_non_revokable(struct sctp_association *asoc, uint32_t tsn) return; } cumackp1 = asoc->cumulative_tsn + 1; - if (compare_with_wrap(cumackp1, tsn, MAX_TSN)) { + if (SCTP_TSN_GT(cumackp1, tsn)) { /* * this tsn is behind the cum ack and thus we don't need to * worry about it being moved from one to the other. @@ -315,13 +315,12 @@ sctp_mark_non_revokable(struct sctp_association *asoc, uint32_t tsn) } SCTP_SET_TSN_PRESENT(asoc->nr_mapping_array, gap); SCTP_UNSET_TSN_PRESENT(asoc->mapping_array, gap); - if (compare_with_wrap(tsn, asoc->highest_tsn_inside_nr_map, MAX_TSN)) { + if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) { asoc->highest_tsn_inside_nr_map = tsn; } if (tsn == asoc->highest_tsn_inside_map) { /* We must back down to see what the new highest is */ - for (i = tsn - 1; (compare_with_wrap(i, asoc->mapping_array_base_tsn, MAX_TSN) || - (i == asoc->mapping_array_base_tsn)); i--) { + for (i = tsn - 1; SCTP_TSN_GE(i, asoc->mapping_array_base_tsn); i--) { SCTP_CALC_TSN_TO_GAP(gap, i, asoc->mapping_array_base_tsn); if (SCTP_IS_TSN_PRESENT(asoc->mapping_array, gap)) { asoc->highest_tsn_inside_map = i; @@ -558,9 +557,7 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb, struct sctp_association *asoc, (uint32_t) control->sinfo_stream, (uint32_t) strm->last_sequence_delivered, (uint32_t) nxt_todel); - if (compare_with_wrap(strm->last_sequence_delivered, - control->sinfo_ssn, MAX_SEQ) || - (strm->last_sequence_delivered == control->sinfo_ssn)) { + if (SCTP_SSN_GE(strm->last_sequence_delivered, control->sinfo_ssn)) { /* The incoming sseq is behind where we last delivered? */ SCTPDBG(SCTP_DEBUG_INDATA1, "Duplicate S-SEQ:%d delivered:%d from peer, Abort association\n", control->sinfo_ssn, strm->last_sequence_delivered); @@ -646,9 +643,7 @@ protocol_error: * Ok, we did not deliver this guy, find the correct place * to put it on the queue. */ - if ((compare_with_wrap(asoc->cumulative_tsn, - control->sinfo_tsn, MAX_TSN)) || - (control->sinfo_tsn == asoc->cumulative_tsn)) { + if (SCTP_TSN_GE(asoc->cumulative_tsn, control->sinfo_tsn)) { goto protocol_error; } if (TAILQ_EMPTY(&strm->inqueue)) { @@ -659,8 +654,7 @@ protocol_error: TAILQ_INSERT_HEAD(&strm->inqueue, control, next); } else { TAILQ_FOREACH(at, &strm->inqueue, next) { - if (compare_with_wrap(at->sinfo_ssn, - control->sinfo_ssn, MAX_SEQ)) { + if (SCTP_SSN_GT(at->sinfo_ssn, control->sinfo_ssn)) { /* * one in queue is bigger than the * new one, insert before this one @@ -991,8 +985,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc, } /* Find its place */ TAILQ_FOREACH(at, &asoc->reasmqueue, sctp_next) { - if (compare_with_wrap(at->rec.data.TSN_seq, - chk->rec.data.TSN_seq, MAX_TSN)) { + if (SCTP_TSN_GT(at->rec.data.TSN_seq, chk->rec.data.TSN_seq)) { /* * one in queue is bigger than the new one, insert * before this one @@ -1383,8 +1376,7 @@ sctp_does_tsn_belong_to_reasm(struct sctp_association *asoc, uint32_t tsn_est; TAILQ_FOREACH(at, &asoc->reasmqueue, sctp_next) { - if (compare_with_wrap(TSN_seq, - at->rec.data.TSN_seq, MAX_TSN)) { + if (SCTP_TSN_GT(TSN_seq, at->rec.data.TSN_seq)) { /* is it one bigger? */ tsn_est = at->rec.data.TSN_seq + 1; if (tsn_est == TSN_seq) { @@ -1467,8 +1459,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, return (0); } SCTP_LTRACE_CHK(stcb->sctp_ep, stcb, ch->ch.chunk_type, tsn); - if (compare_with_wrap(asoc->cumulative_tsn, tsn, MAX_TSN) || - asoc->cumulative_tsn == tsn) { + if (SCTP_TSN_GE(asoc->cumulative_tsn, tsn)) { /* It is a duplicate */ SCTP_STAT_INCR(sctps_recvdupdata); if (asoc->numduptsns < SCTP_MAX_DUP_TSNS) { @@ -1492,7 +1483,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, return (0); } } - if (compare_with_wrap(tsn, *high_tsn, MAX_TSN)) { + if (SCTP_TSN_GT(tsn, *high_tsn)) { *high_tsn = tsn; } /* See if we have received this one already */ @@ -1564,8 +1555,8 @@ 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 (compare_with_wrap(tsn, asoc->highest_tsn_inside_map, MAX_TSN) && - compare_with_wrap(tsn, asoc->highest_tsn_inside_nr_map, MAX_TSN)) { + 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 */ sctp_set_rwnd(stcb, asoc); if ((asoc->cnt_on_all_streams + @@ -1610,7 +1601,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, SCTP_STAT_INCR(sctps_badsid); SCTP_TCB_LOCK_ASSERT(stcb); SCTP_SET_TSN_PRESENT(asoc->nr_mapping_array, gap); - if (compare_with_wrap(tsn, asoc->highest_tsn_inside_nr_map, MAX_TSN)) { + if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) { asoc->highest_tsn_inside_nr_map = tsn; } if (tsn == (asoc->cumulative_tsn + 1)) { @@ -1646,9 +1637,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, if ((chunk_flags & SCTP_DATA_FIRST_FRAG) && (TAILQ_EMPTY(&asoc->resetHead)) && (chunk_flags & SCTP_DATA_UNORDERED) == 0 && - (compare_with_wrap(asoc->strmin[strmno].last_sequence_delivered, - strmseq, MAX_SEQ) || - asoc->strmin[strmno].last_sequence_delivered == strmseq)) { + SCTP_SSN_GE(asoc->strmin[strmno].last_sequence_delivered, strmseq)) { /* The incoming sseq is behind where we last delivered? */ SCTPDBG(SCTP_DEBUG_INDATA1, "EVIL/Broken-Dup S-SEQ:%d delivered:%d from peer, Abort!\n", strmseq, asoc->strmin[strmno].last_sequence_delivered); @@ -1759,7 +1748,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, goto failed_express_del; } SCTP_SET_TSN_PRESENT(asoc->nr_mapping_array, gap); - if (compare_with_wrap(tsn, asoc->highest_tsn_inside_nr_map, MAX_TSN)) { + if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) { asoc->highest_tsn_inside_nr_map = tsn; } sctp_add_to_readq(stcb->sctp_ep, stcb, @@ -1813,7 +1802,7 @@ failed_express_del: goto failed_pdapi_express_del; } SCTP_SET_TSN_PRESENT(asoc->nr_mapping_array, gap); - if (compare_with_wrap(tsn, asoc->highest_tsn_inside_nr_map, MAX_TSN)) { + if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) { asoc->highest_tsn_inside_nr_map = tsn; } SCTP_STAT_INCR(sctps_recvexpressm); @@ -1847,12 +1836,12 @@ failed_pdapi_express_del: control = NULL; if (SCTP_BASE_SYSCTL(sctp_do_drain) == 0) { SCTP_SET_TSN_PRESENT(asoc->nr_mapping_array, gap); - if (compare_with_wrap(tsn, asoc->highest_tsn_inside_nr_map, MAX_TSN)) { + if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) { asoc->highest_tsn_inside_nr_map = tsn; } } else { SCTP_SET_TSN_PRESENT(asoc->mapping_array, gap); - if (compare_with_wrap(tsn, asoc->highest_tsn_inside_map, MAX_TSN)) { + if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_map)) { asoc->highest_tsn_inside_map = tsn; } } @@ -2062,8 +2051,7 @@ failed_pdapi_express_del: * singletons I must worry about. */ if (((liste = TAILQ_FIRST(&asoc->resetHead)) != NULL) && - ((compare_with_wrap(tsn, liste->tsn, MAX_TSN))) - ) { + SCTP_TSN_GT(tsn, liste->tsn)) { /* * yep its past where we need to reset... go * ahead and queue it. @@ -2077,8 +2065,7 @@ failed_pdapi_express_del: unsigned char inserted = 0; TAILQ_FOREACH_SAFE(ctlOn, &asoc->pending_reply_queue, next, nctlOn) { - if (compare_with_wrap(control->sinfo_tsn, - ctlOn->sinfo_tsn, MAX_TSN)) { + if (SCTP_TSN_GT(control->sinfo_tsn, ctlOn->sinfo_tsn)) { continue; } else { /* found it */ @@ -2139,9 +2126,7 @@ finish_express_del: } /* check the special flag for stream resets */ if (((liste = TAILQ_FIRST(&asoc->resetHead)) != NULL) && - ((compare_with_wrap(asoc->cumulative_tsn, liste->tsn, MAX_TSN)) || - (asoc->cumulative_tsn == liste->tsn)) - ) { + SCTP_TSN_GE(asoc->cumulative_tsn, liste->tsn)) { /* * we have finished working through the backlogged TSN's now * time to reset streams. 1: call reset function. 2: free @@ -2166,7 +2151,7 @@ finish_express_del: } } else { TAILQ_FOREACH_SAFE(ctl, &asoc->pending_reply_queue, next, nctl) { - if (compare_with_wrap(ctl->sinfo_tsn, liste->tsn, MAX_TSN)) { + if (SCTP_TSN_GT(ctl->sinfo_tsn, liste->tsn)) { break; } /* @@ -2275,8 +2260,8 @@ sctp_slide_mapping_arrays(struct sctp_tcb *stcb) } asoc->cumulative_tsn = asoc->mapping_array_base_tsn + (at - 1); - if (compare_with_wrap(asoc->cumulative_tsn, asoc->highest_tsn_inside_map, MAX_TSN) && - compare_with_wrap(asoc->cumulative_tsn, asoc->highest_tsn_inside_nr_map, MAX_TSN)) { + if (SCTP_TSN_GT(asoc->cumulative_tsn, asoc->highest_tsn_inside_map) && + SCTP_TSN_GT(asoc->cumulative_tsn, asoc->highest_tsn_inside_nr_map)) { #ifdef INVARIANTS panic("huh, cumack 0x%x greater than high-tsn 0x%x in map", asoc->cumulative_tsn, asoc->highest_tsn_inside_map); @@ -2291,9 +2276,7 @@ sctp_slide_mapping_arrays(struct sctp_tcb *stcb) asoc->highest_tsn_inside_nr_map = asoc->cumulative_tsn; #endif } - if (compare_with_wrap(asoc->highest_tsn_inside_nr_map, - asoc->highest_tsn_inside_map, - MAX_TSN)) { + 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; @@ -2411,9 +2394,7 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap, int *abort_flag) uint32_t highest_tsn; asoc = &stcb->asoc; - if (compare_with_wrap(asoc->highest_tsn_inside_nr_map, - asoc->highest_tsn_inside_map, - MAX_TSN)) { + 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; @@ -2439,7 +2420,7 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap, int *abort_flag) int is_a_gap; /* is there a gap now ? */ - is_a_gap = compare_with_wrap(highest_tsn, stcb->asoc.cumulative_tsn, MAX_TSN); + is_a_gap = SCTP_TSN_GT(highest_tsn, stcb->asoc.cumulative_tsn); /* * CMT DAC algorithm: increase number of packets received @@ -2576,12 +2557,12 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, m = *mm; SCTP_TCB_LOCK_ASSERT(stcb); asoc = &stcb->asoc; - if (compare_with_wrap(asoc->highest_tsn_inside_nr_map, asoc->highest_tsn_inside_map, MAX_TSN)) { + 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; } - was_a_gap = compare_with_wrap(highest_tsn, stcb->asoc.cumulative_tsn, MAX_TSN); + was_a_gap = SCTP_TSN_GT(highest_tsn, stcb->asoc.cumulative_tsn); /* * setup where we got the last DATA packet from for any SACK that * may need to go out. Don't bump the net. This is done ONLY when a @@ -2889,8 +2870,8 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1 * via previous Gap Ack Blocks... * i.e. ACKED or RESEND. */ - if (compare_with_wrap(tp1->rec.data.TSN_seq, - *biggest_newly_acked_tsn, MAX_TSN)) { + if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, + *biggest_newly_acked_tsn)) { *biggest_newly_acked_tsn = tp1->rec.data.TSN_seq; } /*- @@ -2903,9 +2884,8 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1 if (tp1->rec.data.chunk_was_revoked == 0) tp1->whoTo->saw_newack = 1; - if (compare_with_wrap(tp1->rec.data.TSN_seq, - tp1->whoTo->this_sack_highest_newack, - MAX_TSN)) { + if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, + tp1->whoTo->this_sack_highest_newack)) { tp1->whoTo->this_sack_highest_newack = tp1->rec.data.TSN_seq; } @@ -2989,9 +2969,8 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1 if (tp1->sent <= SCTP_DATAGRAM_RESEND) { (*ecn_seg_sums) += tp1->rec.data.ect_nonce; (*ecn_seg_sums) &= SCTP_SACK_NONCE_SUM; - if (compare_with_wrap(tp1->rec.data.TSN_seq, - stcb->asoc.this_sack_highest_gap, - MAX_TSN)) { + if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, + stcb->asoc.this_sack_highest_gap)) { stcb->asoc.this_sack_highest_gap = tp1->rec.data.TSN_seq; } @@ -3031,10 +3010,9 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1 } break; } /* if (tp1->TSN_seq == theTSN) */ - if (compare_with_wrap(tp1->rec.data.TSN_seq, theTSN, - MAX_TSN)) + if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, theTSN)) { break; - + } tp1 = TAILQ_NEXT(tp1, sctp_next); if ((tp1 == NULL) && (circled == 0)) { circled++; @@ -3092,7 +3070,7 @@ sctp_handle_segments(struct mbuf *m, int *offset, struct sctp_tcb *stcb, struct /* This gap report is not in order, so restart. */ tp1 = TAILQ_FIRST(&asoc->sent_queue); } - if (compare_with_wrap((last_tsn + frag_end), *biggest_tsn_acked, MAX_TSN)) { + if (SCTP_TSN_GT((last_tsn + frag_end), *biggest_tsn_acked)) { *biggest_tsn_acked = last_tsn + frag_end; } if (i < num_seg) { @@ -3125,19 +3103,16 @@ sctp_check_for_revoked(struct sctp_tcb *stcb, int tot_revoked = 0; TAILQ_FOREACH(tp1, &asoc->sent_queue, sctp_next) { - if (compare_with_wrap(tp1->rec.data.TSN_seq, cumack, - MAX_TSN)) { + if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, cumack)) { /* * ok this guy is either ACK or MARKED. If it is * ACKED it has been previously acked but not this * time i.e. revoked. If it is MARKED it was ACK'ed * again. */ - if (compare_with_wrap(tp1->rec.data.TSN_seq, biggest_tsn_acked, - MAX_TSN)) + if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, biggest_tsn_acked)) { break; - - + } if (tp1->sent == SCTP_DATAGRAM_ACKED) { /* it has been revoked */ tp1->sent = SCTP_DATAGRAM_SENT; @@ -3244,8 +3219,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, tp1->sent, SCTP_FR_LOG_CHECK_STRIKE); } - if (compare_with_wrap(tp1->rec.data.TSN_seq, biggest_tsn_acked, - MAX_TSN) || + if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, biggest_tsn_acked) || tp1->sent == SCTP_DATAGRAM_UNSENT) { /* done */ break; @@ -3264,8 +3238,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, } } } - if (compare_with_wrap(tp1->rec.data.TSN_seq, - asoc->this_sack_highest_gap, MAX_TSN)) { + if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, asoc->this_sack_highest_gap)) { /* we are beyond the tsn in the sack */ break; } @@ -3289,8 +3262,8 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, * FR using this SACK. */ continue; - } else if (tp1->whoTo && compare_with_wrap(tp1->rec.data.TSN_seq, - tp1->whoTo->this_sack_highest_newack, MAX_TSN)) { + } else if (tp1->whoTo && SCTP_TSN_GT(tp1->rec.data.TSN_seq, + tp1->whoTo->this_sack_highest_newack)) { /* * CMT: New acks were receieved for data sent to * this dest. But no new acks were seen for data @@ -3341,7 +3314,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, * received after this missing TSN. */ if ((tp1->sent < SCTP_DATAGRAM_RESEND) && (num_dests_sacked == 1) && - compare_with_wrap(this_sack_lowest_newack, tp1->rec.data.TSN_seq, MAX_TSN)) { + SCTP_TSN_GT(this_sack_lowest_newack, tp1->rec.data.TSN_seq)) { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) { sctp_log_fr(16 + num_dests_sacked, tp1->rec.data.TSN_seq, @@ -3373,9 +3346,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, #endif ) { - if ((compare_with_wrap(biggest_tsn_newly_acked, - tp1->rec.data.fast_retran_tsn, MAX_TSN)) || - (biggest_tsn_newly_acked == + if (SCTP_TSN_GE(biggest_tsn_newly_acked, tp1->rec.data.fast_retran_tsn)) { /* * Strike the TSN, since this ack is @@ -3415,8 +3386,8 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, */ if ((tp1->sent < SCTP_DATAGRAM_RESEND) && (num_dests_sacked == 1) && - compare_with_wrap(this_sack_lowest_newack, - tp1->rec.data.TSN_seq, MAX_TSN)) { + SCTP_TSN_GT(this_sack_lowest_newack, + tp1->rec.data.TSN_seq)) { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) { sctp_log_fr(32 + num_dests_sacked, tp1->rec.data.TSN_seq, @@ -3434,8 +3405,8 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, * JRI: TODO: remove code for HTNA algo. CMT's SFR * algo covers HTNA. */ - } else if (compare_with_wrap(tp1->rec.data.TSN_seq, - biggest_tsn_newly_acked, MAX_TSN)) { + } else if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, + biggest_tsn_newly_acked)) { /* * We don't strike these: This is the HTNA * algorithm i.e. we don't strike If our TSN is @@ -3468,7 +3439,7 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc, * received after this missing TSN. */ if ((tp1->sent < SCTP_DATAGRAM_RESEND) && (num_dests_sacked == 1) && - compare_with_wrap(this_sack_lowest_newack, tp1->rec.data.TSN_seq, MAX_TSN)) { + SCTP_TSN_GT(this_sack_lowest_newack, tp1->rec.data.TSN_seq)) { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) { sctp_log_fr(48 + num_dests_sacked, tp1->rec.data.TSN_seq, @@ -3715,10 +3686,7 @@ sctp_try_advance_peer_ack_point(struct sctp_tcb *stcb, */ if (tp1->sent == SCTP_FORWARD_TSN_SKIP) { /* advance PeerAckPoint goes forward */ - if (compare_with_wrap(tp1->rec.data.TSN_seq, - asoc->advanced_peer_ack_point, - MAX_TSN)) { - + if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, asoc->advanced_peer_ack_point)) { asoc->advanced_peer_ack_point = tp1->rec.data.TSN_seq; a_adv = tp1; } else if (tp1->rec.data.TSN_seq == asoc->advanced_peer_ack_point) { @@ -3843,7 +3811,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, #endif asoc = &stcb->asoc; old_rwnd = asoc->peers_rwnd; - if (compare_with_wrap(asoc->last_acked_seq, cumack, MAX_TSN)) { + if (SCTP_TSN_GT(asoc->last_acked_seq, cumack)) { /* old ack */ return; } else if (asoc->last_acked_seq == cumack) { @@ -3882,8 +3850,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, } else { send_s = asoc->sending_seq; } - if ((cumack == send_s) || - compare_with_wrap(cumack, send_s, MAX_TSN)) { + if (SCTP_TSN_GE(cumack, send_s)) { #ifndef INVARIANTS struct mbuf *oper; @@ -3923,12 +3890,10 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, __LINE__); } stcb->asoc.overall_error_count = 0; - if (compare_with_wrap(cumack, asoc->last_acked_seq, MAX_TSN)) { + if (SCTP_TSN_GT(cumack, asoc->last_acked_seq)) { /* process the new consecutive TSN first */ TAILQ_FOREACH_SAFE(tp1, &asoc->sent_queue, sctp_next, tp2) { - if (compare_with_wrap(cumack, tp1->rec.data.TSN_seq, - MAX_TSN) || - cumack == tp1->rec.data.TSN_seq) { + if (SCTP_TSN_GE(cumack, tp1->rec.data.TSN_seq)) { if (tp1->sent == SCTP_DATAGRAM_UNSENT) { printf("Warning, an unsent is now acked?\n"); } @@ -4095,8 +4060,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, asoc->nonce_wait_tsn = asoc->sending_seq; } } else { - if (compare_with_wrap(asoc->last_acked_seq, asoc->nonce_wait_tsn, MAX_TSN) || - (asoc->last_acked_seq == asoc->nonce_wait_tsn)) { + if (SCTP_TSN_GE(asoc->last_acked_seq, asoc->nonce_wait_tsn)) { /* * Misbehaving peer. We need * to react to this guy @@ -4108,7 +4072,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, } } else { /* See if Resynchronization Possible */ - if (compare_with_wrap(asoc->last_acked_seq, asoc->nonce_resync_tsn, MAX_TSN)) { + if (SCTP_TSN_GT(asoc->last_acked_seq, asoc->nonce_resync_tsn)) { asoc->nonce_sum_check = 1; /* * Now we must calculate what the base is. @@ -4316,7 +4280,7 @@ again: /* (section 4.2) */ /*********************************************/ /* C1. update advancedPeerAckPoint */ - if (compare_with_wrap(cumack, asoc->advanced_peer_ack_point, MAX_TSN)) { + if (SCTP_TSN_GT(cumack, asoc->advanced_peer_ack_point)) { asoc->advanced_peer_ack_point = cumack; } /* PR-Sctp issues need to be addressed too */ @@ -4327,15 +4291,13 @@ again: old_adv_peer_ack_point = asoc->advanced_peer_ack_point; lchk = sctp_try_advance_peer_ack_point(stcb, asoc); /* C3. See if we need to send a Fwd-TSN */ - if (compare_with_wrap(asoc->advanced_peer_ack_point, cumack, - MAX_TSN)) { + if (SCTP_TSN_GT(asoc->advanced_peer_ack_point, cumack)) { /* * ISSUE with ECN, see FWD-TSN processing for notes * on issues that will occur when the ECN NONCE * stuff is put into SCTP for cross checking. */ - if (compare_with_wrap(asoc->advanced_peer_ack_point, old_adv_peer_ack_point, - MAX_TSN)) { + if (SCTP_TSN_GT(asoc->advanced_peer_ack_point, old_adv_peer_ack_point)) { send_forward_tsn(stcb, asoc); /* * ECN Nonce: Disable Nonce Sum check when @@ -4473,8 +4435,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, tp1 = NULL; send_s = asoc->sending_seq; } - if (cum_ack == send_s || - compare_with_wrap(cum_ack, send_s, MAX_TSN)) { + if (SCTP_TSN_GE(cum_ack, send_s)) { struct mbuf *oper; /* @@ -4512,7 +4473,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, /**********************/ /* 1) check the range */ /**********************/ - if (compare_with_wrap(asoc->last_acked_seq, last_tsn, MAX_TSN)) { + if (SCTP_TSN_GT(asoc->last_acked_seq, last_tsn)) { /* acking something behind */ return; } @@ -4574,9 +4535,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, } /* process the new consecutive TSN first */ TAILQ_FOREACH(tp1, &asoc->sent_queue, sctp_next) { - if (compare_with_wrap(last_tsn, tp1->rec.data.TSN_seq, - MAX_TSN) || - last_tsn == tp1->rec.data.TSN_seq) { + if (SCTP_TSN_GE(last_tsn, tp1->rec.data.TSN_seq)) { if (tp1->sent != SCTP_DATAGRAM_UNSENT) { /* * ECN Nonce: Add the nonce to the sender's @@ -4718,8 +4677,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, * validate the biggest_tsn_acked in the gap acks if * strict adherence is wanted. */ - if ((biggest_tsn_acked == send_s) || - (compare_with_wrap(biggest_tsn_acked, send_s, MAX_TSN))) { + if (SCTP_TSN_GE(biggest_tsn_acked, send_s)) { /* * peer is either confused or we are under * attack. We must abort. @@ -4757,8 +4715,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, asoc->last_acked_seq = cum_ack; TAILQ_FOREACH_SAFE(tp1, &asoc->sent_queue, sctp_next, tp2) { - if (compare_with_wrap(tp1->rec.data.TSN_seq, cum_ack, - MAX_TSN)) { + if (SCTP_TSN_GT(tp1->rec.data.TSN_seq, cum_ack)) { break; } if (tp1->sent == SCTP_DATAGRAM_UNSENT) { @@ -4835,9 +4792,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, } if (asoc->fast_retran_loss_recovery && accum_moved) { - if (compare_with_wrap(asoc->last_acked_seq, - asoc->fast_recovery_tsn, MAX_TSN) || - asoc->last_acked_seq == asoc->fast_recovery_tsn) { + if (SCTP_TSN_GE(asoc->last_acked_seq, asoc->fast_recovery_tsn)) { /* Setup so we will exit RFC2582 fast recovery */ will_exit_fast_recovery = 1; } @@ -5057,8 +5012,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, asoc->nonce_wait_tsn = asoc->sending_seq; } } else { - if (compare_with_wrap(asoc->last_acked_seq, asoc->nonce_wait_tsn, MAX_TSN) || - (asoc->last_acked_seq == asoc->nonce_wait_tsn)) { + if (SCTP_TSN_GE(asoc->last_acked_seq, asoc->nonce_wait_tsn)) { /* * Misbehaving peer. We need * to react to this guy @@ -5070,7 +5024,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, } } else { /* See if Resynchronization Possible */ - if (compare_with_wrap(asoc->last_acked_seq, asoc->nonce_resync_tsn, MAX_TSN)) { + if (SCTP_TSN_GT(asoc->last_acked_seq, asoc->nonce_resync_tsn)) { asoc->nonce_sum_check = 1; /* * now we must calculate what the base is. @@ -5097,9 +5051,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, asoc->fast_retran_loss_recovery = 0; } if ((asoc->sat_t3_loss_recovery) && - ((compare_with_wrap(asoc->last_acked_seq, asoc->sat_t3_recovery_tsn, - MAX_TSN) || - (asoc->last_acked_seq == asoc->sat_t3_recovery_tsn)))) { + SCTP_TSN_GE(asoc->last_acked_seq, asoc->sat_t3_recovery_tsn)) { /* end satellite t3 loss recovery */ asoc->sat_t3_loss_recovery = 0; } @@ -5217,7 +5169,7 @@ again: /* (section 4.2) */ /*********************************************/ /* C1. update advancedPeerAckPoint */ - if (compare_with_wrap(cum_ack, asoc->advanced_peer_ack_point, MAX_TSN)) { + if (SCTP_TSN_GT(cum_ack, asoc->advanced_peer_ack_point)) { asoc->advanced_peer_ack_point = cum_ack; } /* C2. try to further move advancedPeerAckPoint ahead */ @@ -5228,8 +5180,7 @@ again: old_adv_peer_ack_point = asoc->advanced_peer_ack_point; lchk = sctp_try_advance_peer_ack_point(stcb, asoc); /* C3. See if we need to send a Fwd-TSN */ - if (compare_with_wrap(asoc->advanced_peer_ack_point, cum_ack, - MAX_TSN)) { + if (SCTP_TSN_GT(asoc->advanced_peer_ack_point, cum_ack)) { /* * ISSUE with ECN, see FWD-TSN processing for notes * on issues that will occur when the ECN NONCE @@ -5240,8 +5191,7 @@ again: 0xee, cum_ack, asoc->advanced_peer_ack_point, old_adv_peer_ack_point); } - if (compare_with_wrap(asoc->advanced_peer_ack_point, old_adv_peer_ack_point, - MAX_TSN)) { + if (SCTP_TSN_GT(asoc->advanced_peer_ack_point, old_adv_peer_ack_point)) { send_forward_tsn(stcb, asoc); /* @@ -5302,8 +5252,7 @@ sctp_kick_prsctp_reorder_queue(struct sctp_tcb *stcb, * came in */ TAILQ_FOREACH_SAFE(ctl, &strmin->inqueue, next, nctl) { - if (compare_with_wrap(tt, ctl->sinfo_ssn, MAX_SEQ) || - (tt == ctl->sinfo_ssn)) { + if (SCTP_SSN_GE(tt, ctl->sinfo_ssn)) { /* this is deliverable now */ TAILQ_REMOVE(&strmin->inqueue, ctl, next); /* subtract pending on streams */ @@ -5378,8 +5327,7 @@ sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb, if (chk->rec.data.stream_seq == seq) { /* It needs to be tossed */ TAILQ_REMOVE(&asoc->reasmqueue, chk, sctp_next); - if (compare_with_wrap(chk->rec.data.TSN_seq, - asoc->tsn_last_delivered, MAX_TSN)) { + if (SCTP_TSN_GT(chk->rec.data.TSN_seq, asoc->tsn_last_delivered)) { asoc->tsn_last_delivered = chk->rec.data.TSN_seq; asoc->str_of_pdapi = chk->rec.data.stream_number; asoc->ssn_of_pdapi = chk->rec.data.stream_seq; @@ -5389,11 +5337,8 @@ sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb, sctp_ucount_decr(asoc->cnt_on_reasm_queue); /* Clear up any stream problem */ - if ((chk->rec.data.rcv_flags & SCTP_DATA_UNORDERED) != - SCTP_DATA_UNORDERED && - (compare_with_wrap(chk->rec.data.stream_seq, - asoc->strmin[chk->rec.data.stream_number].last_sequence_delivered, - MAX_SEQ))) { + if ((chk->rec.data.rcv_flags & SCTP_DATA_UNORDERED) != SCTP_DATA_UNORDERED && + SCTP_SSN_GT(chk->rec.data.stream_seq, asoc->strmin[chk->rec.data.stream_number].last_sequence_delivered)) { /* * We must dump forward this streams * sequence number if the chunk is not @@ -5415,7 +5360,7 @@ sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb, chk->data = NULL; } sctp_free_a_chunk(stcb, chk); - } else if (compare_with_wrap(chk->rec.data.stream_seq, seq, MAX_SEQ)) { + } else if (SCTP_SSN_GT(chk->rec.data.stream_seq, seq)) { /* * If the stream_seq is > than the purging one, we * are done @@ -5475,8 +5420,7 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, /*************************************************************/ new_cum_tsn = ntohl(fwd->new_cumulative_tsn); - if (compare_with_wrap(asoc->cumulative_tsn, new_cum_tsn, MAX_TSN) || - asoc->cumulative_tsn == new_cum_tsn) { + if (SCTP_TSN_GE(asoc->cumulative_tsn, new_cum_tsn)) { /* Already got there ... */ return; } @@ -5537,7 +5481,7 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, if (!SCTP_IS_TSN_PRESENT(asoc->mapping_array, i) && !SCTP_IS_TSN_PRESENT(asoc->nr_mapping_array, i)) { SCTP_SET_TSN_PRESENT(asoc->nr_mapping_array, i); - if (compare_with_wrap(asoc->mapping_array_base_tsn + i, asoc->highest_tsn_inside_nr_map, MAX_TSN)) { + if (SCTP_TSN_GT(asoc->mapping_array_base_tsn + i, asoc->highest_tsn_inside_nr_map)) { asoc->highest_tsn_inside_nr_map = asoc->mapping_array_base_tsn + i; } } @@ -5563,13 +5507,10 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, * queue. */ TAILQ_FOREACH_SAFE(chk, &asoc->reasmqueue, sctp_next, nchk) { - if ((compare_with_wrap(new_cum_tsn, - chk->rec.data.TSN_seq, MAX_TSN)) || - (new_cum_tsn == chk->rec.data.TSN_seq)) { + if (SCTP_TSN_GE(new_cum_tsn, chk->rec.data.TSN_seq)) { /* It needs to be tossed */ TAILQ_REMOVE(&asoc->reasmqueue, chk, sctp_next); - if (compare_with_wrap(chk->rec.data.TSN_seq, - asoc->tsn_last_delivered, MAX_TSN)) { + if (SCTP_TSN_GT(chk->rec.data.TSN_seq, asoc->tsn_last_delivered)) { asoc->tsn_last_delivered = chk->rec.data.TSN_seq; asoc->str_of_pdapi = chk->rec.data.stream_number; asoc->ssn_of_pdapi = chk->rec.data.stream_seq; @@ -5579,11 +5520,8 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, sctp_ucount_decr(asoc->cnt_on_reasm_queue); /* Clear up any stream problem */ - if ((chk->rec.data.rcv_flags & SCTP_DATA_UNORDERED) != - SCTP_DATA_UNORDERED && - (compare_with_wrap(chk->rec.data.stream_seq, - asoc->strmin[chk->rec.data.stream_number].last_sequence_delivered, - MAX_SEQ))) { + if ((chk->rec.data.rcv_flags & SCTP_DATA_UNORDERED) != SCTP_DATA_UNORDERED && + SCTP_SSN_GT(chk->rec.data.stream_seq, asoc->strmin[chk->rec.data.stream_number].last_sequence_delivered)) { /* * We must dump forward this streams * sequence number if the chunk is not @@ -5681,17 +5619,15 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, stcb->asoc.control_pdapi = sv; break; } else if ((ctl->sinfo_stream == stseq->stream) && - (compare_with_wrap(ctl->sinfo_ssn, stseq->sequence, MAX_SEQ))) { + SCTP_SSN_GT(ctl->sinfo_ssn, stseq->sequence)) { /* We are past our victim SSN */ break; } } strm = &asoc->strmin[stseq->stream]; - if (compare_with_wrap(stseq->sequence, - strm->last_sequence_delivered, MAX_SEQ)) { + if (SCTP_SSN_GT(stseq->sequence, strm->last_sequence_delivered)) { /* Update the sequence number */ - strm->last_sequence_delivered = - stseq->sequence; + strm->last_sequence_delivered = stseq->sequence; } /* now kick the stream the new way */ /* sa_ignore NO_NULL_CHK */ |