/* reset the TSN for striking and other FR stuff */
chk->rec.data.doing_fast_retransmit = 0; /* Clear any time so NO RTT is being done */
if (chk->do_rtt) { if (chk->whoTo->rto_needed == 0) {
chk->whoTo->rto_needed = 1;
}
}
chk->do_rtt = 0; if (alt != net) {
sctp_free_remote_addr(chk->whoTo);
chk->no_fr_allowed = 1;
chk->whoTo = alt;
atomic_add_int(&alt->ref_count, 1);
} else {
chk->no_fr_allowed = 0; if (TAILQ_EMPTY(&stcb->asoc.send_queue)) {
chk->rec.data.fast_retran_tsn = stcb->asoc.sending_seq;
} else {
chk->rec.data.fast_retran_tsn = (TAILQ_FIRST(&stcb->asoc.send_queue))->rec.data.tsn;
}
} /* CMT: Do not allow FRs on retransmitted TSNs.
*/ if (stcb->asoc.sctp_cmt_on_off > 0) {
chk->no_fr_allowed = 1;
} #ifdef THIS_SHOULD_NOT_BE_DONE
} elseif (chk->sent == SCTP_DATAGRAM_ACKED) { /* remember highest acked one */
could_be_sent = chk; #endif
} if (chk->sent == SCTP_DATAGRAM_RESEND) {
cnt_mk++;
}
} if ((orig_flight - net->flight_size) != (orig_tf - stcb->asoc.total_flight)) { /* we did not subtract the same things? */
audit_tf = 1;
}
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
sctp_log_fr(tsnfirst, tsnlast, num_mk, SCTP_FR_T3_TIMEOUT);
} #ifdef SCTP_DEBUG if (num_mk) {
SCTPDBG(SCTP_DEBUG_TIMER1, "LAST TSN marked was %x\n",
tsnlast);
SCTPDBG(SCTP_DEBUG_TIMER1, "Num marked for retransmission was %d peer-rwd:%u\n",
num_mk,
stcb->asoc.peers_rwnd);
} #endif
*num_marked = num_mk;
*num_abandoned = cnt_abandoned; /* Now check for a ECN Echo that may be stranded And *includethecnt_mk'dtohaveallresendsinthe *controlqueue.
*/
TAILQ_FOREACH(chk, &stcb->asoc.control_send_queue, sctp_next) { if (chk->sent == SCTP_DATAGRAM_RESEND) {
cnt_mk++;
} if ((chk->whoTo == net) &&
(chk->rec.chunk_id.id == SCTP_ECN_ECHO)) {
sctp_free_remote_addr(chk->whoTo);
chk->whoTo = alt; if (chk->sent != SCTP_DATAGRAM_RESEND) {
chk->sent = SCTP_DATAGRAM_RESEND;
chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
cnt_mk++;
}
atomic_add_int(&alt->ref_count, 1);
}
} #ifdef THIS_SHOULD_NOT_BE_DONE if ((stcb->asoc.sent_queue_retran_cnt == 0) && (could_be_sent)) { /* fix it so we retransmit the highest acked anyway */
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
cnt_mk++;
could_be_sent->sent = SCTP_DATAGRAM_RESEND;
} #endif if (stcb->asoc.sent_queue_retran_cnt != cnt_mk) { #ifdef INVARIANTS
SCTP_PRINTF("Local Audit says there are %d for retran asoc cnt:%d we marked:%d this time\n",
cnt_mk, stcb->asoc.sent_queue_retran_cnt, num_mk); #endif #ifndef SCTP_AUDITING_ENABLED
stcb->asoc.sent_queue_retran_cnt = cnt_mk; #endif
} if (audit_tf) {
SCTPDBG(SCTP_DEBUG_TIMER4, "Audit total flight due to negative value net:%p\n",
(void *)net);
stcb->asoc.total_flight = 0;
stcb->asoc.total_flight_count = 0; /* Clear all networks flight size */
TAILQ_FOREACH(lnets, &stcb->asoc.nets, sctp_next) {
lnets->flight_size = 0;
SCTPDBG(SCTP_DEBUG_TIMER4, "Net:%p c-f cwnd:%d ssthresh:%d\n",
(void *)lnets, lnets->cwnd, lnets->ssthresh);
}
TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) { if (chk->sent < SCTP_DATAGRAM_RESEND) { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FLIGHT_LOGGING_ENABLE) {
sctp_misc_ints(SCTP_FLIGHT_LOG_UP,
chk->whoTo->flight_size,
chk->book_size,
(uint32_t)(uintptr_t)chk->whoTo,
chk->rec.data.tsn);
}
sctp_flight_size_increase(chk);
sctp_total_flight_increase(stcb, chk);
}
}
} /* We return 1 if we only have a window probe outstanding */ return (0);
}
int
sctp_t3rxt_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sctp_nets *net)
{ struct sctp_nets *alt; int win_probe, num_mk, num_abandoned;
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
sctp_log_fr(0, 0, 0, SCTP_FR_T3_TIMEOUT);
} if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_LOGGING_ENABLE) { struct sctp_nets *lnet;
TAILQ_FOREACH(lnet, &stcb->asoc.nets, sctp_next) { if (net == lnet) {
sctp_log_cwnd(stcb, lnet, 1, SCTP_CWND_LOG_FROM_T3);
} else {
sctp_log_cwnd(stcb, lnet, 0, SCTP_CWND_LOG_FROM_T3);
}
}
} /* Find an alternate and mark those for retransmission */ if ((stcb->asoc.peers_rwnd == 0) &&
(stcb->asoc.total_flight < net->mtu)) {
SCTP_STAT_INCR(sctps_timowindowprobe);
win_probe = 1;
} else {
win_probe = 0;
}
if (win_probe == 0) { /* We don't do normal threshold management on window probes */ if (sctp_threshold_management(inp, stcb, net,
stcb->asoc.max_send_times)) { /* Association was destroyed */ return (1);
} else { if (net != stcb->asoc.primary_destination) { /* send a immediate HB if our RTO is stale */ struct timeval now;
uint32_t ms_goneby;
num_mk = 0;
num_abandoned = 0;
(void)sctp_mark_all_for_resend(stcb, net, alt, win_probe,
&num_mk, &num_abandoned); /* FR Loss recovery just ended with the T3. */
stcb->asoc.fast_retran_loss_recovery = 0;
/* CMT FR loss recovery ended with the T3 */
net->fast_retran_loss_recovery = 0; if ((stcb->asoc.cc_functions.sctp_cwnd_new_transmission_begins) &&
(net->flight_size == 0)) {
(*stcb->asoc.cc_functions.sctp_cwnd_new_transmission_begins)(stcb, net);
}
/* Backoff the timer and cwnd */
sctp_backoff_on_timeout(stcb, net, win_probe, num_mk, num_abandoned); if (((net->dest_state & SCTP_ADDR_REACHABLE) == 0) ||
(net->dest_state & SCTP_ADDR_PF)) { /* Move all pending over too */
sctp_move_chunks_from_net(stcb, net);
/* Get the address that failed, to *forceanewsrcaddressselectionand *arouteallocation.
*/ if (net->ro._s_addr != NULL) {
sctp_free_ifa(net->ro._s_addr);
net->ro._s_addr = NULL;
}
net->src_addr_selected = 0;
/* Force a route allocation too */ #ifdefined(__FreeBSD__) && !defined(__Userspace__)
RO_NHFREE(&net->ro); #else if (net->ro.ro_rt != NULL) {
RTFREE(net->ro.ro_rt);
net->ro.ro_rt = NULL;
} #endif
/* first before all else we must find the cookie */
TAILQ_FOREACH(cookie, &stcb->asoc.control_send_queue, sctp_next) { if (cookie->rec.chunk_id.id == SCTP_COOKIE_ECHO) { break;
}
} if (cookie == NULL) { if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED) { /* FOOBAR! */ struct mbuf *op_err;
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), "Cookie timer expired, but no cookie");
inp->last_abort_code = SCTP_FROM_SCTP_TIMER + SCTP_LOC_3;
sctp_abort_an_association(inp, stcb, op_err, false, SCTP_SO_NOT_LOCKED);
} else { #ifdef INVARIANTS
panic("Cookie timer expires in wrong state?"); #else
SCTP_PRINTF("Strange in state %d not cookie-echoed yet c-e timer expires?\n", SCTP_GET_STATE(stcb)); return (0); #endif
} return (0);
} /* Ok we found the cookie, threshold management next */ if (sctp_threshold_management(inp, stcb, cookie->whoTo,
stcb->asoc.max_init_times)) { /* Assoc is over */ return (1);
} /* *Clearedthresholdmanagement,nowletsbackofftheaddress *andselectanalternate
*/
stcb->asoc.dropped_special_cnt = 0;
sctp_backoff_on_timeout(stcb, cookie->whoTo, 1, 0, 0);
alt = sctp_find_alternate_net(stcb, cookie->whoTo, 0); if (alt != cookie->whoTo) {
sctp_free_remote_addr(cookie->whoTo);
cookie->whoTo = alt;
atomic_add_int(&alt->ref_count, 1);
} /* Now mark the retran info */ if (cookie->sent != SCTP_DATAGRAM_RESEND) {
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
}
cookie->sent = SCTP_DATAGRAM_RESEND;
cookie->flags |= CHUNK_FLAGS_FRAGMENT_OK; /* *Nowcalltheoutputroutinetokickoutthecookieagain,Notewe *don'tmarkanychunksforretransothatFRwillneedtokickin *tomovethese(orasendtimer).
*/ return (0);
}
if (stcb->asoc.stream_reset_outstanding == 0) { return (0);
} /* find the existing STRRESET, we use the seq number we sent out on */
(void)sctp_find_stream_reset(stcb, stcb->asoc.str_reset_seq_out, &strrst); if (strrst == NULL) { return (0);
}
net = strrst->whoTo; /* do threshold management */ if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) { /* Assoc is over */ return (1);
} /* *Clearedthresholdmanagement,nowletsbackofftheaddress *andselectanalternate
*/
sctp_backoff_on_timeout(stcb, net, 1, 0, 0);
alt = sctp_find_alternate_net(stcb, net, 0);
strrst->whoTo = alt;
atomic_add_int(&alt->ref_count, 1);
/* See if a ECN Echo is also stranded */
TAILQ_FOREACH(chk, &stcb->asoc.control_send_queue, sctp_next) { if ((chk->whoTo == net) &&
(chk->rec.chunk_id.id == SCTP_ECN_ECHO)) {
sctp_free_remote_addr(chk->whoTo); if (chk->sent != SCTP_DATAGRAM_RESEND) {
chk->sent = SCTP_DATAGRAM_RESEND;
chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
}
chk->whoTo = alt;
atomic_add_int(&alt->ref_count, 1);
}
} if ((net->dest_state & SCTP_ADDR_REACHABLE) == 0) { /* *Iftheaddresswentun-reachable,weneedtomoveto *alternatesforALLchk'sinqueue
*/
sctp_move_chunks_from_net(stcb, net);
}
sctp_free_remote_addr(net);
/* mark the retran info */ if (strrst->sent != SCTP_DATAGRAM_RESEND)
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
strrst->sent = SCTP_DATAGRAM_RESEND;
strrst->flags |= CHUNK_FLAGS_FRAGMENT_OK;
/* is this a first send, or a retransmission? */ if (TAILQ_EMPTY(&stcb->asoc.asconf_send_queue)) { /* compose a new ASCONF chunk and send it */
sctp_send_asconf(stcb, net, SCTP_ADDR_NOT_LOCKED);
} else { /* *RetransmissionoftheexistingASCONFisneeded
*/
/* find the existing ASCONF */
asconf = TAILQ_FIRST(&stcb->asoc.asconf_send_queue); if (asconf == NULL) { return (0);
}
net = asconf->whoTo; /* do threshold management */ if (sctp_threshold_management(inp, stcb, net,
stcb->asoc.max_send_times)) { /* Assoc is over */ return (1);
} if (asconf->snd_count > stcb->asoc.max_send_times) { /* *Somethingisrotten:ourpeerisnotrespondingto *ASCONFsbutapparentlyistootherchunks.i.e.it *isnotproperlyhandlingthechunktypeupperbits. *MarkthispeerasASCONFincapableandcleanup.
*/
SCTPDBG(SCTP_DEBUG_TIMER1, "asconf_timer: Peer has not responded to our repeated ASCONFs\n");
sctp_asconf_cleanup(stcb); return (0);
} /* *clearedthresholdmanagement,sonowbackoffthenetand *selectanalternate
*/
sctp_backoff_on_timeout(stcb, net, 1, 0, 0);
alt = sctp_find_alternate_net(stcb, net, 0); if (asconf->whoTo != alt) {
asconf->whoTo = alt;
atomic_add_int(&alt->ref_count, 1);
}
/* See if an ECN Echo is also stranded */
TAILQ_FOREACH(chk, &stcb->asoc.control_send_queue, sctp_next) { if ((chk->whoTo == net) &&
(chk->rec.chunk_id.id == SCTP_ECN_ECHO)) {
sctp_free_remote_addr(chk->whoTo);
chk->whoTo = alt; if (chk->sent != SCTP_DATAGRAM_RESEND) {
chk->sent = SCTP_DATAGRAM_RESEND;
chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
}
atomic_add_int(&alt->ref_count, 1);
}
}
TAILQ_FOREACH(chk, &stcb->asoc.asconf_send_queue, sctp_next) { if (chk->whoTo != alt) {
sctp_free_remote_addr(chk->whoTo);
chk->whoTo = alt;
atomic_add_int(&alt->ref_count, 1);
} if (asconf->sent != SCTP_DATAGRAM_RESEND && chk->sent != SCTP_DATAGRAM_UNSENT)
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
chk->sent = SCTP_DATAGRAM_RESEND;
chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
} if ((net->dest_state & SCTP_ADDR_REACHABLE) == 0) { /* *Iftheaddresswentun-reachable,weneedtomove *tothealternateforALLchunksinqueue
*/
sctp_move_chunks_from_net(stcb, net);
}
sctp_free_remote_addr(net);
/* mark the retran info */ if (asconf->sent != SCTP_DATAGRAM_RESEND)
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
asconf->sent = SCTP_DATAGRAM_RESEND;
asconf->flags |= CHUNK_FLAGS_FRAGMENT_OK;
/* send another ASCONF if any and we can do */
sctp_send_asconf(stcb, alt, SCTP_ADDR_NOT_LOCKED);
} return (0);
}
/* first threshold management */ if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) { /* Assoc is over */ return (1);
}
sctp_backoff_on_timeout(stcb, net, 1, 0, 0); /* second select an alternative */
alt = sctp_find_alternate_net(stcb, net, 0);
/* third generate a shutdown into the queue for out net */
sctp_send_shutdown(stcb, alt);
/* first threshold management */ if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) { /* Assoc is over */ return (1);
}
sctp_backoff_on_timeout(stcb, net, 1, 0, 0); /* second select an alternative */
alt = sctp_find_alternate_net(stcb, net, 0);
/* third generate a shutdown into the queue for out net */
sctp_send_shutdown_ack(stcb, alt);
staticvoid
sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
{ struct sctp_stream_queue_pending *sp; unsignedint i, chks_in_queue = 0; int being_filled = 0;
KASSERT(inp != NULL, ("inp is NULL"));
KASSERT(stcb != NULL, ("stcb is NULL"));
SCTP_TCB_LOCK_ASSERT(stcb);
KASSERT(TAILQ_EMPTY(&stcb->asoc.send_queue), ("send_queue not empty"));
KASSERT(TAILQ_EMPTY(&stcb->asoc.sent_queue), ("sent_queue not empty"));
if (stcb->asoc.sent_queue_retran_cnt) {
SCTP_PRINTF("Hmm, sent_queue_retran_cnt is non-zero %d\n",
stcb->asoc.sent_queue_retran_cnt);
stcb->asoc.sent_queue_retran_cnt = 0;
} if (stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, &stcb->asoc)) { /* No stream scheduler information, initialize scheduler */
stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc); if (!stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, &stcb->asoc)) { /* yep, we lost a stream or two */
SCTP_PRINTF("Found additional streams NOT managed by scheduler, corrected\n");
} else { /* no streams lost */
stcb->asoc.total_output_queue_size = 0;
}
} /* Check to see if some data queued, if so report it */ for (i = 0; i < stcb->asoc.streamoutcnt; i++) { if (!TAILQ_EMPTY(&stcb->asoc.strmout[i].outqueue)) {
TAILQ_FOREACH(sp, &stcb->asoc.strmout[i].outqueue, next) { if (sp->msg_is_complete)
being_filled++;
chks_in_queue++;
}
}
} if (chks_in_queue != stcb->asoc.stream_queue_cnt) {
SCTP_PRINTF("Hmm, stream queue cnt at %d I counted %d in stream out wheel\n",
stcb->asoc.stream_queue_cnt, chks_in_queue);
} if (chks_in_queue) { /* call the output queue function */
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_NOT_LOCKED); if ((TAILQ_EMPTY(&stcb->asoc.send_queue)) &&
(TAILQ_EMPTY(&stcb->asoc.sent_queue))) { /* *Probablyshouldgoinandmakeitgobackthrough *andaddfragmentsallowed
*/ if (being_filled == 0) {
SCTP_PRINTF("Still nothing moved %d chunks are stuck\n",
chks_in_queue);
}
}
} else {
SCTP_PRINTF("Found no chunks on any queue tot:%lu\n",
(u_long)stcb->asoc.total_output_queue_size);
stcb->asoc.total_output_queue_size = 0;
}
}
net_was_pf = (net->dest_state & SCTP_ADDR_PF) != 0; if (net->hb_responded == 0) { if (net->ro._s_addr != NULL) { /* Invalidate the src address if we did not get *aresponselasttime.
*/
sctp_free_ifa(net->ro._s_addr);
net->ro._s_addr = NULL;
net->src_addr_selected = 0;
}
sctp_backoff_on_timeout(stcb, net, 1, 0, 0); if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) { /* Assoc is over */ return (1);
}
} /* Zero PBA, if it needs it */ if (net->partial_bytes_acked > 0) {
net->partial_bytes_acked = 0;
} if ((stcb->asoc.total_output_queue_size > 0) &&
(TAILQ_EMPTY(&stcb->asoc.send_queue)) &&
(TAILQ_EMPTY(&stcb->asoc.sent_queue))) {
sctp_audit_stream_queues_for_size(inp, stcb);
} if ((((net->dest_state & SCTP_ADDR_NOHB) == 0) ||
(net->dest_state & SCTP_ADDR_UNCONFIRMED)) &&
(net_was_pf || ((net->dest_state & SCTP_ADDR_PF) == 0))) { /* When moving to PF during threshold management, a HB has been
queued in that routine. */
uint32_t ms_gone_by;
(void)SCTP_GETTIME_TIMEVAL(&tn); if (stcb->asoc.sctp_autoclose_ticks > 0 &&
sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) { /* Auto close is on */
asoc = &stcb->asoc; /* pick the time to use */ if (asoc->time_last_rcvd.tv_sec >
asoc->time_last_sent.tv_sec) {
tim_touse = &asoc->time_last_rcvd;
} else {
tim_touse = &asoc->time_last_sent;
} /* Now has long enough transpired to autoclose? */
ticks_gone_by = sctp_secs_to_ticks((uint32_t)(tn.tv_sec - tim_touse->tv_sec)); if (ticks_gone_by >= asoc->sctp_autoclose_ticks) { /* *autoclosetimehashit,calltheoutputroutine, *whichshoulddonothingjusttobeSUREwedon't *havehangingdata.Wecanthensafelycheckthe *queuesandknowthatwearecleartosend *shutdown
*/
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_AUTOCLOSE_TMR, SCTP_SO_NOT_LOCKED); /* Are we clean? */ if (TAILQ_EMPTY(&asoc->send_queue) &&
TAILQ_EMPTY(&asoc->sent_queue)) { /* *thereisnothingqueuedtosend,soI'm *done...
*/ if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) { /* only send SHUTDOWN 1st time thru */ struct sctp_nets *net;
/* fool the timer startup to use the time left */
tmp = asoc->sctp_autoclose_ticks;
asoc->sctp_autoclose_ticks -= ticks_gone_by;
sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, NULL); /* restore the real tick value */
asoc->sctp_autoclose_ticks = tmp;
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.