Author: hiren
Date: Tue Nov  1 21:08:37 2016
New Revision: 308180
URL: https://svnweb.freebsd.org/changeset/base/308180

Log:
  Set slow start threshold more accurately on loss to be flightsize/2 instead of
  cwnd/2 as recommended by RFC5681. (spotted by mmacy at nextbsd dot org)
  
  Restore pre-r307901 behavior of aligning ssthresh/cwnd on mss boundary. 
(spotted
  by slawa at zxy dot spb dot ru)
  
  Tested by:        dim, Slawa <slawa at zxy dot spb dot ru>
  MFC after:        1 month
  X-MFC with:       r307901
  Sponsored by:     Limelight Networks
  Differential Revision:        https://reviews.freebsd.org/D8349

Modified:
  head/sys/netinet/cc/cc_cdg.c
  head/sys/netinet/cc/cc_chd.c
  head/sys/netinet/cc/cc_dctcp.c
  head/sys/netinet/cc/cc_htcp.c
  head/sys/netinet/cc/cc_newreno.c
  head/sys/netinet/tcp_input.c

Modified: head/sys/netinet/cc/cc_cdg.c
==============================================================================
--- head/sys/netinet/cc/cc_cdg.c        Tue Nov  1 19:18:54 2016        
(r308179)
+++ head/sys/netinet/cc/cc_cdg.c        Tue Nov  1 21:08:37 2016        
(r308180)
@@ -474,7 +474,9 @@ cdg_cong_signal(struct cc_var *ccv, uint
                ENTER_RECOVERY(CCV(ccv, t_flags));
                break;
        case CC_RTO:
-               CCV(ccv, snd_ssthresh) = max(2*mss, cwin/2);
+               CCV(ccv, snd_ssthresh) =
+                   max((CCV(ccv, snd_max) - CCV(ccv, snd_una)) / 2 / mss, 2)
+                       * mss;
                CCV(ccv, snd_cwnd) = mss;
                break;
        default:

Modified: head/sys/netinet/cc/cc_chd.c
==============================================================================
--- head/sys/netinet/cc/cc_chd.c        Tue Nov  1 19:18:54 2016        
(r308179)
+++ head/sys/netinet/cc/cc_chd.c        Tue Nov  1 21:08:37 2016        
(r308180)
@@ -330,13 +330,11 @@ chd_cong_signal(struct cc_var *ccv, uint
        struct ertt *e_t;
        struct chd *chd_data;
        int qdly;
-       uint32_t cwin;
        u_int mss;
 
        e_t = khelp_get_osd(CCV(ccv, osd), ertt_id);
        chd_data = ccv->cc_data;
        qdly = imax(e_t->rtt, chd_data->maxrtt_in_rtt) - e_t->minrtt;
-       cwin = CCV(ccv, snd_cwnd);
        mss = CCV(ccv, t_maxseg);
 
        switch(signal_type) {
@@ -378,7 +376,9 @@ chd_cong_signal(struct cc_var *ccv, uint
                ENTER_FASTRECOVERY(CCV(ccv, t_flags));
                break;
        case CC_RTO:
-               CCV(ccv, snd_ssthresh) = max(2*mss, cwin/2);
+               CCV(ccv, snd_ssthresh) =
+                   max((CCV(ccv, snd_max) - CCV(ccv, snd_una)) / 2 / mss, 2)
+                       * mss;
                CCV(ccv, snd_cwnd) = mss;
                break;
 

Modified: head/sys/netinet/cc/cc_dctcp.c
==============================================================================
--- head/sys/netinet/cc/cc_dctcp.c      Tue Nov  1 19:18:54 2016        
(r308179)
+++ head/sys/netinet/cc/cc_dctcp.c      Tue Nov  1 21:08:37 2016        
(r308180)
@@ -230,19 +230,21 @@ static void
 dctcp_cong_signal(struct cc_var *ccv, uint32_t type)
 {
        struct dctcp *dctcp_data;
-       uint32_t cwin;
+       uint32_t cwin, ssthresh_on_loss;
        u_int mss;
 
        dctcp_data = ccv->cc_data;
        cwin = CCV(ccv, snd_cwnd);
        mss = CCV(ccv, t_maxseg);
+       ssthresh_on_loss =
+           max((CCV(ccv, snd_max) - CCV(ccv, snd_una)) / 2 / mss, 2)
+               * mss;
 
        switch (type) {
        case CC_NDUPACK:
                if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) {
                        if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
-                               CCV(ccv, snd_ssthresh) = mss *
-                                   max(cwin / 2 / mss, 2);
+                               CCV(ccv, snd_ssthresh) = ssthresh_on_loss;
                                dctcp_data->num_cong_events++;
                        } else {
                                /* cwnd has already updated as congestion
@@ -250,8 +252,7 @@ dctcp_cong_signal(struct cc_var *ccv, ui
                                 * snd_cwnd_prev and recalculate snd_ssthresh
                                 */
                                cwin = CCV(ccv, snd_cwnd_prev);
-                               CCV(ccv, snd_ssthresh) =
-                                   max(cwin / 2 / mss, 2) * mss;
+                               CCV(ccv, snd_ssthresh) = ssthresh_on_loss;
                        }
                        ENTER_RECOVERY(CCV(ccv, t_flags));
                }
@@ -265,8 +266,7 @@ dctcp_cong_signal(struct cc_var *ccv, ui
                if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
                        if (V_dctcp_slowstart &&
                            dctcp_data->num_cong_events++ == 0) {
-                               CCV(ccv, snd_ssthresh) =
-                                   mss * max(cwin / 2 / mss, 2);
+                               CCV(ccv, snd_ssthresh) = ssthresh_on_loss;
                                dctcp_data->alpha = MAX_ALPHA_VALUE;
                                dctcp_data->bytes_ecn = 0;
                                dctcp_data->bytes_total = 0;
@@ -285,7 +285,7 @@ dctcp_cong_signal(struct cc_var *ccv, ui
                        dctcp_update_alpha(ccv);
                        dctcp_data->save_sndnxt += CCV(ccv, t_maxseg);
                        dctcp_data->num_cong_events++;
-                       CCV(ccv, snd_ssthresh) = max(2 * mss, cwin / 2);
+                       CCV(ccv, snd_ssthresh) = ssthresh_on_loss;
                        CCV(ccv, snd_cwnd) = mss;
                }
                break;

Modified: head/sys/netinet/cc/cc_htcp.c
==============================================================================
--- head/sys/netinet/cc/cc_htcp.c       Tue Nov  1 19:18:54 2016        
(r308179)
+++ head/sys/netinet/cc/cc_htcp.c       Tue Nov  1 21:08:37 2016        
(r308180)
@@ -325,7 +325,9 @@ htcp_cong_signal(struct cc_var *ccv, uin
                 */
                if (CCV(ccv, t_rxtshift) >= 2)
                        htcp_data->t_last_cong = ticks;
-               CCV(ccv, snd_ssthresh) = max(2 * mss, cwin / 2);
+               CCV(ccv, snd_ssthresh) =
+                   max((CCV(ccv, snd_max) - CCV(ccv, snd_una)) / 2 / mss, 2)
+                       * mss;
                CCV(ccv, snd_cwnd) = mss;
                break;
        }
@@ -518,6 +520,10 @@ htcp_ssthresh_update(struct cc_var *ccv)
                CCV(ccv, snd_ssthresh) = ((u_long)CCV(ccv, snd_cwnd) *
                    htcp_data->beta) >> HTCP_SHIFT;
        }
+
+       /* Align ssthresh to MSS boundary */
+       CCV(ccv, snd_ssthresh) = (CCV(ccv, snd_ssthresh) / CCV(ccv, t_maxseg))
+           * CCV(ccv, t_maxseg);
 }
 
 

Modified: head/sys/netinet/cc/cc_newreno.c
==============================================================================
--- head/sys/netinet/cc/cc_newreno.c    Tue Nov  1 19:18:54 2016        
(r308179)
+++ head/sys/netinet/cc/cc_newreno.c    Tue Nov  1 21:08:37 2016        
(r308180)
@@ -182,23 +182,26 @@ newreno_after_idle(struct cc_var *ccv)
 static void
 newreno_cong_signal(struct cc_var *ccv, uint32_t type)
 {
-       uint32_t cwin;
+       uint32_t cwin, ssthresh_on_loss;
        u_int mss;
 
        cwin = CCV(ccv, snd_cwnd);
        mss = CCV(ccv, t_maxseg);
+       ssthresh_on_loss =
+           max((CCV(ccv, snd_max) - CCV(ccv, snd_una)) / 2 / mss, 2)
+               * mss;
 
        /* Catch algos which mistakenly leak private signal types. */
        KASSERT((type & CC_SIGPRIVMASK) == 0,
            ("%s: congestion signal type 0x%08x is private\n", __func__, type));
 
-       cwin = max(2*mss, cwin/2);
+       cwin = max(cwin / 2 / mss, 2) * mss;
 
        switch (type) {
        case CC_NDUPACK:
                if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) {
                        if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
-                               CCV(ccv, snd_ssthresh) = cwin;
+                               CCV(ccv, snd_ssthresh) = ssthresh_on_loss;
                                CCV(ccv, snd_cwnd) = cwin;
                        }
                        ENTER_RECOVERY(CCV(ccv, t_flags));
@@ -206,13 +209,13 @@ newreno_cong_signal(struct cc_var *ccv, 
                break;
        case CC_ECN:
                if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
-                       CCV(ccv, snd_ssthresh) = cwin;
+                       CCV(ccv, snd_ssthresh) = ssthresh_on_loss;
                        CCV(ccv, snd_cwnd) = cwin;
                        ENTER_CONGRECOVERY(CCV(ccv, t_flags));
                }
                break;
        case CC_RTO:
-               CCV(ccv, snd_ssthresh) = cwin;
+               CCV(ccv, snd_ssthresh) = ssthresh_on_loss;
                CCV(ccv, snd_cwnd) = mss;
                break;
        }

Modified: head/sys/netinet/tcp_input.c
==============================================================================
--- head/sys/netinet/tcp_input.c        Tue Nov  1 19:18:54 2016        
(r308179)
+++ head/sys/netinet/tcp_input.c        Tue Nov  1 21:08:37 2016        
(r308180)
@@ -444,7 +444,8 @@ cc_cong_signal(struct tcpcb *tp, struct 
                         * ssthresh = max (FlightSize / 2, 2*SMSS) eq (4)
                         */
                        tp->snd_ssthresh =
-                           max((tp->snd_max - tp->snd_una) / 2, 2 * maxseg);
+                           max((tp->snd_max - tp->snd_una) / 2 / maxseg, 2)
+                               * maxseg;
                        tp->snd_cwnd = maxseg;
                }
                break;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to