[SCTP] Update pmtu handling to be similar to tcp
[safe/jmp/linux-2.6] / net / sctp / transport.c
index c4699f5..e14c271 100644 (file)
@@ -241,6 +241,47 @@ void sctp_transport_pmtu(struct sctp_transport *transport)
                transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT;
 }
 
+/* this is a complete rip-off from __sk_dst_check
+ * the cookie is always 0 since this is how it's used in the
+ * pmtu code
+ */
+static struct dst_entry *sctp_transport_dst_check(struct sctp_transport *t)
+{
+       struct dst_entry *dst = t->dst;
+
+       if (dst && dst->obsolete && dst->ops->check(dst, 0) == NULL) {
+               dst_release(t->dst);
+               t->dst = NULL;
+               return NULL;
+       }
+
+       return dst;
+}
+
+void sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu)
+{
+       struct dst_entry *dst;
+
+       if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) {
+               printk(KERN_WARNING "%s: Reported pmtu %d too low, "
+                      "using default minimum of %d\n",
+                      __FUNCTION__, pmtu,
+                      SCTP_DEFAULT_MINSEGMENT);
+               /* Use default minimum segment size and disable
+                * pmtu discovery on this transport.
+                */
+               t->pathmtu = SCTP_DEFAULT_MINSEGMENT;
+               t->param_flags = (t->param_flags & ~SPP_PMTUD) |
+                       SPP_PMTUD_DISABLE;
+       } else {
+               t->pathmtu = pmtu;
+       }
+
+       dst = sctp_transport_dst_check(t);
+       if (dst)
+               dst->ops->update_pmtu(dst, pmtu);
+}
+
 /* Caches the dst entry and source address for a transport's destination
  * address.
  */
@@ -507,7 +548,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
                        transport->cwnd = max(transport->cwnd/2,
                                                 4*transport->asoc->pathmtu);
                break;
-       };
+       }
 
        transport->partial_bytes_acked = 0;
        SCTP_DEBUG_PRINTK("%s: transport: %p reason: %d cwnd: "
@@ -538,7 +579,7 @@ void sctp_transport_reset(struct sctp_transport *t)
         * (see Section 6.2.1)
         */
        t->cwnd = min(4*asoc->pathmtu, max_t(__u32, 2*asoc->pathmtu, 4380));
-       t->ssthresh = SCTP_DEFAULT_MAXWINDOW;
+       t->ssthresh = asoc->peer.i.a_rwnd;
        t->rto = asoc->rto_initial;
        t->rtt = 0;
        t->srtt = 0;