Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / net / sctp / transport.c
index 198ab76..160f62a 100644 (file)
 
 /* 1st Level Abstractions.  */
 
-/* Allocate and initialize a new transport.  */
-struct sctp_transport *sctp_transport_new(const union sctp_addr *addr, int gfp)
-{
-        struct sctp_transport *transport;
-
-        transport = t_new(struct sctp_transport, gfp);
-       if (!transport)
-               goto fail;
-
-       if (!sctp_transport_init(transport, addr, gfp))
-               goto fail_init;
-
-       transport->malloced = 1;
-       SCTP_DBG_OBJCNT_INC(transport);
-
-       return transport;
-
-fail_init:
-       kfree(transport);
-
-fail:
-       return NULL;
-}
-
 /* Initialize a new transport from provided memory.  */
-struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
-                                          const union sctp_addr *addr,
-                                          int gfp)
+static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
+                                                 const union sctp_addr *addr,
+                                                 gfp_t gfp)
 {
        /* Copy in the address.  */
        peer->ipaddr = *addr;
@@ -107,12 +83,16 @@ struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
        peer->last_time_used = jiffies;
        peer->last_time_ecne_reduced = jiffies;
 
-       peer->active = SCTP_ACTIVE;
-       peer->hb_allowed = 0;
+       peer->init_sent_count = 0;
+
+       peer->state = SCTP_ACTIVE;
+       peer->param_flags = SPP_HB_DISABLE |
+                           SPP_PMTUD_ENABLE |
+                           SPP_SACKDELAY_ENABLE;
+       peer->hbinterval  = 0;
 
        /* Initialize the default path max_retrans.  */
-       peer->max_retrans = sctp_max_retrans_path;
-       peer->error_threshold = 0;
+       peer->pathmaxrxt  = sctp_max_retrans_path;
        peer->error_count = 0;
 
        INIT_LIST_HEAD(&peer->transmitted);
@@ -126,7 +106,6 @@ struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
 
        /* Set up the heartbeat timer. */
        init_timer(&peer->hb_timer);
-       peer->hb_interval = SCTP_DEFAULT_TIMEOUT_HEARTBEAT;
        peer->hb_timer.function = sctp_generate_heartbeat_event;
        peer->hb_timer.data = (unsigned long)peer;
 
@@ -144,6 +123,31 @@ struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
        return peer;
 }
 
+/* Allocate and initialize a new transport.  */
+struct sctp_transport *sctp_transport_new(const union sctp_addr *addr,
+                                         gfp_t gfp)
+{
+        struct sctp_transport *transport;
+
+        transport = t_new(struct sctp_transport, gfp);
+       if (!transport)
+               goto fail;
+
+       if (!sctp_transport_init(transport, addr, gfp))
+               goto fail_init;
+
+       transport->malloced = 1;
+       SCTP_DBG_OBJCNT_INC(transport);
+
+       return transport;
+
+fail_init:
+       kfree(transport);
+
+fail:
+       return NULL;
+}
+
 /* This transport is no longer needed.  Free up if possible, or
  * delay until it last reference count.
  */
@@ -155,13 +159,23 @@ void sctp_transport_free(struct sctp_transport *transport)
        if (del_timer(&transport->hb_timer))
                sctp_transport_put(transport);
 
+       /* Delete the T3_rtx timer if it's active.
+        * There is no point in not doing this now and letting
+        * structure hang around in memory since we know
+        * the tranport is going away.
+        */
+       if (timer_pending(&transport->T3_rtx_timer) &&
+           del_timer(&transport->T3_rtx_timer))
+               sctp_transport_put(transport);
+
+
        sctp_transport_put(transport);
 }
 
 /* Destroy the transport data structure.
  * Assumes there are no more users of this structure.
  */
-void sctp_transport_destroy(struct sctp_transport *transport)
+static void sctp_transport_destroy(struct sctp_transport *transport)
 {
        SCTP_ASSERT(transport->dead, "Transport is not dead", return);
 
@@ -218,17 +232,17 @@ void sctp_transport_pmtu(struct sctp_transport *transport)
        dst = transport->af_specific->get_dst(NULL, &transport->ipaddr, NULL);
 
        if (dst) {
-               transport->pmtu = dst_pmtu(dst);
+               transport->pathmtu = dst_mtu(dst);
                dst_release(dst);
        } else
-               transport->pmtu = SCTP_DEFAULT_MAXSEGMENT;
+               transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT;
 }
 
 /* Caches the dst entry and source address for a transport's destination
  * address.
  */
 void sctp_transport_route(struct sctp_transport *transport,
-                         union sctp_addr *saddr, struct sctp_opt *opt)
+                         union sctp_addr *saddr, struct sctp_sock *opt)
 {
        struct sctp_association *asoc = transport->asoc;
        struct sctp_af *af = transport->af_specific;
@@ -243,16 +257,20 @@ void sctp_transport_route(struct sctp_transport *transport,
                af->get_saddr(asoc, dst, daddr, &transport->saddr);
 
        transport->dst = dst;
+       if ((transport->param_flags & SPP_PMTUD_DISABLE) && transport->pathmtu) {
+               return;
+       }
        if (dst) {
-               transport->pmtu = dst_pmtu(dst);
+               transport->pathmtu = dst_mtu(dst);
 
                /* Initialize sk->sk_rcv_saddr, if the transport is the
                 * association's active path for getsockname().
                 */ 
                if (asoc && (transport == asoc->peer.active_path))
-                       af->to_sk_saddr(&transport->saddr, asoc->base.sk);
+                       opt->pf->af->to_sk_saddr(&transport->saddr,
+                                                asoc->base.sk);
        } else
-               transport->pmtu = SCTP_DEFAULT_MAXSEGMENT;
+               transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT;
 }
 
 /* Hold a reference to a transport.  */
@@ -332,7 +350,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);
 }
 
@@ -357,7 +375,7 @@ void sctp_transport_raise_cwnd(struct sctp_transport *transport,
 
        ssthresh = transport->ssthresh;
        pba = transport->partial_bytes_acked;
-       pmtu = transport->asoc->pmtu;
+       pmtu = transport->asoc->pathmtu;
 
        if (cwnd <= ssthresh) {
                /* RFC 2960 7.2.1, sctpimpguide-05 2.14.2 When cwnd is less
@@ -421,16 +439,16 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
 {
        switch (reason) {
        case SCTP_LOWER_CWND_T3_RTX:
-               /* RFC 2960 Section 7.2.3, sctpimpguide-05 Section 2.9.2
+               /* RFC 2960 Section 7.2.3, sctpimpguide
                 * When the T3-rtx timer expires on an address, SCTP should
                 * perform slow start by:
-                *      ssthresh = max(cwnd/2, 2*MTU)
+                *      ssthresh = max(cwnd/2, 4*MTU)
                 *      cwnd = 1*MTU
                 *      partial_bytes_acked = 0
                 */
                transport->ssthresh = max(transport->cwnd/2,
-                                         2*transport->asoc->pmtu);
-               transport->cwnd = transport->asoc->pmtu;
+                                         4*transport->asoc->pathmtu);
+               transport->cwnd = transport->asoc->pathmtu;
                break;
 
        case SCTP_LOWER_CWND_FAST_RTX:
@@ -439,15 +457,15 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
                 * were last sent, according to the formula described in
                 * Section 7.2.3.
                 *
-                * RFC 2960 7.2.3, sctpimpguide-05 2.9.2 Upon detection of
-                * packet losses from SACK (see Section 7.2.4), An endpoint
+                * 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, 2*MTU)
+                *      ssthresh = max(cwnd/2, 4*MTU)
                 *      cwnd = ssthresh
                 *      partial_bytes_acked = 0
                 */
                transport->ssthresh = max(transport->cwnd/2,
-                                         2*transport->asoc->pmtu);
+                                         4*transport->asoc->pathmtu);
                transport->cwnd = transport->ssthresh;
                break;
 
@@ -467,23 +485,24 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
                if ((jiffies - transport->last_time_ecne_reduced) >
                    transport->rtt) {
                        transport->ssthresh = max(transport->cwnd/2,
-                                                 2*transport->asoc->pmtu);
+                                                 4*transport->asoc->pathmtu);
                        transport->cwnd = transport->ssthresh;
                        transport->last_time_ecne_reduced = jiffies;
                }
                break;
 
        case SCTP_LOWER_CWND_INACTIVE:
-               /* RFC 2960 Section 7.2.1, sctpimpguide-05 Section 2.14.2
-                * When the association does not transmit data on a given
-                * transport address within an RTO, the cwnd of the transport
-                * address should be adjusted to 2*MTU.
+               /* RFC 2960 Section 7.2.1, sctpimpguide
+                * When the endpoint does not transmit data on a given
+                * transport address, the cwnd of the transport address
+                * should be adjusted to max(cwnd/2, 4*MTU) per RTO.
                 * NOTE: Although the draft recommends that this check needs
                 * to be done every RTO interval, we do it every hearbeat
                 * interval.
                 */
                if ((jiffies - transport->last_time_used) > transport->rto)
-                       transport->cwnd = 2*transport->asoc->pmtu;
+                       transport->cwnd = max(transport->cwnd/2,
+                                                4*transport->asoc->pathmtu);
                break;
        };
 
@@ -498,7 +517,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
 unsigned long sctp_transport_timeout(struct sctp_transport *t)
 {
        unsigned long timeout;
-       timeout = t->hb_interval + t->rto + sctp_jitter(t->rto);
+       timeout = t->hbinterval + t->rto + sctp_jitter(t->rto);
        timeout += jiffies;
        return timeout;
 }