Return-Path: X-Original-To: apmail-trafficserver-dev-archive@www.apache.org Delivered-To: apmail-trafficserver-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0E02111C92 for ; Wed, 9 Apr 2014 20:27:50 +0000 (UTC) Received: (qmail 6018 invoked by uid 500); 9 Apr 2014 20:27:48 -0000 Delivered-To: apmail-trafficserver-dev-archive@trafficserver.apache.org Received: (qmail 5940 invoked by uid 500); 9 Apr 2014 20:27:48 -0000 Mailing-List: contact dev-help@trafficserver.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@trafficserver.apache.org Delivered-To: mailing list dev@trafficserver.apache.org Received: (qmail 5932 invoked by uid 99); 9 Apr 2014 20:27:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2014 20:27:48 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [141.84.225.229] (HELO email.studentenwerk.mhn.de) (141.84.225.229) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2014 20:27:44 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by email.studentenwerk.mhn.de (Postfix) with ESMTPSA id 3g3xqZ28fTz2hYg for ; Wed, 9 Apr 2014 22:27:22 +0200 (CEST) From: Wolfgang Walter To: dev@trafficserver.apache.org Subject: [PATCH 3/6] Logging: add % % Date: Wed, 09 Apr 2014 22:27:21 +0200 Message-ID: <2946976.ZnjRDXI9ZL@ei.h3.stusta.mhn.de> Organization: Studentenwerk =?UTF-8?B?TcO8bmNoZW4=?= User-Agent: KMail/4.11.5 (Linux/3.14.0-ei+6.8; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Virus-Checked: Checked by ClamAV on apache.org >From 7f3324b42f8cbe5049fdf8c7bc5bf0c60f9195e7 Mon Sep 17 00:00:00 2001 From: Wolfgang Walter Date: Sun, 6 Apr 2014 13:20:06 +0200 Subject: [PATCH 3/6] Logging: add % % pqli logs the source ip address of the server request. pqlp logs the source port of the server request. --- proxy/http/HttpSM.cc | 7 +++++++ proxy/http/HttpTransact.h | 3 +++ proxy/logging/Log.cc | 14 ++++++++++++++ proxy/logging/LogAccess.cc | 18 ++++++++++++++++++ proxy/logging/LogAccess.h | 2 ++ proxy/logging/LogAccessHttp.cc | 16 ++++++++++++++++ proxy/logging/LogAccessHttp.h | 2 ++ 7 files changed, 62 insertions(+) diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index e60f5a4..2a65209 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -2877,6 +2877,8 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer * p) ink_assert(p->vc_type == HT_HTTP_SERVER); ink_assert(p->vc == server_session); + ats_ip_copy(&t_state.current.server->local_addr, server_session->get_netvc()->get_local_addr()); + if (close_connection) { p->vc->do_io_close(); p->read_vio = NULL; @@ -3425,6 +3427,11 @@ HttpSM::tunnel_handler_ssl_producer(int event, HttpTunnelProducer * p) STATE_ENTER(&HttpSM::tunnel_handler_ssl_producer, event); + if (p->vc_type == HT_HTTP_SERVER && server_entry->vc == p->vc) { + NetVConnection* netvc = (NetVConnection *) p->vc; + ats_ip_copy(&t_state.current.server->local_addr, netvc->get_local_addr()); + } + switch (event) { case VC_EVENT_EOS: // The write side of this connection is still alive diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h index 652c5ac..9255fdb 100644 --- a/proxy/http/HttpTransact.h +++ b/proxy/http/HttpTransact.h @@ -715,6 +715,8 @@ public: /// @c true if the connection is transparent. bool is_transparent; + IpEndpoint local_addr; + bool had_connect_fail() const { return 0 != connect_result; } void clear_connect_fail() { connect_result = 0; } void set_connect_fail(int e) { connect_result = e; } @@ -736,6 +738,7 @@ public: is_transparent(false) { memset(&addr, 0, sizeof(addr)); + memset(&local_addr, 0, sizeof(addr)); } }; diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc index 560085c..fe671d0 100644 --- a/proxy/logging/Log.cc +++ b/proxy/logging/Log.cc @@ -672,6 +672,20 @@ Log::init_fields() global_field_list.add(field, false); ink_hash_table_insert(field_symbol_hash, "pqsp", field); + field = NEW(new LogField("proxy_req_local_ip", "pqli", + LogField::IP, + &LogAccess::marshal_proxy_req_local_ip, + &LogAccess::unmarshal_ip_to_str)); + global_field_list.add(field, false); + ink_hash_table_insert(field_symbol_hash, "pqli", field); + + field = NEW(new LogField("proxy_req_server_port", "pqlp", + LogField::sINT, + &LogAccess::marshal_proxy_req_local_port, + &LogAccess::unmarshal_int_to_str)); + global_field_list.add(field, false); + ink_hash_table_insert(field_symbol_hash, "pqlp", field); + Ptr hierarchy_map = make_ptr(NEW(new LogFieldAliasTable)); hierarchy_map->init(36, SQUID_HIER_EMPTY, "EMPTY", diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc index 5db1740..9a14391 100644 --- a/proxy/logging/LogAccess.cc +++ b/proxy/logging/LogAccess.cc @@ -340,6 +340,24 @@ LogAccess::marshal_proxy_req_server_port(char *buf) -------------------------------------------------------------------------*/ int +LogAccess::marshal_proxy_req_local_ip(char *buf) +{ + DEFAULT_IP_FIELD; +} + +/*------------------------------------------------------------------------- + -------------------------------------------------------------------------*/ + +int +LogAccess::marshal_proxy_req_local_port(char *buf) +{ + DEFAULT_INT_FIELD; +} + +/*------------------------------------------------------------------------- + -------------------------------------------------------------------------*/ + +int LogAccess::marshal_proxy_hierarchy_route(char *buf) { DEFAULT_INT_FIELD; diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h index 909efb7..2ef5ca5 100644 --- a/proxy/logging/LogAccess.h +++ b/proxy/logging/LogAccess.h @@ -206,6 +206,8 @@ public: inkcoreapi virtual int marshal_proxy_req_server_name(char *); // STR 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_req_local_ip(char *); // INT + inkcoreapi virtual int marshal_proxy_req_local_port(char *); // INT inkcoreapi virtual int marshal_proxy_hierarchy_route(char *); // INT inkcoreapi virtual int marshal_proxy_host_name(char *); // STR inkcoreapi virtual int marshal_proxy_host_ip(char *); // STR diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc index 626e672..8d82aab 100644 --- a/proxy/logging/LogAccessHttp.cc +++ b/proxy/logging/LogAccessHttp.cc @@ -697,6 +697,22 @@ LogAccessHttp::marshal_proxy_req_server_port(char *buf) return INK_MIN_ALIGN; } +int +LogAccessHttp::marshal_proxy_req_local_ip(char *buf) +{ + return marshal_ip(buf, m_http_sm->t_state.current.server != NULL ? &m_http_sm->t_state.current.server->local_addr.sa : 0); +} + +int +LogAccessHttp::marshal_proxy_req_local_port(char *buf) +{ + if (buf) { + in_port_t port = m_http_sm->t_state.current.server != NULL ? ats_ip_port_host_order(&m_http_sm->t_state.current.server->local_addr.sa) : 0; + marshal_int(buf, port); + } + return INK_MIN_ALIGN; +} + /*------------------------------------------------------------------------- -------------------------------------------------------------------------*/ diff --git a/proxy/logging/LogAccessHttp.h b/proxy/logging/LogAccessHttp.h index cfd9f0a..133cd94 100644 --- a/proxy/logging/LogAccessHttp.h +++ b/proxy/logging/LogAccessHttp.h @@ -92,6 +92,8 @@ public: virtual int marshal_proxy_req_server_name(char *); // STR virtual int marshal_proxy_req_server_ip(char *); // INT virtual int marshal_proxy_req_server_port(char *); // INT + virtual int marshal_proxy_req_local_ip(char *); // STR + virtual int marshal_proxy_req_local_port(char *); // INT virtual int marshal_proxy_hierarchy_route(char *); // INT // -- 1.9.1