Repository: trafficserver
Updated Branches:
  refs/heads/master a70e9473c -> 500b3c5e0


TS-4064: Customizable congestion control algorithms


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/038b189d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/038b189d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/038b189d

Branch: refs/heads/master
Commit: 038b189d62e8100a656e674e6ed4fd611ba32d6f
Parents: a70e947
Author: Brian Geffon <bri...@apache.org>
Authored: Tue Jan 5 02:37:04 2016 -0800
Committer: Brian Geffon <bri...@apache.org>
Committed: Tue Jan 5 03:02:28 2016 -0800

----------------------------------------------------------------------
 iocore/net/I_NetVConnection.h     |  3 +++
 iocore/net/P_UnixNetVConnection.h | 20 ++++++++++++++++++++
 mgmt/RecordsConfig.cc             |  4 ++++
 proxy/PluginVC.cc                 |  6 ++++++
 proxy/PluginVC.h                  |  2 ++
 proxy/http/HttpClientSession.cc   |  8 ++++++++
 proxy/http/HttpServerSession.cc   |  8 ++++++++
 7 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/038b189d/iocore/net/I_NetVConnection.h
----------------------------------------------------------------------
diff --git a/iocore/net/I_NetVConnection.h b/iocore/net/I_NetVConnection.h
index 79e2dac..0dcda03 100644
--- a/iocore/net/I_NetVConnection.h
+++ b/iocore/net/I_NetVConnection.h
@@ -518,6 +518,9 @@ public:
   /** Set the TCP initial congestion window */
   virtual int set_tcp_init_cwnd(int init_cwnd) = 0;
 
+  /** Set the TCP congestion control algorithm */
+  virtual int set_tcp_congestion_control(const char *name, int len) = 0;
+
   /** Set local sock addr struct. */
   virtual void set_local_addr() = 0;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/038b189d/iocore/net/P_UnixNetVConnection.h
----------------------------------------------------------------------
diff --git a/iocore/net/P_UnixNetVConnection.h 
b/iocore/net/P_UnixNetVConnection.h
index 968b0b9..5c20d13 100644
--- a/iocore/net/P_UnixNetVConnection.h
+++ b/iocore/net/P_UnixNetVConnection.h
@@ -291,6 +291,7 @@ public:
   virtual void set_local_addr();
   virtual void set_remote_addr();
   virtual int set_tcp_init_cwnd(int init_cwnd);
+  virtual int set_tcp_congestion_control(const char *name, int len);
   virtual void apply_options();
 
   friend void write_to_net_io(NetHandler *, UnixNetVConnection *, EThread *);
@@ -452,6 +453,25 @@ UnixNetVConnection::set_tcp_init_cwnd(int init_cwnd)
 #endif
 }
 
+TS_INLINE int
+UnixNetVConnection::set_tcp_congestion_control(const char *name, int len)
+{
+#ifdef TCP_CONGESTION
+  int rv = 0;
+  rv = setsockopt(con.fd, IPPROTO_TCP, TCP_CONGESTION, reinterpret_cast<void 
*>(const_cast<char *>(name)), len);
+  if (rv < 0) {
+    Error("Unable to set TCP congestion control on socket %d to \"%.*s\", 
errno=%d (%s)", con.fd, len, name, errno,
+          strerror(errno));
+  } else {
+    Debug("socket", "Setting TCP congestion control on socket [%d] to \"%.*s\" 
-> %d", con.fd, len, name, rv);
+  }
+  return rv;
+#else
+  Debug("socket", "Setting TCP congestion control %.*s is not supported on 
this platform.", len, name);
+  return -1;
+#endif
+}
+
 TS_INLINE UnixNetVConnection::~UnixNetVConnection()
 {
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/038b189d/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 34e180d..05d87f8 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -855,6 +855,10 @@ static const RecordElement RecordsConfig[] =
   ,
   {RECT_CONFIG, "proxy.config.net.sock_option_tfo_queue_size_in", RECD_INT, 
"10000", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}
   ,
+  {RECT_CONFIG, "proxy.config.net.tcp_congestion_control_in", RECD_STRING, "", 
RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+  ,
+  {RECT_CONFIG, "proxy.config.net.tcp_congestion_control_out", RECD_STRING, 
"", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+  ,
 
   
//##############################################################################
   //#

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/038b189d/proxy/PluginVC.cc
----------------------------------------------------------------------
diff --git a/proxy/PluginVC.cc b/proxy/PluginVC.cc
index 25efaf9..b0a5e92 100644
--- a/proxy/PluginVC.cc
+++ b/proxy/PluginVC.cc
@@ -907,6 +907,12 @@ PluginVC::set_tcp_init_cwnd(int /* init_cwnd ATS_UNUSED */)
   return -1;
 }
 
+int
+PluginVC::set_tcp_congestion_control(const char *ATS_UNUSED, int ATS_UNUSED)
+{
+  return -1;
+}
+
 void
 PluginVC::apply_options()
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/038b189d/proxy/PluginVC.h
----------------------------------------------------------------------
diff --git a/proxy/PluginVC.h b/proxy/PluginVC.h
index b495a1d..cf0d4d9 100644
--- a/proxy/PluginVC.h
+++ b/proxy/PluginVC.h
@@ -104,6 +104,8 @@ public:
   virtual void set_local_addr();
   virtual void set_remote_addr();
   virtual int set_tcp_init_cwnd(int init_cwnd);
+  virtual int set_tcp_congestion_control(const char *name, int len);
+
   virtual void apply_options();
 
   virtual bool get_data(int id, void *data);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/038b189d/proxy/http/HttpClientSession.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpClientSession.cc b/proxy/http/HttpClientSession.cc
index 4e89546..367b0fe 100644
--- a/proxy/http/HttpClientSession.cc
+++ b/proxy/http/HttpClientSession.cc
@@ -200,6 +200,14 @@ HttpClientSession::new_connection(NetVConnection *new_vc, 
MIOBuffer *iobuf, IOBu
 
   DebugHttpSsn("[%" PRId64 "] session born, netvc %p", con_id, new_vc);
 
+  RecString congestion_control_in;
+  if (REC_ReadConfigStringAlloc(congestion_control_in, 
"proxy.config.net.tcp_congestion_control_in") == REC_ERR_OKAY) {
+    int len = strlen(congestion_control_in);
+    if (len > 0) {
+      client_vc->set_tcp_congestion_control(congestion_control_in, len);
+    }
+    ats_free(congestion_control_in);
+  }
   if (!iobuf) {
     SSLNetVConnection *ssl_vc = dynamic_cast<SSLNetVConnection *>(new_vc);
     if (ssl_vc) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/038b189d/proxy/http/HttpServerSession.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpServerSession.cc b/proxy/http/HttpServerSession.cc
index 1e5405f..7a0db7b 100644
--- a/proxy/http/HttpServerSession.cc
+++ b/proxy/http/HttpServerSession.cc
@@ -90,6 +90,14 @@ HttpServerSession::new_connection(NetVConnection *new_vc)
   buf_reader = read_buffer->alloc_reader();
   Debug("http_ss", "[%" PRId64 "] session born, netvc %p", con_id, new_vc);
   state = HSS_INIT;
+  RecString congestion_control_out;
+  if (REC_ReadConfigStringAlloc(congestion_control_out, 
"proxy.config.net.tcp_congestion_control_out") == REC_ERR_OKAY) {
+    int len = strlen(congestion_control_out);
+    if (len > 0) {
+      new_vc->set_tcp_congestion_control(congestion_control_out, len);
+    }
+    ats_free(congestion_control_out);
+  }
 }
 
 VIO *

Reply via email to