Merge branch 'sctp'
authorDavid S. Miller <davem@davemloft.net>
Thu, 3 Jul 2014 01:44:14 +0000 (18:44 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Jul 2014 01:44:14 +0000 (18:44 -0700)
Daniel Borkmann says:

====================
Misc SCTP updates

Daniel Borkmann (2):
  net: sctp: improve timer slack calculation for transport HBs
  net: sctp: only warn in proc_sctp_do_alpha_beta if write
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
include/net/sctp/sctp.h
net/sctp/sysctl.c
net/sctp/transport.c

index 8e4de46c052ec7d78188f203df2b69b0a0b423ab..c2035c96a2ee150a833ab28aa71e510abab72a5b 100644 (file)
@@ -388,27 +388,6 @@ static inline int sctp_list_single_entry(struct list_head *head)
        return (head->next != head) && (head->next == head->prev);
 }
 
-/* Generate a random jitter in the range of -50% ~ +50% of input RTO. */
-static inline __s32 sctp_jitter(__u32 rto)
-{
-       static __u32 sctp_rand;
-       __s32 ret;
-
-       /* Avoid divide by zero. */
-       if (!rto)
-               rto = 1;
-
-       sctp_rand += jiffies;
-       sctp_rand ^= (sctp_rand << 12);
-       sctp_rand ^= (sctp_rand >> 20);
-
-       /* Choose random number from 0 to rto, then move to -50% ~ +50%
-        * of rto.
-        */
-       ret = sctp_rand % rto - (rto >> 1);
-       return ret;
-}
-
 /* Break down data chunks at this point.  */
 static inline int sctp_frag_point(const struct sctp_association *asoc, int pmtu)
 {
index 12c7e01c267711ef19878f6c1da1e66e257ecf7e..2e9ada10fd846c10bc6281c30f29cf1fed02ca3c 100644 (file)
@@ -424,8 +424,9 @@ static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
                                   void __user *buffer, size_t *lenp,
                                   loff_t *ppos)
 {
-       pr_warn_once("Changing rto_alpha or rto_beta may lead to "
-                    "suboptimal rtt/srtt estimations!\n");
+       if (write)
+               pr_warn_once("Changing rto_alpha or rto_beta may lead to "
+                            "suboptimal rtt/srtt estimations!\n");
 
        return proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
 }
index 7dd672fa651f979ae6b93578fc678254a7317b6b..b10e047bbd15548b405393837047b437e4802d26 100644 (file)
@@ -594,15 +594,16 @@ void sctp_transport_burst_reset(struct sctp_transport *t)
 }
 
 /* What is the next timeout value for this transport? */
-unsigned long sctp_transport_timeout(struct sctp_transport *t)
+unsigned long sctp_transport_timeout(struct sctp_transport *trans)
 {
-       unsigned long timeout;
-       timeout = t->rto + sctp_jitter(t->rto);
-       if ((t->state != SCTP_UNCONFIRMED) &&
-           (t->state != SCTP_PF))
-               timeout += t->hbinterval;
-       timeout += jiffies;
-       return timeout;
+       /* RTO + timer slack +/- 50% of RTO */
+       unsigned long timeout = (trans->rto >> 1) + prandom_u32_max(trans->rto);
+
+       if (trans->state != SCTP_UNCONFIRMED &&
+           trans->state != SCTP_PF)
+               timeout += trans->hbinterval;
+
+       return timeout + jiffies;
 }
 
 /* Reset transport variables to their initial values */