You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2018/07/23 19:49:32 UTC

[trafficserver] branch 7.1.x updated: Adds new logging tags: nhi and nhp

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/7.1.x by this push:
     new fbaf0db  Adds new logging tags: nhi and nhp
fbaf0db is described below

commit fbaf0db022d932ef3749bd8d5a55ea1537dc4f64
Author: Randall Meyer <ra...@yahoo.com>
AuthorDate: Mon Jul 23 10:59:02 2018 -0700

    Adds new logging tags: nhi and nhp
    
    next-hop-ip (nhi) is the IP of the next hop
    next-hop-port (nhp) is the port of the next hop
    
    Uses the original logic that pqsi used for marshalling
    (pre 01201739e252f84e7c8a7c62c0ee31feb0def616)
    
    (cherry picked from commit 74f03c78b24a524750080c53d6a6fa3c9b262a4b)
---
 doc/admin-guide/logging/formatting.en.rst |  4 ++++
 proxy/logging/Log.cc                      |  8 ++++++++
 proxy/logging/LogAccess.cc                | 13 +++++++++++++
 proxy/logging/LogAccess.h                 |  2 ++
 proxy/logging/LogAccessHttp.cc            | 16 ++++++++++++++++
 proxy/logging/LogAccessHttp.h             |  2 ++
 6 files changed, 45 insertions(+)

diff --git a/doc/admin-guide/logging/formatting.en.rst b/doc/admin-guide/logging/formatting.en.rst
index bbb3150..1bd034f 100644
--- a/doc/admin-guide/logging/formatting.en.rst
+++ b/doc/admin-guide/logging/formatting.en.rst
@@ -423,6 +423,8 @@ Network Addresses, Ports, and Interfaces
 .. _pqsn:
 .. _shi:
 .. _shn:
+.. _nhi:
+.. _nhp:
 
 The following log fields are used to log details of the network (IP) addresses,
 incoming/outgoing ports, and network interfaces used during transactions.
@@ -449,6 +451,8 @@ shi   Origin Server  IP address resolved via DNS by |TS| for the origin server.
                      |TS| for the connection will be reported. See note below
                      regarding misleading values from cached documents.
 shn   Origin Server  Host name of the origin server.
+nhi   Origin Server  Destination IP address of next hop
+nhp   Origin Server  Destination port of next hop
 ===== ============== ==========================================================
 
 .. note::
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 9e06443..1d66548 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -657,6 +657,14 @@ Log::init_fields()
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "pqsp", field);
 
+  field = new LogField("next_hop_ip", "nhi", LogField::IP, &LogAccess::marshal_next_hop_ip, &LogAccess::unmarshal_ip_to_str);
+  global_field_list.add(field, false);
+  ink_hash_table_insert(field_symbol_hash, "nhi", field);
+
+  field = new LogField("next_hop_port", "nhp", LogField::IP, &LogAccess::marshal_next_hop_port, &LogAccess::unmarshal_int_to_str);
+  global_field_list.add(field, false);
+  ink_hash_table_insert(field_symbol_hash, "nhp", field);
+
   Ptr<LogFieldAliasTable> hierarchy_map = make_ptr(new LogFieldAliasTable);
   hierarchy_map->init(
     36, SQUID_HIER_EMPTY, "EMPTY", SQUID_HIER_NONE, "NONE", SQUID_HIER_DIRECT, "DIRECT", SQUID_HIER_SIBLING_HIT, "SIBLING_HIT",
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index 144d82a..8c6174c 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -290,6 +290,19 @@ LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_req_server_port, DEFAULT_INT_FIELD)
 
 LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_hierarchy_route, DEFAULT_INT_FIELD)
 
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+
+LOG_ACCESS_DEFAULT_FIELD(marshal_next_hop_ip, DEFAULT_IP_FIELD)
+
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+
+LOG_ACCESS_DEFAULT_FIELD(marshal_next_hop_port, DEFAULT_INT_FIELD)
+
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+
 LOG_ACCESS_DEFAULT_FIELD(marshal_client_retry_after_time, DEFAULT_INT_FIELD)
 
 /*-------------------------------------------------------------------------
diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
index 0d410e3..2bc40c3 100644
--- a/proxy/logging/LogAccess.h
+++ b/proxy/logging/LogAccess.h
@@ -219,6 +219,8 @@ public:
   inkcoreapi virtual int marshal_proxy_req_server_ip(char *);   // INT
   inkcoreapi virtual int marshal_proxy_req_server_port(char *); // INT
   inkcoreapi virtual int marshal_proxy_hierarchy_route(char *); // INT
+  inkcoreapi virtual int marshal_next_hop_ip(char *);           // STR
+  inkcoreapi virtual int marshal_next_hop_port(char *);         // INT
   inkcoreapi virtual int marshal_proxy_host_name(char *);       // STR
   inkcoreapi virtual int marshal_proxy_host_ip(char *);         // STR
   inkcoreapi virtual int marshal_proxy_req_is_ssl(char *);      // INT
diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc
index ccf097b..8d9b277 100644
--- a/proxy/logging/LogAccessHttp.cc
+++ b/proxy/logging/LogAccessHttp.cc
@@ -1071,6 +1071,22 @@ LogAccessHttp::marshal_proxy_req_server_port(char *buf)
   return INK_MIN_ALIGN;
 }
 
+int
+LogAccessHttp::marshal_next_hop_ip(char *buf)
+{
+  return marshal_ip(buf, m_http_sm->t_state.current.server != nullptr ? &m_http_sm->t_state.current.server->dst_addr.sa : nullptr);
+}
+
+int
+LogAccessHttp::marshal_next_hop_port(char *buf)
+{
+  if (buf) {
+    uint16_t port = ntohs(m_http_sm->t_state.current.server != nullptr ? m_http_sm->t_state.current.server->dst_addr.port() : 0);
+    marshal_int(buf, port);
+  }
+  return INK_MIN_ALIGN;
+}
+
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
diff --git a/proxy/logging/LogAccessHttp.h b/proxy/logging/LogAccessHttp.h
index ef679b9..bd353cd 100644
--- a/proxy/logging/LogAccessHttp.h
+++ b/proxy/logging/LogAccessHttp.h
@@ -107,6 +107,8 @@ public:
   int marshal_proxy_hierarchy_route(char *) override; // INT
   int marshal_proxy_host_port(char *) override;       // INT
   int marshal_proxy_req_is_ssl(char *) override;      // INT
+  int marshal_next_hop_ip(char *) override;           // STR
+  int marshal_next_hop_port(char *) override;         // INT
 
   //
   // server -> proxy fields