trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [trafficserver] 03/03: TS-4882: Add TCP Fast Open metrics.
Date Mon, 26 Sep 2016 20:47:22 GMT
This is an automated email from the ASF dual-hosted git repository.

jpeach pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit 221ecb6ab272423bcd731e6b52d033f22558dff6
Author: James Peach <jpeach@apache.org>
AuthorDate: Wed Sep 21 13:46:35 2016 -0700

    TS-4882: Add TCP Fast Open metrics.
---
 iocore/net/BIO_fastopen.cc          | 10 ++++++++--
 iocore/net/Net.cc                   |  2 ++
 iocore/net/P_Net.h                  |  2 ++
 iocore/net/UnixConnection.cc        |  4 ++++
 iocore/net/UnixNetVConnection.cc    |  4 ++++
 proxy/config/metrics.config.default |  5 +++++
 6 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/iocore/net/BIO_fastopen.cc b/iocore/net/BIO_fastopen.cc
index d7c7d15..55be47c 100644
--- a/iocore/net/BIO_fastopen.cc
+++ b/iocore/net/BIO_fastopen.cc
@@ -21,7 +21,7 @@
  *  limitations under the License.
  */
 
-#include "I_Net.h"
+#include "P_Net.h"
 #include "I_SocketManager.h"
 #include "ts/ink_assert.h"
 
@@ -64,10 +64,16 @@ fastopen_bwrite(BIO *bio, const char *in, int insz)
     // On the first write only, make a TFO request if TFO is enabled.
     // The best documentation on the behavior of the Linux API is in
     // RFC 7413. If we get EINPROGRESS it means that the SYN has been
-    // sent without data dn we sshould retry.
+    // sent without data and we should retry.
     const sockaddr *dst = reinterpret_cast<const sockaddr *>(bio->ptr);
+    ProxyMutex *mutex   = this_ethread()->mutex.get();
+
+    NET_INCREMENT_DYN_STAT(net_fastopen_attempts_stat);
 
     err = socketManager.sendto(bio->num, (void *)in, insz, MSG_FASTOPEN, dst, ats_ip_size(dst));
+    if (err < 0) {
+      NET_INCREMENT_DYN_STAT(net_fastopen_failures_stat);
+    }
 
     bio->ptr = NULL;
   } else {
diff --git a/iocore/net/Net.cc b/iocore/net/Net.cc
index 10427be..46d0739 100644
--- a/iocore/net/Net.cc
+++ b/iocore/net/Net.cc
@@ -70,6 +70,8 @@ register_net_stats()
     {"proxy.process.net.net_handler_run", net_handler_run_stat},
     {"proxy.process.net.read_bytes", net_read_bytes_stat},
     {"proxy.process.net.write_bytes", net_write_bytes_stat},
+    {"proxy.process.net.fastopen_out.attempts", net_fastopen_attempts_stat},
+    {"proxy.process.net.fastopen_out.failures", net_fastopen_failures_stat},
     {"proxy.process.socks.connections_successful", socks_connections_successful_stat},
     {"proxy.process.socks.connections_unsuccessful", socks_connections_unsuccessful_stat},
   };
diff --git a/iocore/net/P_Net.h b/iocore/net/P_Net.h
index f8ffe59..a807b06 100644
--- a/iocore/net/P_Net.h
+++ b/iocore/net/P_Net.h
@@ -53,6 +53,8 @@ enum Net_Stats {
   keep_alive_queue_timeout_total_stat,
   keep_alive_queue_timeout_count_stat,
   default_inactivity_timeout_stat,
+  net_fastopen_attempts_stat,
+  net_fastopen_failures_stat,
   Net_Stat_Count
 };
 
diff --git a/iocore/net/UnixConnection.cc b/iocore/net/UnixConnection.cc
index 00fb4e6..78860e8 100644
--- a/iocore/net/UnixConnection.cc
+++ b/iocore/net/UnixConnection.cc
@@ -325,6 +325,10 @@ Connection::connect(sockaddr const *target, NetVCOptions const &opt)
   cleaner<Connection> cleanup(this, &Connection::_cleanup); // mark for close until
we succeed.
 
   if (opt.f_tcp_fastopen && !opt.f_blocking_connect) {
+    ProxyMutex *mutex = this_ethread()->mutex.get();
+
+    NET_INCREMENT_DYN_STAT(net_fastopen_attempts_stat);
+
     // TCP Fast Open is (effectively) a non-blocking connect, so set the
     // return value we would see in that case.
     errno = EINPROGRESS;
diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc
index 4a499de..96302b9 100644
--- a/iocore/net/UnixNetVConnection.cc
+++ b/iocore/net/UnixNetVConnection.cc
@@ -1006,6 +1006,10 @@ UnixNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor
&bu
       msg.msg_iovlen  = niov;
 
       r = socketManager.sendmsg(con.fd, &msg, MSG_FASTOPEN);
+      if (r < 0) {
+        NET_INCREMENT_DYN_STAT(net_fastopen_failures_stat);
+      }
+
     } else {
       r = socketManager.writev(con.fd, &tiovec[0], niov);
     }
diff --git a/proxy/config/metrics.config.default b/proxy/config/metrics.config.default
index 74623f1..a02e2fa 100644
--- a/proxy/config/metrics.config.default
+++ b/proxy/config/metrics.config.default
@@ -1563,3 +1563,8 @@ integer 'proxy.cluster.log.bytes_received_from_network_avg_10s' [[
 counter 'proxy.process.ssl.total_success_handshake_count' [[
   return proxy.process.ssl.total_success_handshake_count_in
 ]]
+
+counter 'proxy.process.net.fastopen_out.success' [[
+  return proxy.process.net.fastopen_out.attempts -
+    proxy.process.net.fastopen_out.failures
+]]

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>.

Mime
View raw message