2006-11-03 15:23:16 +00:00
|
|
|
/*-
|
2007-05-08 17:01:12 +00:00
|
|
|
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
2012-05-23 11:26:28 +00:00
|
|
|
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
|
|
|
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
2006-11-03 15:23:16 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* a) Redistributions of source code must retain the above copyright notice,
|
2011-12-17 19:21:40 +00:00
|
|
|
* this list of conditions and the following disclaimer.
|
2006-11-03 15:23:16 +00:00
|
|
|
*
|
|
|
|
* b) Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
2011-12-17 19:21:40 +00:00
|
|
|
* the documentation and/or other materials provided with the distribution.
|
2006-11-03 15:23:16 +00:00
|
|
|
*
|
|
|
|
* c) Neither the name of Cisco Systems, Inc. nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#define _IP_VHL
|
2007-01-18 09:58:43 +00:00
|
|
|
#include <netinet/sctp_os.h>
|
2006-11-03 15:23:16 +00:00
|
|
|
#include <netinet/sctp_pcb.h>
|
|
|
|
#ifdef INET6
|
|
|
|
#endif
|
|
|
|
#include <netinet/sctp_var.h>
|
2007-03-15 11:27:14 +00:00
|
|
|
#include <netinet/sctp_sysctl.h>
|
2006-11-03 15:23:16 +00:00
|
|
|
#include <netinet/sctp_timer.h>
|
|
|
|
#include <netinet/sctputil.h>
|
|
|
|
#include <netinet/sctp_output.h>
|
|
|
|
#include <netinet/sctp_header.h>
|
|
|
|
#include <netinet/sctp_indata.h>
|
|
|
|
#include <netinet/sctp_asconf.h>
|
|
|
|
#include <netinet/sctp_input.h>
|
|
|
|
#include <netinet/sctp.h>
|
|
|
|
#include <netinet/sctp_uio.h>
|
2014-07-11 06:52:48 +00:00
|
|
|
#if defined(INET) || defined(INET6)
|
2008-12-06 13:19:54 +00:00
|
|
|
#include <netinet/udp.h>
|
2014-07-11 06:52:48 +00:00
|
|
|
#endif
|
2006-11-03 15:23:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
sctp_audit_retranmission_queue(struct sctp_association *asoc)
|
|
|
|
{
|
|
|
|
struct sctp_tmit_chunk *chk;
|
|
|
|
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTPDBG(SCTP_DEBUG_TIMER4, "Audit invoked on send queue cnt:%d onqueue:%d\n",
|
|
|
|
asoc->sent_queue_retran_cnt,
|
|
|
|
asoc->sent_queue_cnt);
|
2006-11-03 15:23:16 +00:00
|
|
|
asoc->sent_queue_retran_cnt = 0;
|
|
|
|
asoc->sent_queue_cnt = 0;
|
|
|
|
TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) {
|
|
|
|
if (chk->sent == SCTP_DATAGRAM_RESEND) {
|
|
|
|
sctp_ucount_incr(asoc->sent_queue_retran_cnt);
|
|
|
|
}
|
|
|
|
asoc->sent_queue_cnt++;
|
|
|
|
}
|
|
|
|
TAILQ_FOREACH(chk, &asoc->control_send_queue, sctp_next) {
|
|
|
|
if (chk->sent == SCTP_DATAGRAM_RESEND) {
|
|
|
|
sctp_ucount_incr(asoc->sent_queue_retran_cnt);
|
|
|
|
}
|
|
|
|
}
|
2008-05-20 13:47:46 +00:00
|
|
|
TAILQ_FOREACH(chk, &asoc->asconf_send_queue, sctp_next) {
|
|
|
|
if (chk->sent == SCTP_DATAGRAM_RESEND) {
|
|
|
|
sctp_ucount_incr(asoc->sent_queue_retran_cnt);
|
|
|
|
}
|
|
|
|
}
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTPDBG(SCTP_DEBUG_TIMER4, "Audit completes retran:%d onqueue:%d\n",
|
|
|
|
asoc->sent_queue_retran_cnt,
|
|
|
|
asoc->sent_queue_cnt);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
|
2016-02-17 18:04:22 +00:00
|
|
|
static int
|
2006-11-03 15:23:16 +00:00
|
|
|
sctp_threshold_management(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|
|
|
struct sctp_nets *net, uint16_t threshold)
|
|
|
|
{
|
|
|
|
if (net) {
|
|
|
|
net->error_count++;
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTPDBG(SCTP_DEBUG_TIMER4, "Error count for %p now %d thresh:%d\n",
|
2012-09-05 18:52:01 +00:00
|
|
|
(void *)net, net->error_count,
|
2007-05-09 13:30:06 +00:00
|
|
|
net->failure_threshold);
|
2006-11-03 15:23:16 +00:00
|
|
|
if (net->error_count > net->failure_threshold) {
|
|
|
|
/* We had a threshold failure */
|
|
|
|
if (net->dest_state & SCTP_ADDR_REACHABLE) {
|
|
|
|
net->dest_state &= ~SCTP_ADDR_REACHABLE;
|
2007-03-15 11:27:14 +00:00
|
|
|
net->dest_state &= ~SCTP_ADDR_REQ_PRIMARY;
|
2011-08-03 20:21:00 +00:00
|
|
|
net->dest_state &= ~SCTP_ADDR_PF;
|
2006-11-03 15:23:16 +00:00
|
|
|
sctp_ulp_notify(SCTP_NOTIFY_INTERFACE_DOWN,
|
2012-05-13 17:36:04 +00:00
|
|
|
stcb, 0,
|
2007-09-08 11:35:11 +00:00
|
|
|
(void *)net, SCTP_SO_NOT_LOCKED);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
2011-08-03 20:21:00 +00:00
|
|
|
} else if ((net->pf_threshold < net->failure_threshold) &&
|
|
|
|
(net->error_count > net->pf_threshold)) {
|
|
|
|
if (!(net->dest_state & SCTP_ADDR_PF)) {
|
|
|
|
net->dest_state |= SCTP_ADDR_PF;
|
|
|
|
net->last_active = sctp_get_tick_count();
|
|
|
|
sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED);
|
2015-05-28 16:00:23 +00:00
|
|
|
sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT,
|
2016-02-17 18:04:22 +00:00
|
|
|
inp, stcb, net,
|
2015-05-28 16:00:23 +00:00
|
|
|
SCTP_FROM_SCTP_TIMER + SCTP_LOC_1);
|
2016-02-17 18:04:22 +00:00
|
|
|
sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net);
|
2011-08-03 20:21:00 +00:00
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (stcb == NULL)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
if (net) {
|
|
|
|
if ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0) {
|
2008-06-14 07:58:05 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) {
|
2007-08-24 00:53:53 +00:00
|
|
|
sctp_misc_ints(SCTP_THRESHOLD_INCR,
|
|
|
|
stcb->asoc.overall_error_count,
|
|
|
|
(stcb->asoc.overall_error_count + 1),
|
|
|
|
SCTP_FROM_SCTP_TIMER,
|
|
|
|
__LINE__);
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
stcb->asoc.overall_error_count++;
|
|
|
|
}
|
|
|
|
} else {
|
2008-06-14 07:58:05 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) {
|
2007-08-24 00:53:53 +00:00
|
|
|
sctp_misc_ints(SCTP_THRESHOLD_INCR,
|
|
|
|
stcb->asoc.overall_error_count,
|
|
|
|
(stcb->asoc.overall_error_count + 1),
|
|
|
|
SCTP_FROM_SCTP_TIMER,
|
|
|
|
__LINE__);
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
stcb->asoc.overall_error_count++;
|
|
|
|
}
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTPDBG(SCTP_DEBUG_TIMER4, "Overall error count for %p now %d thresh:%u state:%x\n",
|
2012-09-05 18:52:01 +00:00
|
|
|
(void *)&stcb->asoc, stcb->asoc.overall_error_count,
|
2016-12-26 11:06:41 +00:00
|
|
|
(uint32_t)threshold,
|
|
|
|
((net == NULL) ? (uint32_t)0 : (uint32_t)net->dest_state));
|
2006-11-03 15:23:16 +00:00
|
|
|
/*
|
|
|
|
* We specifically do not do >= to give the assoc one more change
|
|
|
|
* before we fail it.
|
|
|
|
*/
|
|
|
|
if (stcb->asoc.overall_error_count > threshold) {
|
|
|
|
/* Abort notification sends a ULP notify */
|
2014-03-16 12:32:16 +00:00
|
|
|
struct mbuf *op_err;
|
2006-11-03 15:23:16 +00:00
|
|
|
|
2015-07-27 22:35:54 +00:00
|
|
|
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
|
2015-03-10 09:16:31 +00:00
|
|
|
"Association error counter exceeded");
|
2015-05-28 16:00:23 +00:00
|
|
|
inp->last_abort_code = SCTP_FROM_SCTP_TIMER + SCTP_LOC_2;
|
2014-03-16 12:32:16 +00:00
|
|
|
sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED);
|
2006-11-03 15:23:16 +00:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2010-11-07 17:44:04 +00:00
|
|
|
/*
|
|
|
|
* sctp_find_alternate_net() returns a non-NULL pointer as long
|
|
|
|
* the argument net is non-NULL.
|
|
|
|
*/
|
2006-11-03 15:23:16 +00:00
|
|
|
struct sctp_nets *
|
|
|
|
sctp_find_alternate_net(struct sctp_tcb *stcb,
|
|
|
|
struct sctp_nets *net,
|
2007-07-14 09:36:28 +00:00
|
|
|
int mode)
|
2006-11-03 15:23:16 +00:00
|
|
|
{
|
|
|
|
/* Find and return an alternate network if possible */
|
2007-07-14 09:36:28 +00:00
|
|
|
struct sctp_nets *alt, *mnet, *min_errors_net = NULL, *max_cwnd_net = NULL;
|
2006-11-03 15:23:16 +00:00
|
|
|
int once;
|
2007-07-14 09:36:28 +00:00
|
|
|
|
|
|
|
/* JRS 5/14/07 - Initialize min_errors to an impossible value. */
|
|
|
|
int min_errors = -1;
|
|
|
|
uint32_t max_cwnd = 0;
|
2006-11-03 15:23:16 +00:00
|
|
|
|
|
|
|
if (stcb->asoc.numnets == 1) {
|
|
|
|
/* No others but net */
|
|
|
|
return (TAILQ_FIRST(&stcb->asoc.nets));
|
|
|
|
}
|
2007-07-14 09:36:28 +00:00
|
|
|
/*
|
|
|
|
* JRS 5/14/07 - If mode is set to 2, use the CMT PF find alternate
|
|
|
|
* net algorithm. This algorithm chooses the active destination (not
|
|
|
|
* in PF state) with the largest cwnd value. If all destinations are
|
|
|
|
* in PF state, unreachable, or unconfirmed, choose the desination
|
|
|
|
* that is in PF state with the lowest error count. In case of a
|
|
|
|
* tie, choose the destination that was most recently active.
|
|
|
|
*/
|
|
|
|
if (mode == 2) {
|
|
|
|
TAILQ_FOREACH(mnet, &stcb->asoc.nets, sctp_next) {
|
2016-12-26 11:06:41 +00:00
|
|
|
/*
|
|
|
|
* JRS 5/14/07 - If the destination is unreachable
|
|
|
|
* or unconfirmed, skip it.
|
|
|
|
*/
|
2007-07-14 09:36:28 +00:00
|
|
|
if (((mnet->dest_state & SCTP_ADDR_REACHABLE) != SCTP_ADDR_REACHABLE) ||
|
|
|
|
(mnet->dest_state & SCTP_ADDR_UNCONFIRMED)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* JRS 5/14/07 - If the destination is reachable
|
|
|
|
* but in PF state, compare the error count of the
|
|
|
|
* destination to the minimum error count seen thus
|
|
|
|
* far. Store the destination with the lower error
|
|
|
|
* count. If the error counts are equal, store the
|
|
|
|
* destination that was most recently active.
|
|
|
|
*/
|
|
|
|
if (mnet->dest_state & SCTP_ADDR_PF) {
|
|
|
|
/*
|
|
|
|
* JRS 5/14/07 - If the destination under
|
|
|
|
* consideration is the current destination,
|
|
|
|
* work as if the error count is one higher.
|
|
|
|
* The actual error count will not be
|
|
|
|
* incremented until later in the t3
|
|
|
|
* handler.
|
|
|
|
*/
|
|
|
|
if (mnet == net) {
|
|
|
|
if (min_errors == -1) {
|
|
|
|
min_errors = mnet->error_count + 1;
|
|
|
|
min_errors_net = mnet;
|
|
|
|
} else if (mnet->error_count + 1 < min_errors) {
|
|
|
|
min_errors = mnet->error_count + 1;
|
|
|
|
min_errors_net = mnet;
|
|
|
|
} else if (mnet->error_count + 1 == min_errors
|
|
|
|
&& mnet->last_active > min_errors_net->last_active) {
|
|
|
|
min_errors_net = mnet;
|
|
|
|
min_errors = mnet->error_count + 1;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
if (min_errors == -1) {
|
|
|
|
min_errors = mnet->error_count;
|
|
|
|
min_errors_net = mnet;
|
|
|
|
} else if (mnet->error_count < min_errors) {
|
|
|
|
min_errors = mnet->error_count;
|
|
|
|
min_errors_net = mnet;
|
|
|
|
} else if (mnet->error_count == min_errors
|
|
|
|
&& mnet->last_active > min_errors_net->last_active) {
|
|
|
|
min_errors_net = mnet;
|
|
|
|
min_errors = mnet->error_count;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* JRS 5/14/07 - If the destination is reachable and
|
|
|
|
* not in PF state, compare the cwnd of the
|
|
|
|
* destination to the highest cwnd seen thus far.
|
|
|
|
* Store the destination with the higher cwnd value.
|
|
|
|
* If the cwnd values are equal, randomly choose one
|
|
|
|
* of the two destinations.
|
|
|
|
*/
|
|
|
|
if (max_cwnd < mnet->cwnd) {
|
|
|
|
max_cwnd_net = mnet;
|
|
|
|
max_cwnd = mnet->cwnd;
|
|
|
|
} else if (max_cwnd == mnet->cwnd) {
|
|
|
|
uint32_t rndval;
|
|
|
|
uint8_t this_random;
|
|
|
|
|
|
|
|
if (stcb->asoc.hb_random_idx > 3) {
|
|
|
|
rndval = sctp_select_initial_TSN(&stcb->sctp_ep->sctp_ep);
|
|
|
|
memcpy(stcb->asoc.hb_random_values, &rndval, sizeof(stcb->asoc.hb_random_values));
|
|
|
|
this_random = stcb->asoc.hb_random_values[0];
|
|
|
|
stcb->asoc.hb_random_idx++;
|
|
|
|
stcb->asoc.hb_ect_randombit = 0;
|
|
|
|
} else {
|
|
|
|
this_random = stcb->asoc.hb_random_values[stcb->asoc.hb_random_idx];
|
|
|
|
stcb->asoc.hb_random_idx++;
|
|
|
|
stcb->asoc.hb_ect_randombit = 0;
|
|
|
|
}
|
|
|
|
if (this_random % 2 == 1) {
|
|
|
|
max_cwnd_net = mnet;
|
2008-07-09 16:45:30 +00:00
|
|
|
max_cwnd = mnet->cwnd; /* Useless? */
|
2007-07-14 09:36:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (max_cwnd_net == NULL) {
|
|
|
|
if (min_errors_net == NULL) {
|
|
|
|
return (net);
|
|
|
|
}
|
|
|
|
return (min_errors_net);
|
|
|
|
} else {
|
|
|
|
return (max_cwnd_net);
|
|
|
|
}
|
2016-12-06 10:21:25 +00:00
|
|
|
} /* JRS 5/14/07 - If mode is set to 1, use the
|
2016-12-26 11:06:41 +00:00
|
|
|
* CMT policy for choosing an alternate net. */
|
2007-07-14 09:36:28 +00:00
|
|
|
else if (mode == 1) {
|
2006-11-03 15:23:16 +00:00
|
|
|
TAILQ_FOREACH(mnet, &stcb->asoc.nets, sctp_next) {
|
|
|
|
if (((mnet->dest_state & SCTP_ADDR_REACHABLE) != SCTP_ADDR_REACHABLE) ||
|
2010-11-07 17:44:04 +00:00
|
|
|
(mnet->dest_state & SCTP_ADDR_UNCONFIRMED)) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/*
|
|
|
|
* will skip ones that are not-reachable or
|
|
|
|
* unconfirmed
|
|
|
|
*/
|
|
|
|
continue;
|
|
|
|
}
|
2007-07-14 09:36:28 +00:00
|
|
|
if (max_cwnd < mnet->cwnd) {
|
|
|
|
max_cwnd_net = mnet;
|
|
|
|
max_cwnd = mnet->cwnd;
|
|
|
|
} else if (max_cwnd == mnet->cwnd) {
|
2006-11-03 15:23:16 +00:00
|
|
|
uint32_t rndval;
|
|
|
|
uint8_t this_random;
|
|
|
|
|
|
|
|
if (stcb->asoc.hb_random_idx > 3) {
|
|
|
|
rndval = sctp_select_initial_TSN(&stcb->sctp_ep->sctp_ep);
|
|
|
|
memcpy(stcb->asoc.hb_random_values, &rndval,
|
|
|
|
sizeof(stcb->asoc.hb_random_values));
|
|
|
|
this_random = stcb->asoc.hb_random_values[0];
|
|
|
|
stcb->asoc.hb_random_idx = 0;
|
|
|
|
stcb->asoc.hb_ect_randombit = 0;
|
|
|
|
} else {
|
|
|
|
this_random = stcb->asoc.hb_random_values[stcb->asoc.hb_random_idx];
|
|
|
|
stcb->asoc.hb_random_idx++;
|
|
|
|
stcb->asoc.hb_ect_randombit = 0;
|
|
|
|
}
|
|
|
|
if (this_random % 2) {
|
2007-07-14 09:36:28 +00:00
|
|
|
max_cwnd_net = mnet;
|
|
|
|
max_cwnd = mnet->cwnd;
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-07-14 09:36:28 +00:00
|
|
|
if (max_cwnd_net) {
|
|
|
|
return (max_cwnd_net);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
mnet = net;
|
|
|
|
once = 0;
|
|
|
|
|
|
|
|
if (mnet == NULL) {
|
|
|
|
mnet = TAILQ_FIRST(&stcb->asoc.nets);
|
2010-09-05 13:41:45 +00:00
|
|
|
if (mnet == NULL) {
|
|
|
|
return (NULL);
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
2015-01-19 11:52:08 +00:00
|
|
|
for (;;) {
|
2006-11-03 15:23:16 +00:00
|
|
|
alt = TAILQ_NEXT(mnet, sctp_next);
|
|
|
|
if (alt == NULL) {
|
|
|
|
once++;
|
|
|
|
if (once > 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
alt = TAILQ_FIRST(&stcb->asoc.nets);
|
2010-09-05 13:41:45 +00:00
|
|
|
if (alt == NULL) {
|
|
|
|
return (NULL);
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
if (alt->ro.ro_rt == NULL) {
|
2007-03-15 11:27:14 +00:00
|
|
|
if (alt->ro._s_addr) {
|
|
|
|
sctp_free_ifa(alt->ro._s_addr);
|
|
|
|
alt->ro._s_addr = NULL;
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
alt->src_addr_selected = 0;
|
|
|
|
}
|
2010-11-07 17:44:04 +00:00
|
|
|
if (((alt->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE) &&
|
|
|
|
(alt->ro.ro_rt != NULL) &&
|
|
|
|
(!(alt->dest_state & SCTP_ADDR_UNCONFIRMED))) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/* Found a reachable address */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mnet = alt;
|
2015-01-19 11:52:08 +00:00
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
|
|
|
|
if (alt == NULL) {
|
|
|
|
/* Case where NO insv network exists (dormant state) */
|
|
|
|
/* we rotate destinations */
|
|
|
|
once = 0;
|
|
|
|
mnet = net;
|
2015-01-19 11:52:08 +00:00
|
|
|
for (;;) {
|
2010-09-05 13:41:45 +00:00
|
|
|
if (mnet == NULL) {
|
|
|
|
return (TAILQ_FIRST(&stcb->asoc.nets));
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
alt = TAILQ_NEXT(mnet, sctp_next);
|
|
|
|
if (alt == NULL) {
|
|
|
|
once++;
|
|
|
|
if (once > 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
alt = TAILQ_FIRST(&stcb->asoc.nets);
|
2015-01-19 11:52:08 +00:00
|
|
|
if (alt == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
if ((!(alt->dest_state & SCTP_ADDR_UNCONFIRMED)) &&
|
|
|
|
(alt != net)) {
|
|
|
|
/* Found an alternate address */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mnet = alt;
|
2015-01-19 11:52:08 +00:00
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
if (alt == NULL) {
|
|
|
|
return (net);
|
|
|
|
}
|
|
|
|
return (alt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sctp_backoff_on_timeout(struct sctp_tcb *stcb,
|
|
|
|
struct sctp_nets *net,
|
|
|
|
int win_probe,
|
2010-07-29 11:37:04 +00:00
|
|
|
int num_marked, int num_abandoned)
|
2006-11-03 15:23:16 +00:00
|
|
|
{
|
2007-06-13 01:31:53 +00:00
|
|
|
if (net->RTO == 0) {
|
2015-10-13 18:27:55 +00:00
|
|
|
if (net->RTO_measured) {
|
|
|
|
net->RTO = stcb->asoc.minrto;
|
|
|
|
} else {
|
|
|
|
net->RTO = stcb->asoc.initial_rto;
|
|
|
|
}
|
2007-06-13 01:31:53 +00:00
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
net->RTO <<= 1;
|
|
|
|
if (net->RTO > stcb->asoc.maxrto) {
|
|
|
|
net->RTO = stcb->asoc.maxrto;
|
|
|
|
}
|
2010-07-29 11:37:04 +00:00
|
|
|
if ((win_probe == 0) && (num_marked || num_abandoned)) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/* We don't apply penalty to window probe scenarios */
|
2007-07-14 09:36:28 +00:00
|
|
|
/* JRS - Use the congestion control given in the CC module */
|
|
|
|
stcb->asoc.cc_functions.sctp_cwnd_update_after_timeout(stcb, net);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-27 13:53:31 +00:00
|
|
|
#ifndef INVARIANTS
|
|
|
|
static void
|
2008-08-28 09:44:07 +00:00
|
|
|
sctp_recover_sent_list(struct sctp_tcb *stcb)
|
|
|
|
{
|
2010-12-30 16:56:20 +00:00
|
|
|
struct sctp_tmit_chunk *chk, *nchk;
|
2008-08-28 09:44:07 +00:00
|
|
|
struct sctp_association *asoc;
|
|
|
|
|
|
|
|
asoc = &stcb->asoc;
|
2010-12-30 16:56:20 +00:00
|
|
|
TAILQ_FOREACH_SAFE(chk, &asoc->sent_queue, sctp_next, nchk) {
|
2016-12-07 19:30:59 +00:00
|
|
|
if (SCTP_TSN_GE(asoc->last_acked_seq, chk->rec.data.tsn)) {
|
2008-08-28 09:44:07 +00:00
|
|
|
SCTP_PRINTF("Found chk:%p tsn:%x <= last_acked_seq:%x\n",
|
2016-12-07 19:30:59 +00:00
|
|
|
(void *)chk, chk->rec.data.tsn, asoc->last_acked_seq);
|
2012-11-16 19:39:10 +00:00
|
|
|
if (chk->sent != SCTP_DATAGRAM_NR_ACKED) {
|
2016-12-07 19:30:59 +00:00
|
|
|
if (asoc->strmout[chk->rec.data.sid].chunks_on_queues > 0) {
|
|
|
|
asoc->strmout[chk->rec.data.sid].chunks_on_queues--;
|
2012-11-07 22:11:38 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-07 19:30:59 +00:00
|
|
|
if ((asoc->strmout[chk->rec.data.sid].chunks_on_queues == 0) &&
|
|
|
|
(asoc->strmout[chk->rec.data.sid].state == SCTP_STREAM_RESET_PENDING) &&
|
|
|
|
TAILQ_EMPTY(&asoc->strmout[chk->rec.data.sid].outqueue)) {
|
2015-12-03 15:19:29 +00:00
|
|
|
asoc->trigger_reset = 1;
|
|
|
|
}
|
2008-08-28 09:44:07 +00:00
|
|
|
TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next);
|
2013-09-03 19:31:59 +00:00
|
|
|
if (PR_SCTP_ENABLED(chk->flags)) {
|
2008-08-28 09:44:07 +00:00
|
|
|
if (asoc->pr_sctp_cnt != 0)
|
|
|
|
asoc->pr_sctp_cnt--;
|
|
|
|
}
|
|
|
|
if (chk->data) {
|
|
|
|
/* sa_ignore NO_NULL_CHK */
|
|
|
|
sctp_free_bufspace(stcb, asoc, chk, 1);
|
|
|
|
sctp_m_freem(chk->data);
|
2010-12-30 16:56:20 +00:00
|
|
|
chk->data = NULL;
|
2014-08-02 21:36:40 +00:00
|
|
|
if (asoc->prsctp_supported && PR_SCTP_BUF_ENABLED(chk->flags)) {
|
2008-08-28 09:44:07 +00:00
|
|
|
asoc->sent_queue_cnt_removeable--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
asoc->sent_queue_cnt--;
|
2011-05-08 09:11:59 +00:00
|
|
|
sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
|
2008-08-28 09:44:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SCTP_PRINTF("after recover order is as follows\n");
|
2010-12-30 16:56:20 +00:00
|
|
|
TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) {
|
2016-12-07 19:30:59 +00:00
|
|
|
SCTP_PRINTF("chk:%p TSN:%x\n", (void *)chk, chk->rec.data.tsn);
|
2008-08-28 09:44:07 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-27 13:53:31 +00:00
|
|
|
#endif
|
|
|
|
|
2006-11-03 15:23:16 +00:00
|
|
|
static int
|
|
|
|
sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|
|
|
struct sctp_nets *net,
|
|
|
|
struct sctp_nets *alt,
|
|
|
|
int window_probe,
|
2010-07-29 11:37:04 +00:00
|
|
|
int *num_marked,
|
|
|
|
int *num_abandoned)
|
2006-11-03 15:23:16 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mark all chunks (well not all) that were sent to *net for
|
|
|
|
* retransmission. Move them to alt for there destination as well...
|
|
|
|
* We only mark chunks that have been outstanding long enough to
|
|
|
|
* have received feed-back.
|
|
|
|
*/
|
2010-12-30 16:56:20 +00:00
|
|
|
struct sctp_tmit_chunk *chk, *nchk;
|
2006-11-03 15:23:16 +00:00
|
|
|
struct sctp_nets *lnets;
|
|
|
|
struct timeval now, min_wait, tv;
|
2011-02-24 22:58:15 +00:00
|
|
|
int cur_rto;
|
2010-07-29 11:37:04 +00:00
|
|
|
int cnt_abandoned;
|
2007-04-14 09:44:09 +00:00
|
|
|
int audit_tf, num_mk, fir;
|
2006-11-03 15:23:16 +00:00
|
|
|
unsigned int cnt_mk;
|
2007-04-14 09:44:09 +00:00
|
|
|
uint32_t orig_flight, orig_tf;
|
2006-11-03 15:23:16 +00:00
|
|
|
uint32_t tsnlast, tsnfirst;
|
2008-08-28 09:44:07 +00:00
|
|
|
int recovery_cnt = 0;
|
2006-11-03 15:23:16 +00:00
|
|
|
|
2007-07-14 09:36:28 +00:00
|
|
|
|
2006-11-03 15:23:16 +00:00
|
|
|
/* none in flight now */
|
|
|
|
audit_tf = 0;
|
|
|
|
fir = 0;
|
|
|
|
/*
|
|
|
|
* figure out how long a data chunk must be pending before we can
|
|
|
|
* mark it ..
|
|
|
|
*/
|
2007-05-08 14:32:53 +00:00
|
|
|
(void)SCTP_GETTIME_TIMEVAL(&now);
|
2006-11-03 15:23:16 +00:00
|
|
|
/* get cur rto in micro-seconds */
|
2011-02-24 22:58:15 +00:00
|
|
|
cur_rto = (net->lastsa >> SCTP_RTT_SHIFT) + net->lastsv;
|
|
|
|
cur_rto *= 1000;
|
2011-08-03 20:21:00 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
|
2011-02-24 22:58:15 +00:00
|
|
|
sctp_log_fr(cur_rto,
|
2007-06-14 22:59:04 +00:00
|
|
|
stcb->asoc.peers_rwnd,
|
|
|
|
window_probe,
|
|
|
|
SCTP_FR_T3_MARK_TIME);
|
2011-08-03 20:21:00 +00:00
|
|
|
sctp_log_fr(net->flight_size, 0, 0, SCTP_FR_CWND_REPORT);
|
2007-06-14 22:59:04 +00:00
|
|
|
sctp_log_fr(net->flight_size, net->cwnd, stcb->asoc.total_flight, SCTP_FR_CWND_REPORT);
|
|
|
|
}
|
2011-02-24 22:58:15 +00:00
|
|
|
tv.tv_sec = cur_rto / 1000000;
|
|
|
|
tv.tv_usec = cur_rto % 1000000;
|
2006-11-03 15:23:16 +00:00
|
|
|
min_wait = now;
|
|
|
|
timevalsub(&min_wait, &tv);
|
|
|
|
if (min_wait.tv_sec < 0 || min_wait.tv_usec < 0) {
|
|
|
|
/*
|
|
|
|
* if we hit here, we don't have enough seconds on the clock
|
|
|
|
* to account for the RTO. We just let the lower seconds be
|
|
|
|
* the bounds and don't worry about it. This may mean we
|
|
|
|
* will mark a lot more than we should.
|
|
|
|
*/
|
|
|
|
min_wait.tv_sec = min_wait.tv_usec = 0;
|
|
|
|
}
|
2011-08-03 20:21:00 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
|
2011-02-24 22:58:15 +00:00
|
|
|
sctp_log_fr(cur_rto, now.tv_sec, now.tv_usec, SCTP_FR_T3_MARK_TIME);
|
2007-06-14 22:59:04 +00:00
|
|
|
sctp_log_fr(0, min_wait.tv_sec, min_wait.tv_usec, SCTP_FR_T3_MARK_TIME);
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
/*
|
|
|
|
* Our rwnd will be incorrect here since we are not adding back the
|
|
|
|
* cnt * mbuf but we will fix that down below.
|
|
|
|
*/
|
|
|
|
orig_flight = net->flight_size;
|
2007-04-14 09:44:09 +00:00
|
|
|
orig_tf = stcb->asoc.total_flight;
|
|
|
|
|
2006-11-03 15:23:16 +00:00
|
|
|
net->fast_retran_ip = 0;
|
|
|
|
/* Now on to each chunk */
|
2010-07-29 11:37:04 +00:00
|
|
|
cnt_abandoned = 0;
|
2006-11-03 15:23:16 +00:00
|
|
|
num_mk = cnt_mk = 0;
|
|
|
|
tsnfirst = tsnlast = 0;
|
2008-10-27 13:53:31 +00:00
|
|
|
#ifndef INVARIANTS
|
2008-08-28 09:44:07 +00:00
|
|
|
start_again:
|
2008-10-27 13:53:31 +00:00
|
|
|
#endif
|
2010-12-30 16:56:20 +00:00
|
|
|
TAILQ_FOREACH_SAFE(chk, &stcb->asoc.sent_queue, sctp_next, nchk) {
|
2016-12-07 19:30:59 +00:00
|
|
|
if (SCTP_TSN_GE(stcb->asoc.last_acked_seq, chk->rec.data.tsn)) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/* Strange case our list got out of order? */
|
2013-10-29 20:04:50 +00:00
|
|
|
SCTP_PRINTF("Our list is out of order? last_acked:%x chk:%x\n",
|
2016-12-07 19:30:59 +00:00
|
|
|
(unsigned int)stcb->asoc.last_acked_seq, (unsigned int)chk->rec.data.tsn);
|
2008-08-28 09:44:07 +00:00
|
|
|
recovery_cnt++;
|
|
|
|
#ifdef INVARIANTS
|
|
|
|
panic("last acked >= chk on sent-Q");
|
|
|
|
#else
|
|
|
|
SCTP_PRINTF("Recover attempts a restart cnt:%d\n", recovery_cnt);
|
|
|
|
sctp_recover_sent_list(stcb);
|
|
|
|
if (recovery_cnt < 10) {
|
|
|
|
goto start_again;
|
|
|
|
} else {
|
|
|
|
SCTP_PRINTF("Recovery fails %d times??\n", recovery_cnt);
|
|
|
|
}
|
|
|
|
#endif
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
if ((chk->whoTo == net) && (chk->sent < SCTP_DATAGRAM_ACKED)) {
|
|
|
|
/*
|
|
|
|
* found one to mark: If it is less than
|
|
|
|
* DATAGRAM_ACKED it MUST not be a skipped or marked
|
|
|
|
* TSN but instead one that is either already set
|
|
|
|
* for retransmission OR one that needs
|
|
|
|
* retransmission.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* validate its been outstanding long enough */
|
2011-08-03 20:21:00 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
|
2016-12-07 19:30:59 +00:00
|
|
|
sctp_log_fr(chk->rec.data.tsn,
|
2007-06-14 22:59:04 +00:00
|
|
|
chk->sent_rcv_time.tv_sec,
|
|
|
|
chk->sent_rcv_time.tv_usec,
|
|
|
|
SCTP_FR_T3_MARK_TIME);
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
if ((chk->sent_rcv_time.tv_sec > min_wait.tv_sec) && (window_probe == 0)) {
|
|
|
|
/*
|
|
|
|
* we have reached a chunk that was sent
|
|
|
|
* some seconds past our min.. forget it we
|
|
|
|
* will find no more to send.
|
|
|
|
*/
|
2011-08-03 20:21:00 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
|
2007-06-14 22:59:04 +00:00
|
|
|
sctp_log_fr(0,
|
|
|
|
chk->sent_rcv_time.tv_sec,
|
|
|
|
chk->sent_rcv_time.tv_usec,
|
|
|
|
SCTP_FR_T3_STOPPED);
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
continue;
|
|
|
|
} else if ((chk->sent_rcv_time.tv_sec == min_wait.tv_sec) &&
|
|
|
|
(window_probe == 0)) {
|
|
|
|
/*
|
|
|
|
* we must look at the micro seconds to
|
|
|
|
* know.
|
|
|
|
*/
|
|
|
|
if (chk->sent_rcv_time.tv_usec >= min_wait.tv_usec) {
|
|
|
|
/*
|
|
|
|
* ok it was sent after our boundary
|
|
|
|
* time.
|
|
|
|
*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2014-08-02 21:36:40 +00:00
|
|
|
if (stcb->asoc.prsctp_supported && PR_SCTP_TTL_ENABLED(chk->flags)) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/* Is it expired? */
|
2010-09-17 19:20:39 +00:00
|
|
|
if (timevalcmp(&now, &chk->rec.data.timetodrop, >)) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/* Yes so drop it */
|
|
|
|
if (chk->data) {
|
2007-05-09 13:30:06 +00:00
|
|
|
(void)sctp_release_pr_sctp_chunk(stcb,
|
2006-11-03 15:23:16 +00:00
|
|
|
chk,
|
2012-05-13 19:32:49 +00:00
|
|
|
1,
|
2009-03-14 13:42:13 +00:00
|
|
|
SCTP_SO_NOT_LOCKED);
|
2010-07-29 11:37:04 +00:00
|
|
|
cnt_abandoned++;
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
2008-12-06 13:19:54 +00:00
|
|
|
continue;
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-02 21:36:40 +00:00
|
|
|
if (stcb->asoc.prsctp_supported && PR_SCTP_RTX_ENABLED(chk->flags)) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/* Has it been retransmitted tv_sec times? */
|
|
|
|
if (chk->snd_count > chk->rec.data.timetodrop.tv_sec) {
|
|
|
|
if (chk->data) {
|
2007-05-09 13:30:06 +00:00
|
|
|
(void)sctp_release_pr_sctp_chunk(stcb,
|
2006-11-03 15:23:16 +00:00
|
|
|
chk,
|
2012-05-13 19:32:49 +00:00
|
|
|
1,
|
2009-03-14 13:42:13 +00:00
|
|
|
SCTP_SO_NOT_LOCKED);
|
2010-07-29 11:37:04 +00:00
|
|
|
cnt_abandoned++;
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
2008-12-06 13:19:54 +00:00
|
|
|
continue;
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
2007-04-14 09:44:09 +00:00
|
|
|
if (chk->sent < SCTP_DATAGRAM_RESEND) {
|
2006-11-03 15:23:16 +00:00
|
|
|
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
|
|
|
num_mk++;
|
|
|
|
if (fir == 0) {
|
|
|
|
fir = 1;
|
2016-12-07 19:30:59 +00:00
|
|
|
tsnfirst = chk->rec.data.tsn;
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
2016-12-07 19:30:59 +00:00
|
|
|
tsnlast = chk->rec.data.tsn;
|
2011-08-03 20:21:00 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
|
2016-12-07 19:30:59 +00:00
|
|
|
sctp_log_fr(chk->rec.data.tsn, chk->snd_count,
|
2007-06-14 22:59:04 +00:00
|
|
|
0, SCTP_FR_T3_MARKED);
|
|
|
|
}
|
2007-04-14 09:44:09 +00:00
|
|
|
if (chk->rec.data.chunk_was_revoked) {
|
|
|
|
/* deflate the cwnd */
|
|
|
|
chk->whoTo->cwnd -= chk->book_size;
|
|
|
|
chk->rec.data.chunk_was_revoked = 0;
|
|
|
|
}
|
|
|
|
net->marked_retrans++;
|
|
|
|
stcb->asoc.marked_retrans++;
|
2008-06-14 07:58:05 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FLIGHT_LOGGING_ENABLE) {
|
2007-06-14 22:59:04 +00:00
|
|
|
sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_RSND_TO,
|
|
|
|
chk->whoTo->flight_size,
|
|
|
|
chk->book_size,
|
2016-12-26 11:06:41 +00:00
|
|
|
(uint32_t)(uintptr_t)chk->whoTo,
|
2016-12-07 19:30:59 +00:00
|
|
|
chk->rec.data.tsn);
|
2007-06-14 22:59:04 +00:00
|
|
|
}
|
2007-04-14 09:44:09 +00:00
|
|
|
sctp_flight_size_decrease(chk);
|
|
|
|
sctp_total_flight_decrease(stcb, chk);
|
|
|
|
stcb->asoc.peers_rwnd += chk->send_size;
|
2008-06-14 07:58:05 +00:00
|
|
|
stcb->asoc.peers_rwnd += SCTP_BASE_SYSCTL(sctp_peer_chunk_oh);
|
2007-03-15 11:27:14 +00:00
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
chk->sent = SCTP_DATAGRAM_RESEND;
|
|
|
|
SCTP_STAT_INCR(sctps_markedretrans);
|
|
|
|
|
|
|
|
/* 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 */
|
2011-03-08 11:58:25 +00:00
|
|
|
|
|
|
|
if (chk->do_rtt) {
|
|
|
|
if (chk->whoTo->rto_needed == 0) {
|
|
|
|
chk->whoTo->rto_needed = 1;
|
|
|
|
}
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
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 {
|
2016-12-07 19:30:59 +00:00
|
|
|
chk->rec.data.fast_retran_tsn = (TAILQ_FIRST(&stcb->asoc.send_queue))->rec.data.tsn;
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-01 11:19:54 +00:00
|
|
|
/*
|
|
|
|
* CMT: Do not allow FRs on retransmitted TSNs.
|
|
|
|
*/
|
2010-12-22 17:59:38 +00:00
|
|
|
if (stcb->asoc.sctp_cmt_on_off > 0) {
|
2006-11-03 15:23:16 +00:00
|
|
|
chk->no_fr_allowed = 1;
|
|
|
|
}
|
2010-07-29 11:37:04 +00:00
|
|
|
#ifdef THIS_SHOULD_NOT_BE_DONE
|
2006-11-03 15:23:16 +00:00
|
|
|
} else if (chk->sent == SCTP_DATAGRAM_ACKED) {
|
|
|
|
/* remember highest acked one */
|
|
|
|
could_be_sent = chk;
|
2010-07-29 11:37:04 +00:00
|
|
|
#endif
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
if (chk->sent == SCTP_DATAGRAM_RESEND) {
|
|
|
|
cnt_mk++;
|
|
|
|
}
|
|
|
|
}
|
2007-04-14 09:44:09 +00:00
|
|
|
if ((orig_flight - net->flight_size) != (orig_tf - stcb->asoc.total_flight)) {
|
|
|
|
/* we did not subtract the same things? */
|
|
|
|
audit_tf = 1;
|
|
|
|
}
|
2011-08-03 20:21:00 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
|
2007-06-14 22:59:04 +00:00
|
|
|
sctp_log_fr(tsnfirst, tsnlast, num_mk, SCTP_FR_T3_TIMEOUT);
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
#ifdef SCTP_DEBUG
|
2007-05-09 13:30:06 +00:00
|
|
|
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:%ld\n",
|
|
|
|
num_mk, (u_long)stcb->asoc.peers_rwnd);
|
|
|
|
SCTPDBG(SCTP_DEBUG_TIMER1, "LAST TSN marked was %x\n",
|
|
|
|
tsnlast);
|
|
|
|
SCTPDBG(SCTP_DEBUG_TIMER1, "Num marked for retransmission was %d peer-rwd:%d\n",
|
|
|
|
num_mk,
|
|
|
|
(int)stcb->asoc.peers_rwnd);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
*num_marked = num_mk;
|
2010-07-29 11:37:04 +00:00
|
|
|
*num_abandoned = cnt_abandoned;
|
2010-07-26 09:20:55 +00:00
|
|
|
/*
|
|
|
|
* Now check for a ECN Echo that may be stranded And include the
|
|
|
|
* cnt_mk'd to have all resends in the control queue.
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
|
|
|
cnt_mk++;
|
|
|
|
}
|
|
|
|
atomic_add_int(&alt->ref_count, 1);
|
|
|
|
}
|
|
|
|
}
|
2010-07-29 11:37:04 +00:00
|
|
|
#ifdef THIS_SHOULD_NOT_BE_DONE
|
2006-11-03 15:23:16 +00:00
|
|
|
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;
|
|
|
|
}
|
2010-07-29 11:37:04 +00:00
|
|
|
#endif
|
2006-11-03 15:23:16 +00:00
|
|
|
if (stcb->asoc.sent_queue_retran_cnt != cnt_mk) {
|
2006-12-14 17:02:55 +00:00
|
|
|
#ifdef INVARIANTS
|
2007-07-17 20:58:26 +00:00
|
|
|
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);
|
2006-11-03 15:23:16 +00:00
|
|
|
#endif
|
|
|
|
#ifndef SCTP_AUDITING_ENABLED
|
|
|
|
stcb->asoc.sent_queue_retran_cnt = cnt_mk;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
if (audit_tf) {
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTPDBG(SCTP_DEBUG_TIMER4,
|
|
|
|
"Audit total flight due to negative value net:%p\n",
|
2012-09-05 18:52:01 +00:00
|
|
|
(void *)net);
|
2006-11-03 15:23:16 +00:00
|
|
|
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;
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTPDBG(SCTP_DEBUG_TIMER4,
|
|
|
|
"Net:%p c-f cwnd:%d ssthresh:%d\n",
|
2012-09-05 18:52:01 +00:00
|
|
|
(void *)lnets, lnets->cwnd, lnets->ssthresh);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) {
|
|
|
|
if (chk->sent < SCTP_DATAGRAM_RESEND) {
|
2008-06-14 07:58:05 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FLIGHT_LOGGING_ENABLE) {
|
2007-06-14 22:59:04 +00:00
|
|
|
sctp_misc_ints(SCTP_FLIGHT_LOG_UP,
|
|
|
|
chk->whoTo->flight_size,
|
|
|
|
chk->book_size,
|
2016-12-26 11:06:41 +00:00
|
|
|
(uint32_t)(uintptr_t)chk->whoTo,
|
2016-12-07 19:30:59 +00:00
|
|
|
chk->rec.data.tsn);
|
2007-06-14 22:59:04 +00:00
|
|
|
}
|
2007-04-14 09:44:09 +00:00
|
|
|
sctp_flight_size_increase(chk);
|
|
|
|
sctp_total_flight_increase(stcb, chk);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* 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;
|
2010-07-29 11:37:04 +00:00
|
|
|
int win_probe, num_mk, num_abandoned;
|
2006-11-03 15:23:16 +00:00
|
|
|
|
2008-06-14 07:58:05 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
|
2007-06-14 22:59:04 +00:00
|
|
|
sctp_log_fr(0, 0, 0, SCTP_FR_T3_TIMEOUT);
|
|
|
|
}
|
2008-06-14 07:58:05 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_LOGGING_ENABLE) {
|
2006-11-03 15:23:16 +00:00
|
|
|
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;
|
|
|
|
}
|
2007-04-14 09:44:09 +00:00
|
|
|
|
2006-11-03 15:23:16 +00:00
|
|
|
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;
|
|
|
|
unsigned int ms_goneby;
|
|
|
|
|
2007-05-08 14:32:53 +00:00
|
|
|
(void)SCTP_GETTIME_TIMEVAL(&now);
|
2006-11-03 15:23:16 +00:00
|
|
|
if (net->last_sent_time.tv_sec) {
|
|
|
|
ms_goneby = (now.tv_sec - net->last_sent_time.tv_sec) * 1000;
|
|
|
|
} else {
|
|
|
|
ms_goneby = 0;
|
|
|
|
}
|
2011-08-03 20:21:00 +00:00
|
|
|
if ((net->dest_state & SCTP_ADDR_PF) == 0) {
|
|
|
|
if ((ms_goneby > net->RTO) || (net->RTO == 0)) {
|
2008-12-06 13:19:54 +00:00
|
|
|
/*
|
2011-08-03 20:21:00 +00:00
|
|
|
* no recent feed back in an
|
|
|
|
* RTO or more, request a
|
|
|
|
* RTT update
|
2008-12-06 13:19:54 +00:00
|
|
|
*/
|
2011-08-03 20:21:00 +00:00
|
|
|
sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED);
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* For a window probe we don't penalize the net's but only
|
|
|
|
* the association. This may fail it if SACKs are not coming
|
|
|
|
* back. If sack's are coming with rwnd locked at 0, we will
|
|
|
|
* continue to hold things waiting for rwnd to raise
|
|
|
|
*/
|
|
|
|
if (sctp_threshold_management(inp, stcb, NULL,
|
|
|
|
stcb->asoc.max_send_times)) {
|
|
|
|
/* Association was destroyed */
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
}
|
2011-08-03 20:21:00 +00:00
|
|
|
if (stcb->asoc.sctp_cmt_on_off > 0) {
|
|
|
|
if (net->pf_threshold < net->failure_threshold) {
|
|
|
|
alt = sctp_find_alternate_net(stcb, net, 2);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* CMT: Using RTX_SSTHRESH policy for CMT. If CMT is
|
|
|
|
* being used, then pick dest with largest ssthresh
|
|
|
|
* for any retransmission.
|
|
|
|
*/
|
|
|
|
alt = sctp_find_alternate_net(stcb, net, 1);
|
|
|
|
/*
|
|
|
|
* CUCv2: If a different dest is picked for the
|
|
|
|
* retransmission, then new (rtx-)pseudo_cumack
|
|
|
|
* needs to be tracked for orig dest. Let CUCv2
|
|
|
|
* track new (rtx-) pseudo-cumack always.
|
|
|
|
*/
|
|
|
|
net->find_pseudo_cumack = 1;
|
|
|
|
net->find_rtx_pseudo_cumack = 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
alt = sctp_find_alternate_net(stcb, net, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* setup the sat loss recovery that prevents satellite cwnd advance.
|
|
|
|
*/
|
|
|
|
stcb->asoc.sat_t3_loss_recovery = 1;
|
|
|
|
stcb->asoc.sat_t3_recovery_tsn = stcb->asoc.sending_seq;
|
|
|
|
|
|
|
|
/* Backoff the timer and cwnd */
|
|
|
|
sctp_backoff_on_timeout(stcb, net, win_probe, num_mk, num_abandoned);
|
|
|
|
if ((!(net->dest_state & SCTP_ADDR_REACHABLE)) ||
|
|
|
|
(net->dest_state & SCTP_ADDR_PF)) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/* Move all pending over too */
|
2010-09-15 23:10:45 +00:00
|
|
|
sctp_move_chunks_from_net(stcb, net);
|
2007-05-08 00:21:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the address that failed, to force a new src address
|
|
|
|
* selecton and a route allocation.
|
|
|
|
*/
|
|
|
|
if (net->ro._s_addr) {
|
|
|
|
sctp_free_ifa(net->ro._s_addr);
|
|
|
|
net->ro._s_addr = NULL;
|
|
|
|
}
|
|
|
|
net->src_addr_selected = 0;
|
|
|
|
|
|
|
|
/* Force a route allocation too */
|
|
|
|
if (net->ro.ro_rt) {
|
|
|
|
RTFREE(net->ro.ro_rt);
|
|
|
|
net->ro.ro_rt = NULL;
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
/* Was it our primary? */
|
|
|
|
if ((stcb->asoc.primary_destination == net) && (alt != net)) {
|
|
|
|
/*
|
|
|
|
* Yes, note it as such and find an alternate note:
|
|
|
|
* this means HB code must use this to resent the
|
|
|
|
* primary if it goes active AND if someone does a
|
|
|
|
* change-primary then this flag must be cleared
|
|
|
|
* from any net structures.
|
|
|
|
*/
|
2011-08-03 20:21:00 +00:00
|
|
|
if (stcb->asoc.alternate) {
|
|
|
|
sctp_free_remote_addr(stcb->asoc.alternate);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
2011-08-03 20:21:00 +00:00
|
|
|
stcb->asoc.alternate = alt;
|
|
|
|
atomic_add_int(&stcb->asoc.alternate->ref_count, 1);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Special case for cookie-echo'ed case, we don't do output but must
|
|
|
|
* await the COOKIE-ACK before retransmission
|
|
|
|
*/
|
|
|
|
if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED) {
|
|
|
|
/*
|
|
|
|
* Here we just reset the timer and start again since we
|
|
|
|
* have not established the asoc
|
|
|
|
*/
|
|
|
|
sctp_timer_start(SCTP_TIMER_TYPE_SEND, inp, stcb, net);
|
|
|
|
return (0);
|
|
|
|
}
|
2014-08-02 21:36:40 +00:00
|
|
|
if (stcb->asoc.prsctp_supported) {
|
2006-11-03 15:23:16 +00:00
|
|
|
struct sctp_tmit_chunk *lchk;
|
|
|
|
|
|
|
|
lchk = sctp_try_advance_peer_ack_point(stcb, &stcb->asoc);
|
|
|
|
/* C3. See if we need to send a Fwd-TSN */
|
2010-12-30 21:32:35 +00:00
|
|
|
if (SCTP_TSN_GT(stcb->asoc.advanced_peer_ack_point, stcb->asoc.last_acked_seq)) {
|
2006-11-03 15:23:16 +00:00
|
|
|
send_forward_tsn(stcb, &stcb->asoc);
|
|
|
|
if (lchk) {
|
|
|
|
/* Assure a timer is up */
|
|
|
|
sctp_timer_start(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, lchk->whoTo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-06-14 07:58:05 +00:00
|
|
|
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_CWND_MONITOR_ENABLE) {
|
2007-06-14 22:59:04 +00:00
|
|
|
sctp_log_cwnd(stcb, net, net->cwnd, SCTP_CWND_LOG_FROM_RTX);
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sctp_t1init_timer(struct sctp_inpcb *inp,
|
|
|
|
struct sctp_tcb *stcb,
|
|
|
|
struct sctp_nets *net)
|
|
|
|
{
|
|
|
|
/* bump the thresholds */
|
|
|
|
if (stcb->asoc.delayed_connection) {
|
|
|
|
/*
|
|
|
|
* special hook for delayed connection. The library did NOT
|
|
|
|
* complete the rest of its sends.
|
|
|
|
*/
|
|
|
|
stcb->asoc.delayed_connection = 0;
|
2007-09-08 11:35:11 +00:00
|
|
|
sctp_send_initiate(inp, stcb, SCTP_SO_NOT_LOCKED);
|
2006-11-03 15:23:16 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (SCTP_GET_STATE((&stcb->asoc)) != SCTP_STATE_COOKIE_WAIT) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (sctp_threshold_management(inp, stcb, net,
|
|
|
|
stcb->asoc.max_init_times)) {
|
|
|
|
/* Association was destroyed */
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
stcb->asoc.dropped_special_cnt = 0;
|
2010-07-29 11:37:04 +00:00
|
|
|
sctp_backoff_on_timeout(stcb, stcb->asoc.primary_destination, 1, 0, 0);
|
2006-11-03 15:23:16 +00:00
|
|
|
if (stcb->asoc.initial_init_rto_max < net->RTO) {
|
|
|
|
net->RTO = stcb->asoc.initial_init_rto_max;
|
|
|
|
}
|
|
|
|
if (stcb->asoc.numnets > 1) {
|
|
|
|
/* If we have more than one addr use it */
|
|
|
|
struct sctp_nets *alt;
|
|
|
|
|
|
|
|
alt = sctp_find_alternate_net(stcb, stcb->asoc.primary_destination, 0);
|
2010-11-07 17:44:04 +00:00
|
|
|
if (alt != stcb->asoc.primary_destination) {
|
2010-09-15 23:10:45 +00:00
|
|
|
sctp_move_chunks_from_net(stcb, stcb->asoc.primary_destination);
|
2006-11-03 15:23:16 +00:00
|
|
|
stcb->asoc.primary_destination = alt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Send out a new init */
|
2007-09-08 11:35:11 +00:00
|
|
|
sctp_send_initiate(inp, stcb, SCTP_SO_NOT_LOCKED);
|
2006-11-03 15:23:16 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For cookie and asconf we actually need to find and mark for resend, then
|
|
|
|
* increment the resend counter (after all the threshold management stuff of
|
|
|
|
* course).
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
sctp_cookie_timer(struct sctp_inpcb *inp,
|
|
|
|
struct sctp_tcb *stcb,
|
2011-12-17 19:21:40 +00:00
|
|
|
struct sctp_nets *net SCTP_UNUSED)
|
2006-11-03 15:23:16 +00:00
|
|
|
{
|
|
|
|
struct sctp_nets *alt;
|
|
|
|
struct sctp_tmit_chunk *cookie;
|
|
|
|
|
|
|
|
/* 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->asoc) == SCTP_STATE_COOKIE_ECHOED) {
|
|
|
|
/* FOOBAR! */
|
2014-03-16 12:32:16 +00:00
|
|
|
struct mbuf *op_err;
|
2006-11-03 15:23:16 +00:00
|
|
|
|
2015-07-27 22:35:54 +00:00
|
|
|
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
|
2014-03-16 12:32:16 +00:00
|
|
|
"Cookie timer expired, but no cookie");
|
2015-05-28 16:00:23 +00:00
|
|
|
inp->last_abort_code = SCTP_FROM_SCTP_TIMER + SCTP_LOC_3;
|
2014-03-16 12:32:16 +00:00
|
|
|
sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED);
|
2006-11-03 15:23:16 +00:00
|
|
|
} else {
|
2006-12-14 17:02:55 +00:00
|
|
|
#ifdef INVARIANTS
|
2006-11-03 15:23:16 +00:00
|
|
|
panic("Cookie timer expires in wrong state?");
|
|
|
|
#else
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTP_PRINTF("Strange in state %d not cookie-echoed yet c-e timer expires?\n", SCTP_GET_STATE(&stcb->asoc));
|
2006-11-03 15:23:16 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
/*
|
2016-05-09 16:35:05 +00:00
|
|
|
* Cleared threshold management, now lets backoff the address and
|
|
|
|
* select an alternate
|
2006-11-03 15:23:16 +00:00
|
|
|
*/
|
|
|
|
stcb->asoc.dropped_special_cnt = 0;
|
2010-07-29 11:37:04 +00:00
|
|
|
sctp_backoff_on_timeout(stcb, cookie->whoTo, 1, 0, 0);
|
2006-11-03 15:23:16 +00:00
|
|
|
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;
|
|
|
|
/*
|
|
|
|
* Now call the output routine to kick out the cookie again, Note we
|
|
|
|
* don't mark any chunks for retran so that FR will need to kick in
|
|
|
|
* to move these (or a send timer).
|
|
|
|
*/
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|
|
|
struct sctp_nets *net)
|
|
|
|
{
|
|
|
|
struct sctp_nets *alt;
|
|
|
|
struct sctp_tmit_chunk *strrst = NULL, *chk = NULL;
|
|
|
|
|
|
|
|
if (stcb->asoc.stream_reset_outstanding == 0) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
/* find the existing STRRESET, we use the seq number we sent out on */
|
2007-05-09 13:30:06 +00:00
|
|
|
(void)sctp_find_stream_reset(stcb, stcb->asoc.str_reset_seq_out, &strrst);
|
2006-11-03 15:23:16 +00:00
|
|
|
if (strrst == NULL) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
/* do threshold management */
|
|
|
|
if (sctp_threshold_management(inp, stcb, strrst->whoTo,
|
|
|
|
stcb->asoc.max_send_times)) {
|
|
|
|
/* Assoc is over */
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
/*
|
2016-05-09 16:35:05 +00:00
|
|
|
* Cleared threshold management, now lets backoff the address and
|
|
|
|
* select an alternate
|
2006-11-03 15:23:16 +00:00
|
|
|
*/
|
2010-07-29 11:37:04 +00:00
|
|
|
sctp_backoff_on_timeout(stcb, strrst->whoTo, 1, 0, 0);
|
2006-11-03 15:23:16 +00:00
|
|
|
alt = sctp_find_alternate_net(stcb, strrst->whoTo, 0);
|
|
|
|
sctp_free_remote_addr(strrst->whoTo);
|
|
|
|
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;
|
|
|
|
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
|
|
|
}
|
|
|
|
chk->whoTo = alt;
|
|
|
|
atomic_add_int(&alt->ref_count, 1);
|
|
|
|
}
|
|
|
|
}
|
2011-08-03 20:21:00 +00:00
|
|
|
if (!(net->dest_state & SCTP_ADDR_REACHABLE)) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/*
|
|
|
|
* If the address went un-reachable, we need to move to
|
|
|
|
* alternates for ALL chk's in queue
|
|
|
|
*/
|
2010-09-15 23:10:45 +00:00
|
|
|
sctp_move_chunks_from_net(stcb, net);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
/* mark the retran info */
|
|
|
|
if (strrst->sent != SCTP_DATAGRAM_RESEND)
|
|
|
|
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
|
|
|
strrst->sent = SCTP_DATAGRAM_RESEND;
|
|
|
|
|
|
|
|
/* restart the timer */
|
|
|
|
sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, inp, stcb, strrst->whoTo);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|
|
|
struct sctp_nets *net)
|
|
|
|
{
|
|
|
|
struct sctp_nets *alt;
|
2010-12-30 16:56:20 +00:00
|
|
|
struct sctp_tmit_chunk *asconf, *chk;
|
2006-11-03 15:23:16 +00:00
|
|
|
|
2007-07-24 20:06:02 +00:00
|
|
|
/* is this a first send, or a retransmission? */
|
2008-05-20 13:47:46 +00:00
|
|
|
if (TAILQ_EMPTY(&stcb->asoc.asconf_send_queue)) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/* compose a new ASCONF chunk and send it */
|
2007-09-15 19:07:42 +00:00
|
|
|
sctp_send_asconf(stcb, net, SCTP_ADDR_NOT_LOCKED);
|
2006-11-03 15:23:16 +00:00
|
|
|
} else {
|
2007-07-24 20:06:02 +00:00
|
|
|
/*
|
|
|
|
* Retransmission of the existing ASCONF is needed
|
|
|
|
*/
|
2006-11-03 15:23:16 +00:00
|
|
|
|
|
|
|
/* find the existing ASCONF */
|
2008-05-20 13:47:46 +00:00
|
|
|
asconf = TAILQ_FIRST(&stcb->asoc.asconf_send_queue);
|
2006-11-03 15:23:16 +00:00
|
|
|
if (asconf == NULL) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
/* do threshold management */
|
|
|
|
if (sctp_threshold_management(inp, stcb, asconf->whoTo,
|
|
|
|
stcb->asoc.max_send_times)) {
|
|
|
|
/* Assoc is over */
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
if (asconf->snd_count > stcb->asoc.max_send_times) {
|
|
|
|
/*
|
2007-07-24 20:06:02 +00:00
|
|
|
* Something is rotten: our peer is not responding
|
|
|
|
* to ASCONFs but apparently is to other chunks.
|
|
|
|
* i.e. it is not properly handling the chunk type
|
|
|
|
* upper bits. Mark this peer as ASCONF incapable
|
|
|
|
* and cleanup.
|
2006-11-03 15:23:16 +00:00
|
|
|
*/
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTPDBG(SCTP_DEBUG_TIMER1, "asconf_timer: Peer has not responded to our repeated ASCONFs\n");
|
2006-11-03 15:23:16 +00:00
|
|
|
sctp_asconf_cleanup(stcb, net);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
/*
|
2007-07-24 20:06:02 +00:00
|
|
|
* cleared threshold management, so now backoff the net and
|
|
|
|
* select an alternate
|
2006-11-03 15:23:16 +00:00
|
|
|
*/
|
2010-07-29 11:37:04 +00:00
|
|
|
sctp_backoff_on_timeout(stcb, asconf->whoTo, 1, 0, 0);
|
2006-11-03 15:23:16 +00:00
|
|
|
alt = sctp_find_alternate_net(stcb, asconf->whoTo, 0);
|
2008-05-20 13:47:46 +00:00
|
|
|
if (asconf->whoTo != alt) {
|
|
|
|
sctp_free_remote_addr(asconf->whoTo);
|
|
|
|
asconf->whoTo = alt;
|
|
|
|
atomic_add_int(&alt->ref_count, 1);
|
|
|
|
}
|
2007-07-24 20:06:02 +00:00
|
|
|
/* See if an ECN Echo is also stranded */
|
2006-11-03 15:23:16 +00:00
|
|
|
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;
|
|
|
|
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
|
|
|
}
|
|
|
|
atomic_add_int(&alt->ref_count, 1);
|
|
|
|
}
|
|
|
|
}
|
2010-12-30 16:56:20 +00:00
|
|
|
TAILQ_FOREACH(chk, &stcb->asoc.asconf_send_queue, sctp_next) {
|
2008-05-20 13:47:46 +00:00
|
|
|
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;
|
|
|
|
}
|
2011-08-03 20:21:00 +00:00
|
|
|
if (!(net->dest_state & SCTP_ADDR_REACHABLE)) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/*
|
|
|
|
* If the address went un-reachable, we need to move
|
2007-07-24 20:06:02 +00:00
|
|
|
* to the alternate for ALL chunks in queue
|
2006-11-03 15:23:16 +00:00
|
|
|
*/
|
2010-09-15 23:10:45 +00:00
|
|
|
sctp_move_chunks_from_net(stcb, net);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
/* mark the retran info */
|
|
|
|
if (asconf->sent != SCTP_DATAGRAM_RESEND)
|
|
|
|
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
|
|
|
asconf->sent = SCTP_DATAGRAM_RESEND;
|
2008-05-20 13:47:46 +00:00
|
|
|
|
|
|
|
/* send another ASCONF if any and we can do */
|
|
|
|
sctp_send_asconf(stcb, alt, SCTP_ADDR_NOT_LOCKED);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2007-09-08 17:48:46 +00:00
|
|
|
/* Mobility adaptation */
|
2007-09-13 10:36:43 +00:00
|
|
|
void
|
2007-09-08 17:48:46 +00:00
|
|
|
sctp_delete_prim_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
2011-12-17 19:21:40 +00:00
|
|
|
struct sctp_nets *net SCTP_UNUSED)
|
2007-09-08 17:48:46 +00:00
|
|
|
{
|
|
|
|
if (stcb->asoc.deleted_primary == NULL) {
|
|
|
|
SCTPDBG(SCTP_DEBUG_ASCONF1, "delete_prim_timer: deleted_primary is not stored...\n");
|
|
|
|
sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
|
2007-09-13 10:36:43 +00:00
|
|
|
return;
|
2007-09-08 17:48:46 +00:00
|
|
|
}
|
|
|
|
SCTPDBG(SCTP_DEBUG_ASCONF1, "delete_prim_timer: finished to keep deleted primary ");
|
|
|
|
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, &stcb->asoc.deleted_primary->ro._l_addr.sa);
|
|
|
|
sctp_free_remote_addr(stcb->asoc.deleted_primary);
|
|
|
|
stcb->asoc.deleted_primary = NULL;
|
|
|
|
sctp_mobility_feature_off(inp, SCTP_MOBILITY_PRIM_DELETED);
|
2007-09-13 10:36:43 +00:00
|
|
|
return;
|
2007-09-08 17:48:46 +00:00
|
|
|
}
|
|
|
|
|
2006-11-03 15:23:16 +00:00
|
|
|
/*
|
|
|
|
* For the shutdown and shutdown-ack, we do not keep one around on the
|
|
|
|
* control queue. This means we must generate a new one and call the general
|
|
|
|
* chunk output routine, AFTER having done threshold management.
|
2010-11-07 17:44:04 +00:00
|
|
|
* It is assumed that net is non-NULL.
|
2006-11-03 15:23:16 +00:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
sctp_shutdown_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|
|
|
struct sctp_nets *net)
|
|
|
|
{
|
|
|
|
struct sctp_nets *alt;
|
|
|
|
|
2016-05-02 20:56:11 +00:00
|
|
|
/* first threshold management */
|
2006-11-03 15:23:16 +00:00
|
|
|
if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) {
|
|
|
|
/* Assoc is over */
|
|
|
|
return (1);
|
|
|
|
}
|
2010-11-07 17:44:04 +00:00
|
|
|
sctp_backoff_on_timeout(stcb, net, 1, 0, 0);
|
2006-11-03 15:23:16 +00:00
|
|
|
/* second select an alternative */
|
|
|
|
alt = sctp_find_alternate_net(stcb, net, 0);
|
|
|
|
|
|
|
|
/* third generate a shutdown into the queue for out net */
|
2010-11-07 17:44:04 +00:00
|
|
|
sctp_send_shutdown(stcb, alt);
|
|
|
|
|
2006-11-03 15:23:16 +00:00
|
|
|
/* fourth restart timer */
|
|
|
|
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, inp, stcb, alt);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sctp_shutdownack_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|
|
|
struct sctp_nets *net)
|
|
|
|
{
|
|
|
|
struct sctp_nets *alt;
|
|
|
|
|
2016-05-02 20:56:11 +00:00
|
|
|
/* first threshold management */
|
2006-11-03 15:23:16 +00:00
|
|
|
if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) {
|
|
|
|
/* Assoc is over */
|
|
|
|
return (1);
|
|
|
|
}
|
2010-11-07 17:44:04 +00:00
|
|
|
sctp_backoff_on_timeout(stcb, net, 1, 0, 0);
|
2006-11-03 15:23:16 +00:00
|
|
|
/* 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);
|
|
|
|
|
|
|
|
/* fourth restart timer */
|
|
|
|
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNACK, inp, stcb, alt);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp,
|
|
|
|
struct sctp_tcb *stcb)
|
|
|
|
{
|
|
|
|
struct sctp_stream_queue_pending *sp;
|
2011-01-23 19:36:28 +00:00
|
|
|
unsigned int i, chks_in_queue = 0;
|
2006-11-03 15:23:16 +00:00
|
|
|
int being_filled = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function is ONLY called when the send/sent queues are empty.
|
|
|
|
*/
|
|
|
|
if ((stcb == NULL) || (inp == NULL))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (stcb->asoc.sent_queue_retran_cnt) {
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTP_PRINTF("Hmm, sent_queue_retran_cnt is non-zero %d\n",
|
2006-11-03 15:23:16 +00:00
|
|
|
stcb->asoc.sent_queue_retran_cnt);
|
|
|
|
stcb->asoc.sent_queue_retran_cnt = 0;
|
|
|
|
}
|
2011-01-23 19:36:28 +00:00
|
|
|
if (stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, &stcb->asoc)) {
|
2011-02-03 20:44:49 +00:00
|
|
|
/* No stream scheduler information, initialize scheduler */
|
|
|
|
stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 0);
|
|
|
|
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");
|
2006-11-03 15:23:16 +00:00
|
|
|
} else {
|
2011-02-03 20:44:49 +00:00
|
|
|
/* no streams lost */
|
2006-11-03 15:23:16 +00:00
|
|
|
stcb->asoc.total_output_queue_size = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Check to see if some data queued, if so report it */
|
2011-01-23 19:36:28 +00:00
|
|
|
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) {
|
2006-11-03 15:23:16 +00:00
|
|
|
if (sp->msg_is_complete)
|
|
|
|
being_filled++;
|
|
|
|
chks_in_queue++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (chks_in_queue != stcb->asoc.stream_queue_cnt) {
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTP_PRINTF("Hmm, stream queue cnt at %d I counted %d in stream out wheel\n",
|
2006-11-03 15:23:16 +00:00
|
|
|
stcb->asoc.stream_queue_cnt, chks_in_queue);
|
|
|
|
}
|
|
|
|
if (chks_in_queue) {
|
|
|
|
/* call the output queue function */
|
2007-09-08 11:35:11 +00:00
|
|
|
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_NOT_LOCKED);
|
2006-11-03 15:23:16 +00:00
|
|
|
if ((TAILQ_EMPTY(&stcb->asoc.send_queue)) &&
|
|
|
|
(TAILQ_EMPTY(&stcb->asoc.sent_queue))) {
|
|
|
|
/*
|
|
|
|
* Probably should go in and make it go back through
|
|
|
|
* and add fragments allowed
|
|
|
|
*/
|
|
|
|
if (being_filled == 0) {
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTP_PRINTF("Still nothing moved %d chunks are stuck\n",
|
2006-11-03 15:23:16 +00:00
|
|
|
chks_in_queue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2007-05-09 13:30:06 +00:00
|
|
|
SCTP_PRINTF("Found no chunks on any queue tot:%lu\n",
|
2006-11-03 15:23:16 +00:00
|
|
|
(u_long)stcb->asoc.total_output_queue_size);
|
|
|
|
stcb->asoc.total_output_queue_size = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
2011-08-03 20:21:00 +00:00
|
|
|
struct sctp_nets *net)
|
2006-11-03 15:23:16 +00:00
|
|
|
{
|
2011-08-03 20:21:00 +00:00
|
|
|
uint8_t net_was_pf;
|
2007-07-14 09:36:28 +00:00
|
|
|
|
2011-12-27 10:16:24 +00:00
|
|
|
if (net->dest_state & SCTP_ADDR_PF) {
|
|
|
|
net_was_pf = 1;
|
|
|
|
} else {
|
|
|
|
net_was_pf = 0;
|
|
|
|
}
|
|
|
|
if (net->hb_responded == 0) {
|
|
|
|
if (net->ro._s_addr) {
|
|
|
|
/*
|
|
|
|
* Invalidate the src address if we did not get a
|
|
|
|
* response last time.
|
|
|
|
*/
|
|
|
|
sctp_free_ifa(net->ro._s_addr);
|
|
|
|
net->ro._s_addr = NULL;
|
|
|
|
net->src_addr_selected = 0;
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
2011-12-27 10:16:24 +00:00
|
|
|
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);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-27 10:16:24 +00:00
|
|
|
/* Zero PBA, if it needs it */
|
|
|
|
if (net->partial_bytes_acked) {
|
|
|
|
net->partial_bytes_acked = 0;
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
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);
|
|
|
|
}
|
2011-08-03 20:21:00 +00:00
|
|
|
if (!(net->dest_state & SCTP_ADDR_NOHB) &&
|
|
|
|
!((net_was_pf == 0) && (net->dest_state & SCTP_ADDR_PF))) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/*
|
2011-08-03 20:21:00 +00:00
|
|
|
* when move to PF during threshold mangement, a HB has been
|
|
|
|
* queued in that routine
|
2006-11-03 15:23:16 +00:00
|
|
|
*/
|
2012-04-14 20:22:01 +00:00
|
|
|
uint32_t ms_gone_by;
|
|
|
|
|
|
|
|
if ((net->last_sent_time.tv_sec > 0) ||
|
|
|
|
(net->last_sent_time.tv_usec > 0)) {
|
|
|
|
struct timeval diff;
|
|
|
|
|
|
|
|
SCTP_GETTIME_TIMEVAL(&diff);
|
|
|
|
timevalsub(&diff, &net->last_sent_time);
|
2016-12-26 11:06:41 +00:00
|
|
|
ms_gone_by = (uint32_t)(diff.tv_sec * 1000) +
|
|
|
|
(uint32_t)(diff.tv_usec / 1000);
|
2012-04-14 20:22:01 +00:00
|
|
|
} else {
|
|
|
|
ms_gone_by = 0xffffffff;
|
|
|
|
}
|
2012-04-14 21:01:44 +00:00
|
|
|
if ((ms_gone_by >= net->heart_beat_delay) ||
|
|
|
|
(net->dest_state & SCTP_ADDR_PF)) {
|
2012-04-14 20:22:01 +00:00
|
|
|
sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED);
|
|
|
|
}
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sctp_pathmtu_timer(struct sctp_inpcb *inp,
|
|
|
|
struct sctp_tcb *stcb,
|
|
|
|
struct sctp_nets *net)
|
|
|
|
{
|
2008-05-20 13:47:46 +00:00
|
|
|
uint32_t next_mtu, mtu;
|
2006-11-03 15:23:16 +00:00
|
|
|
|
2011-12-17 19:21:40 +00:00
|
|
|
next_mtu = sctp_get_next_mtu(net->mtu);
|
2007-05-08 00:21:05 +00:00
|
|
|
|
2008-05-20 13:47:46 +00:00
|
|
|
if ((next_mtu > net->mtu) && (net->port == 0)) {
|
2007-05-08 00:21:05 +00:00
|
|
|
if ((net->src_addr_selected == 0) ||
|
|
|
|
(net->ro._s_addr == NULL) ||
|
|
|
|
(net->ro._s_addr->localifa_flags & SCTP_BEING_DELETED)) {
|
2007-05-09 13:30:06 +00:00
|
|
|
if ((net->ro._s_addr != NULL) && (net->ro._s_addr->localifa_flags & SCTP_BEING_DELETED)) {
|
2007-05-08 00:21:05 +00:00
|
|
|
sctp_free_ifa(net->ro._s_addr);
|
|
|
|
net->ro._s_addr = NULL;
|
|
|
|
net->src_addr_selected = 0;
|
2007-05-09 13:30:06 +00:00
|
|
|
} else if (net->ro._s_addr == NULL) {
|
2008-05-20 13:47:46 +00:00
|
|
|
#if defined(INET6) && defined(SCTP_EMBEDDED_V6_SCOPE)
|
|
|
|
if (net->ro._l_addr.sa.sa_family == AF_INET6) {
|
|
|
|
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
|
|
|
|
|
|
|
|
/* KAME hack: embed scopeid */
|
2009-09-17 15:11:12 +00:00
|
|
|
(void)sa6_embedscope(sin6, MODULE_GLOBAL(ip6_use_defzone));
|
2008-05-20 13:47:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-05-09 13:30:06 +00:00
|
|
|
net->ro._s_addr = sctp_source_address_selection(inp,
|
|
|
|
stcb,
|
2016-12-26 11:06:41 +00:00
|
|
|
(sctp_route_t *)&net->ro,
|
2007-05-09 13:30:06 +00:00
|
|
|
net, 0, stcb->asoc.vrf_id);
|
2008-05-20 13:47:46 +00:00
|
|
|
#if defined(INET6) && defined(SCTP_EMBEDDED_V6_SCOPE)
|
|
|
|
if (net->ro._l_addr.sa.sa_family == AF_INET6) {
|
|
|
|
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
|
|
|
|
|
|
|
|
(void)sa6_recoverscope(sin6);
|
|
|
|
}
|
|
|
|
#endif /* INET6 */
|
2007-05-08 00:21:05 +00:00
|
|
|
}
|
|
|
|
if (net->ro._s_addr)
|
|
|
|
net->src_addr_selected = 1;
|
|
|
|
}
|
|
|
|
if (net->ro._s_addr) {
|
|
|
|
mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._s_addr.sa, net->ro.ro_rt);
|
2014-07-11 06:52:48 +00:00
|
|
|
#if defined(INET) || defined(INET6)
|
2008-12-06 13:19:54 +00:00
|
|
|
if (net->port) {
|
|
|
|
mtu -= sizeof(struct udphdr);
|
|
|
|
}
|
2014-07-11 06:52:48 +00:00
|
|
|
#endif
|
2007-05-08 00:21:05 +00:00
|
|
|
if (mtu > next_mtu) {
|
2006-11-03 15:23:16 +00:00
|
|
|
net->mtu = next_mtu;
|
2015-08-14 14:26:13 +00:00
|
|
|
} else {
|
|
|
|
net->mtu = mtu;
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* restart the timer */
|
|
|
|
sctp_timer_start(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sctp_autoclose_timer(struct sctp_inpcb *inp,
|
|
|
|
struct sctp_tcb *stcb,
|
|
|
|
struct sctp_nets *net)
|
|
|
|
{
|
|
|
|
struct timeval tn, *tim_touse;
|
|
|
|
struct sctp_association *asoc;
|
|
|
|
int ticks_gone_by;
|
|
|
|
|
2007-05-08 14:32:53 +00:00
|
|
|
(void)SCTP_GETTIME_TIMEVAL(&tn);
|
2006-11-03 15:23:16 +00:00
|
|
|
if (stcb->asoc.sctp_autoclose_ticks &&
|
|
|
|
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 = SEC_TO_TICKS(tn.tv_sec - tim_touse->tv_sec);
|
|
|
|
if ((ticks_gone_by > 0) &&
|
|
|
|
(ticks_gone_by >= (int)asoc->sctp_autoclose_ticks)) {
|
|
|
|
/*
|
|
|
|
* autoclose time has hit, call the output routine,
|
|
|
|
* which should do nothing just to be SURE we don't
|
|
|
|
* have hanging data. We can then safely check the
|
|
|
|
* queues and know that we are clear to send
|
|
|
|
* shutdown
|
|
|
|
*/
|
2007-09-08 11:35:11 +00:00
|
|
|
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_AUTOCLOSE_TMR, SCTP_SO_NOT_LOCKED);
|
2006-11-03 15:23:16 +00:00
|
|
|
/* Are we clean? */
|
|
|
|
if (TAILQ_EMPTY(&asoc->send_queue) &&
|
|
|
|
TAILQ_EMPTY(&asoc->sent_queue)) {
|
|
|
|
/*
|
|
|
|
* there is nothing queued to send, so I'm
|
|
|
|
* done...
|
|
|
|
*/
|
2007-02-12 23:24:31 +00:00
|
|
|
if (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) {
|
2006-11-03 15:23:16 +00:00
|
|
|
/* only send SHUTDOWN 1st time thru */
|
2011-08-03 20:21:00 +00:00
|
|
|
struct sctp_nets *netp;
|
|
|
|
|
2007-02-12 23:24:31 +00:00
|
|
|
if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
|
|
|
|
(SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
|
|
|
|
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
|
|
|
|
}
|
2007-08-24 00:53:53 +00:00
|
|
|
SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT);
|
2007-10-16 14:05:51 +00:00
|
|
|
SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
|
2013-02-09 08:27:08 +00:00
|
|
|
sctp_stop_timers_for_shutdown(stcb);
|
|
|
|
if (stcb->asoc.alternate) {
|
|
|
|
netp = stcb->asoc.alternate;
|
|
|
|
} else {
|
|
|
|
netp = stcb->asoc.primary_destination;
|
|
|
|
}
|
|
|
|
sctp_send_shutdown(stcb, netp);
|
2006-11-03 15:23:16 +00:00
|
|
|
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN,
|
|
|
|
stcb->sctp_ep, stcb,
|
2011-08-03 20:21:00 +00:00
|
|
|
netp);
|
2006-11-03 15:23:16 +00:00
|
|
|
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
|
|
|
|
stcb->sctp_ep, stcb,
|
2011-08-03 20:21:00 +00:00
|
|
|
netp);
|
2006-11-03 15:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* No auto close at this time, reset t-o to check
|
|
|
|
* later
|
|
|
|
*/
|
|
|
|
int tmp;
|
|
|
|
|
|
|
|
/* 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,
|
|
|
|
net);
|
|
|
|
/* restore the real tick value */
|
|
|
|
asoc->sctp_autoclose_ticks = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|