Author: tuexen
Date: Tue Mar 17 19:20:12 2020
New Revision: 359048
URL: https://svnweb.freebsd.org/changeset/base/359048

Log:
  Handle the timers in a consistent sequence according to the definition
  of the timer type.
  Just a cleanup, no functional change intended.
  
  MFC after:            1 week

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==============================================================================
--- head/sys/netinet/sctputil.c Tue Mar 17 18:44:03 2020        (r359047)
+++ head/sys/netinet/sctputil.c Tue Mar 17 19:20:12 2020        (r359048)
@@ -1738,9 +1738,6 @@ sctp_timeout_handler(void *t)
 
        /* 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;
@@ -1905,27 +1902,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;
@@ -1940,13 +1916,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;
@@ -1956,6 +1935,33 @@ 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);
+               sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
+                   SCTP_CALLED_FROM_INPKILL_TIMER);
+               inp = NULL;
+               goto out_no_decr;
        case SCTP_TIMER_TYPE_ASOCKILL:
                if ((stcb == NULL) || (inp == NULL)) {
                        break;
@@ -1984,22 +1990,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);
-               sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT,
-                   SCTP_CALLED_FROM_INPKILL_TIMER);
-               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);
@@ -2059,11 +2059,6 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, s
                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 */
                {
@@ -2183,22 +2178,6 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, s
                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
@@ -2225,6 +2204,21 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, s
                }
                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
@@ -2240,6 +2234,20 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, s
                }
                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
@@ -2255,21 +2263,27 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, s
                }
                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)) {
                        return;
@@ -2277,20 +2291,6 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, s
                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);
@@ -2340,9 +2340,6 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, st
                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;
@@ -2387,24 +2384,6 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, st
                 * 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;
@@ -2417,35 +2396,55 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, st
                }
                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",
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to