Merge branch 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/vegard...
[firefly-linux-kernel-4.4.55.git] / net / sctp / sm_sideeffect.c
index b5495aecab60dbef2f75f3b210b241992d62ffb7..86426aac16009ec3e886efc2dd8fdd3f82f6a612 100644 (file)
@@ -434,7 +434,8 @@ sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
  *
  */
 static void sctp_do_8_2_transport_strike(struct sctp_association *asoc,
-                                        struct sctp_transport *transport)
+                                        struct sctp_transport *transport,
+                                        int is_hb)
 {
        /* The check for association's overall error counter exceeding the
         * threshold is done in the state function.
@@ -461,9 +462,15 @@ static void sctp_do_8_2_transport_strike(struct sctp_association *asoc,
         * expires, set RTO <- RTO * 2 ("back off the timer").  The
         * maximum value discussed in rule C7 above (RTO.max) may be
         * used to provide an upper bound to this doubling operation.
+        *
+        * Special Case:  the first HB doesn't trigger exponential backoff.
+        * The first unacknowleged HB triggers it.  We do this with a flag
+        * that indicates that we have an outstanding HB.
         */
-       transport->last_rto = transport->rto;
-       transport->rto = min((transport->rto * 2), transport->asoc->rto_max);
+       if (!is_hb || transport->hb_sent) {
+               transport->last_rto = transport->rto;
+               transport->rto = min((transport->rto * 2), transport->asoc->rto_max);
+       }
 }
 
 /* Worker routine to handle INIT command failure.  */
@@ -621,6 +628,11 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds,
        t->error_count = 0;
        t->asoc->overall_error_count = 0;
 
+       /* Clear the hb_sent flag to signal that we had a good
+        * acknowledgement.
+        */
+       t->hb_sent = 0;
+
        /* Mark the destination transport address as active if it is not so
         * marked.
         */
@@ -646,18 +658,6 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds,
                sctp_transport_hold(t);
 }
 
-/* Helper function to do a transport reset at the expiry of the hearbeat
- * timer.
- */
-static void sctp_cmd_transport_reset(sctp_cmd_seq_t *cmds,
-                                    struct sctp_association *asoc,
-                                    struct sctp_transport *t)
-{
-       sctp_transport_lower_cwnd(t, SCTP_LOWER_CWND_INACTIVE);
-
-       /* Mark one strike against a transport.  */
-       sctp_do_8_2_transport_strike(asoc, t);
-}
 
 /* Helper function to process the process SACK command.  */
 static int sctp_cmd_process_sack(sctp_cmd_seq_t *cmds,
@@ -686,7 +686,8 @@ static void sctp_cmd_setup_t2(sctp_cmd_seq_t *cmds,
 {
        struct sctp_transport *t;
 
-       t = sctp_assoc_choose_shutdown_transport(asoc);
+       t = sctp_assoc_choose_alter_transport(asoc,
+                                             asoc->shutdown_last_sent_to);
        asoc->shutdown_last_sent_to = t;
        asoc->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] = t->rto;
        chunk->transport = t;
@@ -777,7 +778,7 @@ static void sctp_cmd_setup_t4(sctp_cmd_seq_t *cmds,
 {
        struct sctp_transport *t;
 
-       t = asoc->peer.active_path;
+       t = sctp_assoc_choose_alter_transport(asoc, chunk->transport);
        asoc->timeouts[SCTP_EVENT_TIMEOUT_T4_RTO] = t->rto;
        chunk->transport = t;
 }
@@ -1379,7 +1380,8 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
 
                case SCTP_CMD_INIT_CHOOSE_TRANSPORT:
                        chunk = cmd->obj.ptr;
-                       t = sctp_assoc_choose_init_transport(asoc);
+                       t = sctp_assoc_choose_alter_transport(asoc,
+                                               asoc->init_last_sent_to);
                        asoc->init_last_sent_to = t;
                        chunk->transport = t;
                        t->init_sent_count++;
@@ -1458,12 +1460,19 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
 
                case SCTP_CMD_STRIKE:
                        /* Mark one strike against a transport.  */
-                       sctp_do_8_2_transport_strike(asoc, cmd->obj.transport);
+                       sctp_do_8_2_transport_strike(asoc, cmd->obj.transport,
+                                                   0);
+                       break;
+
+               case SCTP_CMD_TRANSPORT_IDLE:
+                       t = cmd->obj.transport;
+                       sctp_transport_lower_cwnd(t, SCTP_LOWER_CWND_INACTIVE);
                        break;
 
-               case SCTP_CMD_TRANSPORT_RESET:
+               case SCTP_CMD_TRANSPORT_HB_SENT:
                        t = cmd->obj.transport;
-                       sctp_cmd_transport_reset(commands, asoc, t);
+                       sctp_do_8_2_transport_strike(asoc, t, 1);
+                       t->hb_sent = 1;
                        break;
 
                case SCTP_CMD_TRANSPORT_ON: