aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@fh-muenster.de>2020-03-25 19:25:20 +0100
committerMichael Tuexen <tuexen@fh-muenster.de>2020-03-25 19:25:20 +0100
commit30513f858d9bae921fa9cec8e3ecda5564233458 (patch)
treec8a9839ee79a4648c28e37ec3c03d2bfa35adb6a
parent1f495441f0a58dc2d15aa9cc78fb5cd5cea6e25a (diff)
downloadusrsctp-30513f858d9bae921fa9cec8e3ecda5564233458.tar.gz
Don't optimize for timers when the socket is gone. This fixes
another bug where the COOKIE was not retransmitted if the socket was closed.
-rwxr-xr-xusrsctplib/netinet/sctputil.c54
1 files changed, 17 insertions, 37 deletions
diff --git a/usrsctplib/netinet/sctputil.c b/usrsctplib/netinet/sctputil.c
index 536611cb..83efdf8d 100755
--- a/usrsctplib/netinet/sctputil.c
+++ b/usrsctplib/netinet/sctputil.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 359301 2020-03-25 13:19:41Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 359306 2020-03-25 18:20:37Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -1732,30 +1732,10 @@ sctp_timeout_handler(void *t)
KASSERT(tmr->self == tmr, ("tmr->self corrupted"));
KASSERT(SCTP_IS_TIMER_TYPE_VALID(tmr->type), ("Invalid timer type %d", tmr->type));
type = tmr->type;
- tmr->stopped_from = 0xa001;
if (inp) {
SCTP_INP_INCR_REF(inp);
- if ((inp->sctp_socket == NULL) &&
- ((type != SCTP_TIMER_TYPE_INPKILL) &&
- (type != SCTP_TIMER_TYPE_INIT) &&
- (type != SCTP_TIMER_TYPE_SEND) &&
- (type != SCTP_TIMER_TYPE_RECV) &&
- (type != SCTP_TIMER_TYPE_HEARTBEAT) &&
- (type != SCTP_TIMER_TYPE_SHUTDOWN) &&
- (type != SCTP_TIMER_TYPE_SHUTDOWNACK) &&
- (type != SCTP_TIMER_TYPE_SHUTDOWNGUARD) &&
- (type != SCTP_TIMER_TYPE_ASOCKILL))) {
- SCTP_INP_DECR_REF(inp);
- SCTPDBG(SCTP_DEBUG_TIMER2,
- "Timer type %d handler exiting due to closed socket.\n",
- type);
-#if defined(__FreeBSD__) && __FreeBSD_version >= 801000
- CURVNET_RESTORE();
-#endif
- return;
- }
}
- tmr->stopped_from = 0xa002;
+ tmr->stopped_from = 0xa001;
if (stcb) {
atomic_add_int(&stcb->asoc.refcnt, 1);
if (stcb->asoc.state == 0) {
@@ -1772,8 +1752,8 @@ sctp_timeout_handler(void *t)
return;
}
}
- tmr->stopped_from = 0xa003;
- SCTPDBG(SCTP_DEBUG_TIMER1, "Timer type %d goes off\n", type);
+ tmr->stopped_from = 0xa002;
+ SCTPDBG(SCTP_DEBUG_TIMER2, "Timer type %d goes off.\n", type);
if (!SCTP_OS_TIMER_ACTIVE(&tmr->timer)) {
if (inp) {
SCTP_INP_DECR_REF(inp);
@@ -1789,8 +1769,8 @@ sctp_timeout_handler(void *t)
#endif
return;
}
- tmr->stopped_from = 0xa004;
+ tmr->stopped_from = 0xa003;
if (stcb) {
SCTP_TCB_LOCK(stcb);
atomic_add_int(&stcb->asoc.refcnt, -1);
@@ -1814,9 +1794,9 @@ sctp_timeout_handler(void *t)
} else {
SCTP_WQ_ADDR_LOCK();
}
- /* record in stopped what t-o occurred */
- tmr->stopped_from = type;
+ /* Record in stopped_from which timeout occurred. */
+ tmr->stopped_from = type;
#if defined(__FreeBSD__)
NET_EPOCH_ENTER(et);
#endif
@@ -2219,14 +2199,14 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) &&
(t_type != SCTP_TIMER_TYPE_ASOCKILL)) {
SCTPDBG(SCTP_DEBUG_TIMER2,
- "timer type %d not started: inp=%p, stcb=%p, net=%p (stcb deleted).\n",
+ "Timer type %d not started: inp=%p, stcb=%p, net=%p (stcb deleted).\n",
t_type, inp, stcb, net);
return;
}
/* Don't restart timer on net that's been removed. */
if (net != NULL && (net->dest_state & SCTP_ADDR_BEING_DELETED)) {
SCTPDBG(SCTP_DEBUG_TIMER2,
- "timer type %d not started: inp=%p, stcb=%p, net=%p (net deleted).\n",
+ "Timer type %d not started: inp=%p, stcb=%p, net=%p (net deleted).\n",
t_type, inp, stcb, net);
return;
}
@@ -2319,7 +2299,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
if ((net->dest_state & SCTP_ADDR_NOHB) &&
!(net->dest_state & SCTP_ADDR_UNCONFIRMED)) {
SCTPDBG(SCTP_DEBUG_TIMER2,
- "timer type %d not started: inp=%p, stcb=%p, net=%p.\n",
+ "Timer type %d not started: inp=%p, stcb=%p, net=%p.\n",
t_type, inp, stcb, net);
return;
}
@@ -2398,7 +2378,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
if (net->dest_state & SCTP_ADDR_NO_PMTUD) {
SCTPDBG(SCTP_DEBUG_TIMER2,
- "timer type %d not started: inp=%p, stcb=%p, net=%p.\n",
+ "Timer type %d not started: inp=%p, stcb=%p, net=%p.\n",
t_type, inp, stcb, net);
return;
}
@@ -2563,7 +2543,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* we leave the current one up unchanged.
*/
SCTPDBG(SCTP_DEBUG_TIMER2,
- "timer type %d already running: inp=%p, stcb=%p, net=%p.\n",
+ "Timer type %d already running: inp=%p, stcb=%p, net=%p.\n",
t_type, inp, stcb, net);
return;
}
@@ -2587,7 +2567,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
tmr->ticks = sctp_get_tick_count();
if (SCTP_OS_TIMER_START(&tmr->timer, to_ticks, sctp_timeout_handler, tmr) == 0) {
SCTPDBG(SCTP_DEBUG_TIMER2,
- "timer type %d started: ticks=%u, inp=%p, stcb=%p, net=%p.\n",
+ "Timer type %d started: ticks=%u, inp=%p, stcb=%p, net=%p.\n",
t_type, to_ticks, inp, stcb, net);
} else {
/*
@@ -2595,7 +2575,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* above.
*/
SCTPDBG(SCTP_DEBUG_TIMER2,
- "timer type %d restarted: ticks=%u, inp=%p, stcb=%p, net=%p.\n",
+ "Timer type %d restarted: ticks=%u, inp=%p, stcb=%p, net=%p.\n",
t_type, to_ticks, inp, stcb, net);
}
return;
@@ -2852,7 +2832,7 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* return.
*/
SCTPDBG(SCTP_DEBUG_TIMER2,
- "shared timer type %d not running: inp=%p, stcb=%p, net=%p.\n",
+ "Shared timer type %d not running: inp=%p, stcb=%p, net=%p.\n",
t_type, inp, stcb, net);
return;
}
@@ -2876,14 +2856,14 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
("sctp_timer_stop of type %d: net = %p, tmr->net = %p",
t_type, net, tmr->net));
SCTPDBG(SCTP_DEBUG_TIMER2,
- "timer type %d stopped: inp=%p, stcb=%p, net=%p.\n",
+ "Timer type %d stopped: inp=%p, stcb=%p, net=%p.\n",
t_type, inp, stcb, net);
tmr->ep = NULL;
tmr->tcb = NULL;
tmr->net = NULL;
} else {
SCTPDBG(SCTP_DEBUG_TIMER2,
- "timer type %d not stopped: inp=%p, stcb=%p, net=%p.\n",
+ "Timer type %d not stopped: inp=%p, stcb=%p, net=%p.\n",
t_type, inp, stcb, net);
}
return;