diff options
author | Michael Tuexen <tuexen@fh-muenster.de> | 2020-03-19 15:32:04 +0100 |
---|---|---|
committer | Michael Tuexen <tuexen@fh-muenster.de> | 2020-03-19 15:32:04 +0100 |
commit | 119007035d48bdf36e6232a141affb889e1df6e2 (patch) | |
tree | 97d585f84d23741cc11a1d63eaa13b1bbd975ab9 | |
parent | 7b87cd42ea036919a69acf299601469f2aa79b75 (diff) | |
download | usrsctp-119007035d48bdf36e6232a141affb889e1df6e2.tar.gz |
First pass on cleanup timer code.
-rwxr-xr-x | usrsctplib/netinet/sctputil.c | 245 |
1 files changed, 122 insertions, 123 deletions
diff --git a/usrsctplib/netinet/sctputil.c b/usrsctplib/netinet/sctputil.c index 0f9b1b2c..d656c6de 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 358083 2020-02-18 21:25:17Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 359048 2020-03-17 19:20:12Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -1837,9 +1837,6 @@ sctp_timeout_handler(void *t) #endif /* call the handler for the appropriate timer type */ switch (type) { - case SCTP_TIMER_TYPE_ADDR_WQ: - sctp_handle_addr_wq(); - break; case SCTP_TIMER_TYPE_SEND: if ((stcb == NULL) || (inp == NULL)) { break; @@ -2003,27 +2000,6 @@ sctp_timeout_handler(void *t) #endif sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SHUT_ACK_TMR, SCTP_SO_NOT_LOCKED); break; - case SCTP_TIMER_TYPE_SHUTDOWNGUARD: - if ((stcb == NULL) || (inp == NULL)) { - break; - } - SCTP_STAT_INCR(sctps_timoshutdownguard); - op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), - "Shutdown guard timer expired"); - sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); - /* no need to unlock on tcb its gone */ - goto out_decr; - case SCTP_TIMER_TYPE_STRRESET: - if ((stcb == NULL) || (inp == NULL)) { - break; - } - if (sctp_strreset_timer(inp, stcb, net)) { - /* no need to unlock on tcb its gone */ - goto out_decr; - } - SCTP_STAT_INCR(sctps_timostrmrst); - sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_STRRST_TMR, SCTP_SO_NOT_LOCKED); - break; case SCTP_TIMER_TYPE_ASCONF: if ((stcb == NULL) || (inp == NULL)) { break; @@ -2038,13 +2014,16 @@ sctp_timeout_handler(void *t) #endif sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_ASCONF_TMR, SCTP_SO_NOT_LOCKED); break; - case SCTP_TIMER_TYPE_PRIM_DELETED: + case SCTP_TIMER_TYPE_SHUTDOWNGUARD: if ((stcb == NULL) || (inp == NULL)) { break; } - sctp_delete_prim_timer(inp, stcb, net); - SCTP_STAT_INCR(sctps_timodelprim); - break; + SCTP_STAT_INCR(sctps_timoshutdownguard); + op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), + "Shutdown guard timer expired"); + sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); + /* no need to unlock on tcb its gone */ + goto out_decr; case SCTP_TIMER_TYPE_AUTOCLOSE: if ((stcb == NULL) || (inp == NULL)) { break; @@ -2054,6 +2033,39 @@ sctp_timeout_handler(void *t) sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_AUTOCLOSE_TMR, SCTP_SO_NOT_LOCKED); did_output = 0; break; + case SCTP_TIMER_TYPE_STRRESET: + if ((stcb == NULL) || (inp == NULL)) { + break; + } + if (sctp_strreset_timer(inp, stcb, net)) { + /* no need to unlock on tcb its gone */ + goto out_decr; + } + SCTP_STAT_INCR(sctps_timostrmrst); + sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_STRRST_TMR, SCTP_SO_NOT_LOCKED); + break; + case SCTP_TIMER_TYPE_INPKILL: + SCTP_STAT_INCR(sctps_timoinpkill); + if (inp == NULL) { + break; + } + /* + * special case, take away our increment since WE are the + * killer + */ + SCTP_INP_DECR_REF(inp); + sctp_timer_stop(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL, + SCTP_FROM_SCTPUTIL + SCTP_LOC_3); +#if defined(__APPLE__) + SCTP_SOCKET_LOCK(SCTP_INP_SO(inp), 1); +#endif + sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, + SCTP_CALLED_FROM_INPKILL_TIMER); +#if defined(__APPLE__) + SCTP_SOCKET_UNLOCK(SCTP_INP_SO(inp), 1); +#endif + inp = NULL; + goto out_no_decr; case SCTP_TIMER_TYPE_ASOCKILL: if ((stcb == NULL) || (inp == NULL)) { break; @@ -2082,28 +2094,16 @@ sctp_timeout_handler(void *t) */ stcb = NULL; goto out_no_decr; - case SCTP_TIMER_TYPE_INPKILL: - SCTP_STAT_INCR(sctps_timoinpkill); - if (inp == NULL) { + case SCTP_TIMER_TYPE_ADDR_WQ: + sctp_handle_addr_wq(); + break; + case SCTP_TIMER_TYPE_PRIM_DELETED: + if ((stcb == NULL) || (inp == NULL)) { break; } - /* - * special case, take away our increment since WE are the - * killer - */ - SCTP_INP_DECR_REF(inp); - sctp_timer_stop(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL, - SCTP_FROM_SCTPUTIL + SCTP_LOC_3); -#if defined(__APPLE__) - SCTP_SOCKET_LOCK(SCTP_INP_SO(inp), 1); -#endif - sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, - SCTP_CALLED_FROM_INPKILL_TIMER); -#if defined(__APPLE__) - SCTP_SOCKET_UNLOCK(SCTP_INP_SO(inp), 1); -#endif - inp = NULL; - goto out_no_decr; + sctp_delete_prim_timer(inp, stcb, net); + SCTP_STAT_INCR(sctps_timodelprim); + break; default: SCTPDBG(SCTP_DEBUG_TIMER1, "sctp_timeout_handler:unknown timer %d\n", type); @@ -2178,11 +2178,6 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, return; } switch (t_type) { - case SCTP_TIMER_TYPE_ADDR_WQ: - /* Only 1 tick away :-) */ - tmr = &SCTP_BASE_INFO(addr_wq_timer); - to_ticks = SCTP_ADDRESS_TICK_DELAY; - break; case SCTP_TIMER_TYPE_SEND: /* Here we use the RTO timer */ { @@ -2302,22 +2297,6 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, tmr = &inp->sctp_ep.signature_change; to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_SIGNATURE]; break; - case SCTP_TIMER_TYPE_ASOCKILL: - if (stcb == NULL) { - return; - } - tmr = &stcb->asoc.strreset_timer; - to_ticks = MSEC_TO_TICKS(SCTP_ASOC_KILL_TIMEOUT); - break; - case SCTP_TIMER_TYPE_INPKILL: - /* - * The inp is setup to die. We re-use the signature_chage - * timer since that has stopped and we are in the GONE - * state. - */ - tmr = &inp->sctp_ep.signature_change; - to_ticks = MSEC_TO_TICKS(SCTP_INP_KILL_TIMEOUT); - break; case SCTP_TIMER_TYPE_PATHMTURAISE: /* * Here we use the value found in the EP for PMTU ususually @@ -2344,6 +2323,21 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, } tmr = &net->rxt_timer; break; + case SCTP_TIMER_TYPE_ASCONF: + /* + * Here the timer comes from the stcb but its value is from + * the net's RTO. + */ + if ((stcb == NULL) || (net == NULL)) { + return; + } + if (net->RTO == 0) { + to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto); + } else { + to_ticks = MSEC_TO_TICKS(net->RTO); + } + tmr = &stcb->asoc.asconf_timer; + break; case SCTP_TIMER_TYPE_SHUTDOWNGUARD: /* * Here we use the endpoints shutdown guard timer usually @@ -2359,6 +2353,20 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, } tmr = &stcb->asoc.shut_guard_timer; break; + case SCTP_TIMER_TYPE_AUTOCLOSE: + if (stcb == NULL) { + return; + } + if (stcb->asoc.sctp_autoclose_ticks == 0) { + /* + * Really an error since stcb is NOT set to + * autoclose + */ + return; + } + to_ticks = stcb->asoc.sctp_autoclose_ticks; + tmr = &stcb->asoc.autoclose_timer; + break; case SCTP_TIMER_TYPE_STRRESET: /* * Here the timer comes from the stcb but its value is from @@ -2374,20 +2382,26 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, } tmr = &stcb->asoc.strreset_timer; break; - case SCTP_TIMER_TYPE_ASCONF: + case SCTP_TIMER_TYPE_INPKILL: /* - * Here the timer comes from the stcb but its value is from - * the net's RTO. + * The inp is setup to die. We re-use the signature_chage + * timer since that has stopped and we are in the GONE + * state. */ - if ((stcb == NULL) || (net == NULL)) { + tmr = &inp->sctp_ep.signature_change; + to_ticks = MSEC_TO_TICKS(SCTP_INP_KILL_TIMEOUT); + break; + case SCTP_TIMER_TYPE_ASOCKILL: + if (stcb == NULL) { return; } - if (net->RTO == 0) { - to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto); - } else { - to_ticks = MSEC_TO_TICKS(net->RTO); - } - tmr = &stcb->asoc.asconf_timer; + tmr = &stcb->asoc.strreset_timer; + to_ticks = MSEC_TO_TICKS(SCTP_ASOC_KILL_TIMEOUT); + break; + case SCTP_TIMER_TYPE_ADDR_WQ: + /* Only 1 tick away :-) */ + tmr = &SCTP_BASE_INFO(addr_wq_timer); + to_ticks = SCTP_ADDRESS_TICK_DELAY; break; case SCTP_TIMER_TYPE_PRIM_DELETED: if ((stcb == NULL) || (net != NULL)) { @@ -2396,20 +2410,6 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto); tmr = &stcb->asoc.delete_prim_timer; break; - case SCTP_TIMER_TYPE_AUTOCLOSE: - if (stcb == NULL) { - return; - } - if (stcb->asoc.sctp_autoclose_ticks == 0) { - /* - * Really an error since stcb is NOT set to - * autoclose - */ - return; - } - to_ticks = stcb->asoc.sctp_autoclose_ticks; - tmr = &stcb->asoc.autoclose_timer; - break; default: SCTPDBG(SCTP_DEBUG_TIMER1, "%s: Unknown timer type %d\n", __func__, t_type); @@ -2463,9 +2463,6 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, SCTP_TCB_LOCK_ASSERT(stcb); } switch (t_type) { - case SCTP_TIMER_TYPE_ADDR_WQ: - tmr = &SCTP_BASE_INFO(addr_wq_timer); - break; case SCTP_TIMER_TYPE_SEND: if ((stcb == NULL) || (net == NULL)) { return; @@ -2510,24 +2507,6 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, * must assure that we do not kill it by accident. */ break; - case SCTP_TIMER_TYPE_ASOCKILL: - /* - * Stop the asoc kill timer. - */ - if (stcb == NULL) { - return; - } - tmr = &stcb->asoc.strreset_timer; - break; - - case SCTP_TIMER_TYPE_INPKILL: - /* - * The inp is setup to die. We re-use the signature_chage - * timer since that has stopped and we are in the GONE - * state. - */ - tmr = &inp->sctp_ep.signature_change; - break; case SCTP_TIMER_TYPE_PATHMTURAISE: if ((stcb == NULL) || (net == NULL)) { return; @@ -2540,35 +2519,55 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, } tmr = &net->rxt_timer; break; + case SCTP_TIMER_TYPE_ASCONF: + if (stcb == NULL) { + return; + } + tmr = &stcb->asoc.asconf_timer; + break; case SCTP_TIMER_TYPE_SHUTDOWNGUARD: if (stcb == NULL) { return; } tmr = &stcb->asoc.shut_guard_timer; break; - case SCTP_TIMER_TYPE_STRRESET: + case SCTP_TIMER_TYPE_AUTOCLOSE: if (stcb == NULL) { return; } - tmr = &stcb->asoc.strreset_timer; + tmr = &stcb->asoc.autoclose_timer; break; - case SCTP_TIMER_TYPE_ASCONF: + case SCTP_TIMER_TYPE_STRRESET: if (stcb == NULL) { return; } - tmr = &stcb->asoc.asconf_timer; + tmr = &stcb->asoc.strreset_timer; break; - case SCTP_TIMER_TYPE_PRIM_DELETED: + case SCTP_TIMER_TYPE_INPKILL: + /* + * The inp is setup to die. We re-use the signature_chage + * timer since that has stopped and we are in the GONE + * state. + */ + tmr = &inp->sctp_ep.signature_change; + break; + case SCTP_TIMER_TYPE_ASOCKILL: + /* + * Stop the asoc kill timer. + */ if (stcb == NULL) { return; } - tmr = &stcb->asoc.delete_prim_timer; + tmr = &stcb->asoc.strreset_timer; break; - case SCTP_TIMER_TYPE_AUTOCLOSE: + case SCTP_TIMER_TYPE_ADDR_WQ: + tmr = &SCTP_BASE_INFO(addr_wq_timer); + break; + case SCTP_TIMER_TYPE_PRIM_DELETED: if (stcb == NULL) { return; } - tmr = &stcb->asoc.autoclose_timer; + tmr = &stcb->asoc.delete_prim_timer; break; default: SCTPDBG(SCTP_DEBUG_TIMER1, "%s: Unknown timer type %d\n", |