diff --git a/iocore/net/I_Net.h b/iocore/net/I_Net.h
index e4e82a6459..81ed6c3edb 100644
--- a/iocore/net/I_Net.h
+++ b/iocore/net/I_Net.h
@@ -61,6 +61,9 @@ extern int net_accept_period;
 extern int net_retry_delay;
 extern int net_throttle_delay;
 
+extern std::string_view net_ccp_in;
+extern std::string_view net_ccp_out;
+
 #define NET_EVENT_OPEN (NET_EVENT_EVENTS_START)
 #define NET_EVENT_OPEN_FAILED (NET_EVENT_EVENTS_START + 1)
 #define NET_EVENT_ACCEPT (NET_EVENT_EVENTS_START + 2)
diff --git a/iocore/net/Net.cc b/iocore/net/Net.cc
index af1d1f75bc..a2c5f5f03a 100644
--- a/iocore/net/Net.cc
+++ b/iocore/net/Net.cc
@@ -40,6 +40,10 @@ int net_accept_period       = 10;
 int net_retry_delay         = 10;
 int net_throttle_delay      = 50; /* milliseconds */
 
+// For the in/out congestion control: ToDo: this probably would be better as 
ports: specifications
+std::string_view net_ccp_in;
+std::string_view net_ccp_out;
+
 static inline void
 configure_net()
 {
@@ -52,6 +56,20 @@ configure_net()
   // These are not reloadable
   REC_ReadConfigInteger(net_event_period, "proxy.config.net.event_period");
   REC_ReadConfigInteger(net_accept_period, "proxy.config.net.accept_period");
+
+  // This is kinda fugly, but better than it was before (on every connection 
in and out)
+  // Note that these would need to be ats_free()'d if we ever want to clean 
that up, but
+  // we have no good way of dealing with that on such globals I think?
+  RecString ccp;
+
+  REC_ReadConfigStringAlloc(ccp, "proxy.config.net.tcp_congestion_control_in");
+  if (ccp && *ccp != '\0') {
+    net_ccp_in = {ccp};
+  }
+  REC_ReadConfigStringAlloc(ccp, 
"proxy.config.net.tcp_congestion_control_out");
+  if (ccp && *ccp != '\0') {
+    net_ccp_out = {ccp};
+  }
 }
 
 static inline void
diff --git a/iocore/net/P_UnixNetVConnection.h 
b/iocore/net/P_UnixNetVConnection.h
index 94c141801b..ba5709171a 100644
--- a/iocore/net/P_UnixNetVConnection.h
+++ b/iocore/net/P_UnixNetVConnection.h
@@ -398,41 +398,6 @@ UnixNetVConnection::set_tcp_init_cwnd(int init_cwnd)
 #endif
 }
 
-inline int
-UnixNetVConnection::set_tcp_congestion_control(int side)
-{
-#ifdef TCP_CONGESTION
-  RecString congestion_control;
-  int ret;
-
-  if (side == CLIENT_SIDE) {
-    ret = REC_ReadConfigStringAlloc(congestion_control, 
"proxy.config.net.tcp_congestion_control_in");
-  } else {
-    ret = REC_ReadConfigStringAlloc(congestion_control, 
"proxy.config.net.tcp_congestion_control_out");
-  }
-
-  if (ret == REC_ERR_OKAY) {
-    int len = strlen(congestion_control);
-    if (len > 0) {
-      int rv = 0;
-      rv     = setsockopt(con.fd, IPPROTO_TCP, TCP_CONGESTION, 
reinterpret_cast<void *>(congestion_control), len);
-      if (rv < 0) {
-        Error("Unable to set TCP congestion control on socket %d to \"%.*s\", 
errno=%d (%s)", con.fd, len, congestion_control,
-              errno, strerror(errno));
-      } else {
-        Debug("socket", "Setting TCP congestion control on socket [%d] to 
\"%.*s\" -> %d", con.fd, len, congestion_control, rv);
-      }
-    }
-    ats_free(congestion_control);
-    return 0;
-  }
-  return -1;
-#else
-  Debug("socket", "Setting TCP congestion control is not supported on this 
platform.");
-  return -1;
-#endif
-}
-
 inline UnixNetVConnection::~UnixNetVConnection() {}
 
 inline SOCKET
diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc
index 635c98f5e9..f005f3d994 100644
--- a/iocore/net/UnixNetVConnection.cc
+++ b/iocore/net/UnixNetVConnection.cc
@@ -1524,3 +1524,33 @@ UnixNetVConnection::protocol_contains(std::string_view 
tag) const
   }
   return retval.data();
 }
+
+int
+UnixNetVConnection::set_tcp_congestion_control(int side)
+{
+#ifdef TCP_CONGESTION
+  std::string_view ccp;
+
+  if (side == CLIENT_SIDE) {
+    ccp = net_ccp_in;
+  } else {
+    ccp = net_ccp_out;
+  }
+
+  if (!ccp.empty()) {
+    int rv = setsockopt(con.fd, IPPROTO_TCP, TCP_CONGESTION, 
reinterpret_cast<const void *>(ccp.data()), ccp.length());
+
+    if (rv < 0) {
+      Error("Unable to set TCP congestion control on socket %d to \"%s\", 
errno=%d (%s)", con.fd, ccp.data(), errno,
+            strerror(errno));
+    } else {
+      Debug("socket", "Setting TCP congestion control on socket [%d] to \"%s\" 
-> %d", con.fd, ccp.data(), rv);
+    }
+    return 0;
+  }
+  return -1;
+#else
+  Debug("socket", "Setting TCP congestion control is not supported on this 
platform.");
+  return -1;
+#endif
+}
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index d4a212262a..896f171f3d 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -793,9 +793,9 @@ static const RecordElement RecordsConfig[] =
   ,
   {RECT_CONFIG, "proxy.config.net.sock_option_tfo_queue_size_in", RECD_INT, 
"10000", RECU_NULL, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.net.tcp_congestion_control_in", RECD_STRING, "", 
RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
+  {RECT_CONFIG, "proxy.config.net.tcp_congestion_control_in", RECD_STRING, "", 
RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.net.tcp_congestion_control_out", RECD_STRING, 
"", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
+  {RECT_CONFIG, "proxy.config.net.tcp_congestion_control_out", RECD_STRING, 
"", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
   ,
 
   
//##############################################################################


With regards,
Apache Git Services

Reply via email to