Author: tuexen
Date: Fri Sep 17 18:53:07 2010
New Revision: 212800
URL: http://svn.freebsd.org/changeset/base/212800

Log:
  Make the initial congestion window configurable via sysctl.
  
  MFC after: 2 weeks.

Modified:
  head/sys/netinet/sctp_cc_functions.c
  head/sys/netinet/sctp_sysctl.c
  head/sys/netinet/sctp_sysctl.h

Modified: head/sys/netinet/sctp_cc_functions.c
==============================================================================
--- head/sys/netinet/sctp_cc_functions.c        Fri Sep 17 16:20:29 2010        
(r212799)
+++ head/sys/netinet/sctp_cc_functions.c        Fri Sep 17 18:53:07 2010        
(r212800)
@@ -44,18 +44,27 @@
 #include <netinet/sctp_cc_functions.h>
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
+
 void
 sctp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net)
 {
+       struct sctp_association *assoc;
+       uint32_t cwnd_in_mtu;
+
+       assoc = &stcb->asoc;
        /*
-        * We take the max of the burst limit times a MTU or the
-        * INITIAL_CWND. We then limit this to 4 MTU's of sending. cwnd must
-        * be at least 2 MTU.
+        * We take the minimum of the burst limit and the initial congestion
+        * window. The initial congestion window is at least two times the
+        * MTU.
         */
-       net->cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND));
-       net->ssthresh = stcb->asoc.peers_rwnd;
+       cwnd_in_mtu = SCTP_BASE_SYSCTL(sctp_initial_cwnd);
+       if ((assoc->max_burst > 0) && (cwnd_in_mtu > assoc->max_burst))
+               cwnd_in_mtu = assoc->max_burst;
+       net->cwnd = (net->mtu - sizeof(struct sctphdr)) * cwnd_in_mtu;
+       net->ssthresh = assoc->peers_rwnd;
 
-       if (SCTP_BASE_SYSCTL(sctp_logging_level) & (SCTP_CWND_MONITOR_ENABLE | 
SCTP_CWND_LOGGING_ENABLE)) {
+       if (SCTP_BASE_SYSCTL(sctp_logging_level) &
+           (SCTP_CWND_MONITOR_ENABLE | SCTP_CWND_LOGGING_ENABLE)) {
                sctp_log_cwnd(stcb, net, 0, SCTP_CWND_INITIALIZATION);
        }
 }

Modified: head/sys/netinet/sctp_sysctl.c
==============================================================================
--- head/sys/netinet/sctp_sysctl.c      Fri Sep 17 16:20:29 2010        
(r212799)
+++ head/sys/netinet/sctp_sysctl.c      Fri Sep 17 18:53:07 2010        
(r212800)
@@ -110,6 +110,7 @@ sctp_init_sysctls()
        SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff) = 
SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT;
        SCTP_BASE_SYSCTL(sctp_vtag_time_wait) = SCTPCTL_TIME_WAIT_DEFAULT;
        SCTP_BASE_SYSCTL(sctp_buffer_splitting) = 
SCTPCTL_BUFFER_SPLITTING_DEFAULT;
+       SCTP_BASE_SYSCTL(sctp_initial_cwnd) = SCTPCTL_INITIAL_CWND_DEFAULT;
 #if defined(SCTP_LOCAL_TRACE_BUF)
        memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
 #endif
@@ -622,6 +623,7 @@ sysctl_sctp_check(SYSCTL_HANDLER_ARGS)
                RANGECHK(SCTP_BASE_SYSCTL(sctp_default_frag_interleave), 
SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MIN, SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MAX);
                RANGECHK(SCTP_BASE_SYSCTL(sctp_vtag_time_wait), 
SCTPCTL_TIME_WAIT_MIN, SCTPCTL_TIME_WAIT_MAX);
                RANGECHK(SCTP_BASE_SYSCTL(sctp_buffer_splitting), 
SCTPCTL_BUFFER_SPLITTING_MIN, SCTPCTL_BUFFER_SPLITTING_MAX);
+               RANGECHK(SCTP_BASE_SYSCTL(sctp_initial_cwnd), 
SCTPCTL_INITIAL_CWND_MIN, SCTPCTL_INITIAL_CWND_MAX);
                RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_base), 
SCTPCTL_MOBILITY_BASE_MIN, SCTPCTL_MOBILITY_BASE_MAX);
                RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), 
SCTPCTL_MOBILITY_FASTHANDOFF_MIN, SCTPCTL_MOBILITY_FASTHANDOFF_MAX);
                
RANGECHK(SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable), 
SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_MIN, 
SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_MAX);
@@ -1072,6 +1074,10 @@ SYSCTL_PROC(_net_inet_sctp, OID_AUTO, bu
     &SCTP_BASE_SYSCTL(sctp_buffer_splitting), 0, sysctl_sctp_check, "IU",
     SCTPCTL_BUFFER_SPLITTING_DESC);
 
+SYSCTL_PROC(_net_inet_sctp, OID_AUTO, initial_cwnd, CTLTYPE_INT | CTLFLAG_RW,
+    &SCTP_BASE_SYSCTL(sctp_initial_cwnd), 0, sysctl_sctp_check, "IU",
+    SCTPCTL_INITIAL_CWND_DESC);
+
 #ifdef SCTP_DEBUG
 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, debug, CTLTYPE_INT | CTLFLAG_RW,
     &SCTP_BASE_SYSCTL(sctp_debug_on), 0, sysctl_sctp_check, "IU",

Modified: head/sys/netinet/sctp_sysctl.h
==============================================================================
--- head/sys/netinet/sctp_sysctl.h      Fri Sep 17 16:20:29 2010        
(r212799)
+++ head/sys/netinet/sctp_sysctl.h      Fri Sep 17 18:53:07 2010        
(r212800)
@@ -108,6 +108,7 @@ struct sctp_sysctl {
        uint32_t sctp_enable_sack_immediately;
        uint32_t sctp_vtag_time_wait;
        uint32_t sctp_buffer_splitting;
+       uint32_t sctp_initial_cwnd;
 #if defined(SCTP_DEBUG)
        uint32_t sctp_debug_on;
 #endif
@@ -497,6 +498,12 @@ struct sctp_sysctl {
 #define SCTPCTL_BUFFER_SPLITTING_MAX           0x3
 #define SCTPCTL_BUFFER_SPLITTING_DEFAULT       SCTPCTL_BUFFER_SPLITTING_MIN
 
+/* Initial congestion window in MTU */
+#define SCTPCTL_INITIAL_CWND_DESC      "Initial congestion window in MTU"
+#define SCTPCTL_INITIAL_CWND_MIN       2
+#define SCTPCTL_INITIAL_CWND_MAX       0xffffffff
+#define SCTPCTL_INITIAL_CWND_DEFAULT   3
+
 #if defined(SCTP_DEBUG)
 /* debug: Configure debug output */
 #define SCTPCTL_DEBUG_DESC     "Configure debug output"
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to