This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 8a8dfd2 Tries to use linux specific tcpinfo fields
8a8dfd2 is described below
commit 8a8dfd2aa0f4f0319cf87a370ed00ba4e48f1b2a
Author: Leif Hedstrom <[email protected]>
AuthorDate: Mon Apr 15 17:21:27 2019 -0600
Tries to use linux specific tcpinfo fields
---
configure.ac | 9 ++++++++-
doc/admin-guide/plugins/tcpinfo.en.rst | 13 +++++++++++++
include/tscore/ParseRules.h | 4 +++-
plugins/tcpinfo/tcpinfo.cc | 28 +++++++++++++++++++++++-----
4 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5a4f5d9..57b80cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1818,10 +1818,12 @@ AC_LINK_IFELSE([
])
# BSD-derived systems populate the socket length in the structure itself. It's
-# redundant to check all of these, but hey, I need the typing practice.
+# redundant to check all of these, but hey, I need the typing practice. Also,
we
+# check for the linux updated version of tcp.h, in linux/tcp.h
AC_CHECK_MEMBER([struct sockaddr.sa_len], [], [], [#include <netinet/in.h>])
AC_CHECK_MEMBER([struct sockaddr_in.sin_len], [], [], [#include
<netinet/in.h>])
AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len], [], [], [#include
<netinet/in.h>])
+AC_CHECK_MEMBER([struct tcp_info.tcpi_data_segs_out], [], [], [#include
<linux/tcp.h>])
if test "x${ac_cv_member_struct_sockaddr_sa_len}" = "xyes"; then
AC_DEFINE(HAVE_STRUCT_SOCKADDR_SA_LEN, 1,
@@ -1838,6 +1840,11 @@ if test "x${ac_cv_member_struct_sockaddr_in6_sin6_len}"
= "xyes"; then
[Whether struct sockaddr_in6 has the sin6_len member])
fi
+if test "x${ac_cv_member_struct_tcp_info_tcpi_data_segs_out}" = "xyes"; then
+ AC_DEFINE(HAVE_STRUCT_LINUX_TCP_INFO, 1,
+ [Whether struct tcp_info have the tcpi_data_segs_{in,out} member])
+fi
+
if test "x${with_profiler}" = "xyes"; then
AC_CHECK_HEADERS([google/profiler.h \
], [], [])
diff --git a/doc/admin-guide/plugins/tcpinfo.en.rst
b/doc/admin-guide/plugins/tcpinfo.en.rst
index f705548..28ca987 100644
--- a/doc/admin-guide/plugins/tcpinfo.en.rst
+++ b/doc/admin-guide/plugins/tcpinfo.en.rst
@@ -94,8 +94,21 @@ The following options may be specified in
:file:`plugin.config`:
lost
retrans
fackets
+ all_retrans
============== ==================================================
+ In addition, on newer Linux system, the following two fields are appended
+ in log level 2:
+ ============== ==================================================
+ Field Name Description
+ ============== ==================================================
+ data_segs_in Number of incoming data segments
+ data_segs_out Number of outgoing data segments
+
+ Note: Features such as TSO (TCP Segment Offload) might skew the numbers
+ here. That's true as well for e.g. the retransmit metrics, i.e. anything
+ that deals with segments.
+
--sample-rate=COUNT
This is the number of times per 1000 requests that the data will
be logged. A pseudo-random number generator is used to determine if a
diff --git a/include/tscore/ParseRules.h b/include/tscore/ParseRules.h
index 6564385..1eac23d 100644
--- a/include/tscore/ParseRules.h
+++ b/include/tscore/ParseRules.h
@@ -24,10 +24,12 @@
#pragma once
#include <cstring>
+// I had to move this here, because I really needed to avoid including
ink_platform.h in here,
+// because of a conflict on linux/tcp.h vs netinet/tcp.h.
+#include <limits.h> // NOLINT(modernize-deprecated-headers)
#include "tscore/ink_defs.h"
#include "tscore/ink_apidefs.h"
-#include "tscore/ink_platform.h"
typedef unsigned int CTypeResult;
diff --git a/plugins/tcpinfo/tcpinfo.cc b/plugins/tcpinfo/tcpinfo.cc
index e8e498e..5f0071e 100644
--- a/plugins/tcpinfo/tcpinfo.cc
+++ b/plugins/tcpinfo/tcpinfo.cc
@@ -21,13 +21,20 @@
limitations under the License.
*/
+#include "tscore/ink_config.h"
+
#include <cstdio>
#include <cstdlib>
#include <memory>
#include <ts/ts.h>
#include <unistd.h>
#include <netinet/in.h>
+// This is a bit of a hack, to get the more linux specific tcp_info struct ...
+#if HAVE_STRUCT_LINUX_TCP_INFO
+#include <linux/tcp.h>
+#elif HAVE_NETINET_IN_H
#include <netinet/tcp.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <getopt.h>
@@ -38,7 +45,6 @@
#include <sys/time.h>
#include <arpa/inet.h>
-#include "tscore/ink_defs.h"
#include "tscore/ParseRules.h"
#if defined(TCP_INFO) && defined(HAVE_STRUCT_TCP_INFO)
@@ -54,10 +60,13 @@
// Log format headers. These are emitted once at the start of a log file. Note
that we
// carefully order the fields so the field ordering is compatible. This lets
you change
// the verbosity without breaking a parser that is moderately robust.
-static const char *tcpi_headers[] = {
- "timestamp event client server rtt",
- "timestamp event client server rtt rttvar last_sent last_recv "
- "snd_cwnd snd_ssthresh rcv_ssthresh unacked sacked lost retrans fackets
all_retrans",
+static const char *tcpi_headers[] = {"timestamp event client server rtt",
+ "timestamp event client server rtt rttvar
last_sent last_recv snd_cwnd "
+ "snd_ssthresh rcv_ssthresh unacked sacked
lost retrans fackets all_retrans"
+// Additional information from linux's linux/tcp.h appended here
+#if HAVE_STRUCT_LINUX_TCP_INFO
+ " data_segs_in data_segs_out"
+#endif
};
struct Config {
@@ -137,11 +146,20 @@ log_tcp_info(Config *config, const char *event_name,
TSHttpSsn ssnp)
if (config->log_level == 2) {
#if !defined(freebsd) || defined(__GLIBC__)
+#if HAVE_STRUCT_LINUX_TCP_INFO
+ ret = TSTextLogObjectWrite(config->log, "%s %s %s %u %u %u %u %u %u %u %u
%u %u %u %u %u %u %u", event_name, client_str,
+ server_str, info.tcpi_rtt, info.tcpi_rttvar,
info.tcpi_last_data_sent, info.tcpi_last_data_recv,
+ info.tcpi_snd_cwnd, info.tcpi_snd_ssthresh,
info.tcpi_rcv_ssthresh, info.tcpi_unacked,
+ info.tcpi_sacked, info.tcpi_lost,
info.tcpi_retrans, info.tcpi_fackets, info.tcpi_total_retrans,
+ info.tcpi_data_segs_in,
info.tcpi_data_segs_out);
+#else
ret = TSTextLogObjectWrite(config->log, "%s %s %s %u %u %u %u %u %u %u %u
%u %u %u %u %u", event_name, client_str, server_str,
info.tcpi_rtt, info.tcpi_rttvar,
info.tcpi_last_data_sent, info.tcpi_last_data_recv,
info.tcpi_snd_cwnd, info.tcpi_snd_ssthresh,
info.tcpi_rcv_ssthresh, info.tcpi_unacked,
info.tcpi_sacked, info.tcpi_lost,
info.tcpi_retrans, info.tcpi_fackets, info.tcpi_total_retrans);
+#endif
#else
+ // E.g. FreeBSD and macOS
ret = TSTextLogObjectWrite(config->log, "%s %s %s %u %u %u %u %u %u %u %u
%u %u %u %u %u", event_name, client_str, server_str,
info.tcpi_rtt, info.tcpi_rttvar,
info.__tcpi_last_data_sent, info.tcpi_last_data_recv,
info.tcpi_snd_cwnd, info.tcpi_snd_ssthresh,
info.__tcpi_rcv_ssthresh, info.__tcpi_unacked,