Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-drm-fsl-dcu.git] / net / sctp / transport.c
index 68d73e2dd155e33c2ca06e7bbd283b5a66738609..a596f5308cb18c89cd63836f95d65aef1f630b58 100644 (file)
@@ -49,6 +49,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/random.h>
 #include <net/sctp/sctp.h>
 #include <net/sctp/sm.h>
 
@@ -74,7 +75,7 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
         * parameter 'RTO.Initial'.
         */
        peer->rtt = 0;
-       peer->rto = sctp_rto_initial;
+       peer->rto = msecs_to_jiffies(sctp_rto_initial);
        peer->rttvar = 0;
        peer->srtt = 0;
        peer->rto_pending = 0;
@@ -85,7 +86,6 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
 
        peer->init_sent_count = 0;
 
-       peer->state = SCTP_ACTIVE;
        peer->param_flags = SPP_HB_DISABLE |
                            SPP_PMTUD_ENABLE |
                            SPP_SACKDELAY_ENABLE;
@@ -109,6 +109,9 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
        peer->hb_timer.function = sctp_generate_heartbeat_event;
        peer->hb_timer.data = (unsigned long)peer;
 
+       /* Initialize the 64-bit random nonce sent with heartbeat. */
+       get_random_bytes(&peer->hb_nonce, sizeof(peer->hb_nonce));
+
        atomic_set(&peer->refcnt, 1);
        peer->dead = 0;
 
@@ -127,9 +130,9 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
 struct sctp_transport *sctp_transport_new(const union sctp_addr *addr,
                                          gfp_t gfp)
 {
-        struct sctp_transport *transport;
+       struct sctp_transport *transport;
 
-        transport = t_new(struct sctp_transport, gfp);
+       transport = t_new(struct sctp_transport, gfp);
        if (!transport)
                goto fail;
 
@@ -182,7 +185,7 @@ static void sctp_transport_destroy(struct sctp_transport *transport)
        if (transport->asoc)
                sctp_association_put(transport->asoc);
 
-        sctp_packet_free(&transport->packet);
+       sctp_packet_free(&transport->packet);
 
        dst_release(transport->dst);
        kfree(transport);
@@ -265,7 +268,7 @@ void sctp_transport_route(struct sctp_transport *transport,
 
                /* Initialize sk->sk_rcv_saddr, if the transport is the
                 * association's active path for getsockname().
-                */ 
+                */
                if (asoc && (transport == asoc->peer.active_path))
                        opt->pf->af->to_sk_saddr(&transport->saddr,
                                                 asoc->base.sk);
@@ -350,7 +353,7 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt)
        tp->rto_pending = 0;
 
        SCTP_DEBUG_PRINTK("%s: transport: %p, rtt: %d, srtt: %d "
-                         "rttvar: %d, rto: %d\n", __FUNCTION__,
+                         "rttvar: %d, rto: %ld\n", __FUNCTION__,
                          tp, rtt, tp->srtt, tp->rttvar, tp->rto);
 }
 
@@ -456,8 +459,8 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
                 * destination address(es) to which the missing DATA chunks
                 * were last sent, according to the formula described in
                 * Section 7.2.3.
-                *
-                * RFC 2960 7.2.3, sctpimpguide Upon detection of packet
+                *
+                * RFC 2960 7.2.3, sctpimpguide Upon detection of packet
                 * losses from SACK (see Section 7.2.4), An endpoint
                 * should do the following:
                 *      ssthresh = max(cwnd/2, 4*MTU)
@@ -485,7 +488,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
                if ((jiffies - transport->last_time_ecne_reduced) >
                    transport->rtt) {
                        transport->ssthresh = max(transport->cwnd/2,
-                                                 4*transport->asoc->pathmtu);
+                                                 4*transport->asoc->pathmtu);
                        transport->cwnd = transport->ssthresh;
                        transport->last_time_ecne_reduced = jiffies;
                }
@@ -517,7 +520,9 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
 unsigned long sctp_transport_timeout(struct sctp_transport *t)
 {
        unsigned long timeout;
-       timeout = t->hbinterval + t->rto + sctp_jitter(t->rto);
+       timeout = t->rto + sctp_jitter(t->rto);
+       if (t->state != SCTP_UNCONFIRMED)
+               timeout += t->hbinterval;
        timeout += jiffies;
        return timeout;
 }