Repository: trafficserver Updated Branches: refs/heads/master 6e3ce5022 -> 1a5624162
[TS-3476] Add a log tag for application protocol. This closes #244. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/1a562416 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/1a562416 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/1a562416 Branch: refs/heads/master Commit: 1a56241621a6a06b30e8a91eb170bf633e77951b Parents: 6e3ce50 Author: ericcarlschwartz <[email protected]> Authored: Mon Jul 6 15:14:56 2015 -0700 Committer: shinrich <[email protected]> Committed: Fri Jul 10 07:08:20 2015 -0500 ---------------------------------------------------------------------- proxy/FetchSM.cc | 2 +- proxy/http2/Http2ClientSession.cc | 12 +++++++++++ proxy/http2/Http2ClientSession.h | 5 ++++- proxy/logging/Log.cc | 5 +++++ proxy/logging/LogAccess.cc | 9 +++++++++ proxy/logging/LogAccess.h | 1 + proxy/logging/LogAccessHttp.cc | 37 ++++++++++++++++++++++++++++++++++ proxy/logging/LogAccessHttp.h | 1 + proxy/spdy/SpdyClientSession.h | 2 +- 9 files changed, 71 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1a562416/proxy/FetchSM.cc ---------------------------------------------------------------------- diff --git a/proxy/FetchSM.cc b/proxy/FetchSM.cc index 3fd726c..1942202 100644 --- a/proxy/FetchSM.cc +++ b/proxy/FetchSM.cc @@ -63,7 +63,7 @@ FetchSM::httpConnect() char const *tag = pi ? pi->getPluginTag() : "fetchSM"; int64_t id = pi ? pi->getPluginId() : 0; - Debug(DEBUG_TAG, "[%s] calling httpconnect write", __FUNCTION__); + Debug(DEBUG_TAG, "[%s] calling httpconnect write pi=%p tag=%s id=%d", __FUNCTION__, pi, tag, id); http_vc = reinterpret_cast<PluginVC *>(TSHttpConnectWithPluginId(&_addr.sa, tag, id)); /* http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1a562416/proxy/http2/Http2ClientSession.cc ---------------------------------------------------------------------- diff --git a/proxy/http2/Http2ClientSession.cc b/proxy/http2/Http2ClientSession.cc index 93c7e3c..32445f8 100644 --- a/proxy/http2/Http2ClientSession.cc +++ b/proxy/http2/Http2ClientSession.cc @@ -391,3 +391,15 @@ Http2ClientSession::state_complete_frame_read(int event, void *edata) vio->reenable(); return 0; } + +int64_t +Http2ClientSession::getPluginId() const +{ + return con_id; +} + +char const* +Http2ClientSession::getPluginTag() const +{ + return "http/2"; +} http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1a562416/proxy/http2/Http2ClientSession.h ---------------------------------------------------------------------- diff --git a/proxy/http2/Http2ClientSession.h b/proxy/http2/Http2ClientSession.h index 5e3ab23..e7e0aa1 100644 --- a/proxy/http2/Http2ClientSession.h +++ b/proxy/http2/Http2ClientSession.h @@ -25,6 +25,7 @@ #define __HTTP2_CLIENT_SESSION_H__ #include "HTTP2.h" +#include "Plugin.h" #include "ProxyClientSession.h" #include "Http2ConnectionState.h" @@ -143,7 +144,7 @@ private: } hdr; }; -class Http2ClientSession : public ProxyClientSession +class Http2ClientSession : public ProxyClientSession, public PluginIdentity { public: typedef ProxyClientSession super; ///< Parent type. @@ -198,6 +199,8 @@ public: return upgrade_context; } + virtual char const* getPluginTag() const; + virtual int64_t getPluginId() const; private: Http2ClientSession(Http2ClientSession &); // noncopyable http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1a562416/proxy/logging/Log.cc ---------------------------------------------------------------------- diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc index f565ea0..23a6c84 100644 --- a/proxy/logging/Log.cc +++ b/proxy/logging/Log.cc @@ -439,6 +439,11 @@ Log::init_fields() global_field_list.add(field, false); ink_hash_table_insert(field_symbol_hash, "cqhv", field); + field = new LogField("client_req_protocol_version", "cqpv", LogField::dINT, &LogAccess::marshal_client_req_protocol_version, + (LogField::UnmarshalFunc) &LogAccess::unmarshal_str); + global_field_list.add(field, false); + ink_hash_table_insert(field_symbol_hash, "cqpv", field); + field = new LogField("client_req_header_len", "cqhl", LogField::sINT, &LogAccess::marshal_client_req_header_len, &LogAccess::unmarshal_int_to_str); global_field_list.add(field, false); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1a562416/proxy/logging/LogAccess.cc ---------------------------------------------------------------------- diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc index 24fa519..65c71f8 100644 --- a/proxy/logging/LogAccess.cc +++ b/proxy/logging/LogAccess.cc @@ -218,6 +218,15 @@ LogAccess::marshal_client_req_http_version(char *buf) -------------------------------------------------------------------------*/ int +LogAccess::marshal_client_req_protocol_version(char *buf) +{ + DEFAULT_STR_FIELD; +} + +/*------------------------------------------------------------------------- + -------------------------------------------------------------------------*/ + +int LogAccess::marshal_client_req_header_len(char *buf) { DEFAULT_INT_FIELD; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1a562416/proxy/logging/LogAccess.h ---------------------------------------------------------------------- diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h index ec9feb4..16d5f33 100644 --- a/proxy/logging/LogAccess.h +++ b/proxy/logging/LogAccess.h @@ -183,6 +183,7 @@ public: inkcoreapi virtual int marshal_client_req_url_path(char *); // STR inkcoreapi virtual int marshal_client_req_url_scheme(char *); // STR inkcoreapi virtual int marshal_client_req_http_version(char *); // INT + inkcoreapi virtual int marshal_client_req_protocol_version(char *); // STR inkcoreapi virtual int marshal_client_req_header_len(char *); // INT inkcoreapi virtual int marshal_client_req_body_len(char *); // INT inkcoreapi virtual int marshal_client_req_tcp_reused(char *); // INT http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1a562416/proxy/logging/LogAccessHttp.cc ---------------------------------------------------------------------- diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc index 28d6c61..43f935e 100644 --- a/proxy/logging/LogAccessHttp.cc +++ b/proxy/logging/LogAccessHttp.cc @@ -573,6 +573,43 @@ LogAccessHttp::marshal_client_req_http_version(char *buf) -------------------------------------------------------------------------*/ int +LogAccessHttp::marshal_client_req_protocol_version(char *buf) +{ + int len = INK_MIN_ALIGN; + char const *tag = m_http_sm->plugin_tag; + + if (!tag) { + if (m_client_request) { + HTTPVersion versionObject = m_client_request->version_get(); + int64_t major = HTTP_MAJOR(versionObject.m_version); + int64_t minor = HTTP_MINOR(versionObject.m_version); + if (major == 1 && minor == 1) { + tag = "http/1.1"; + } else if (major == 1 && minor == 0) { + tag = "http/1.0"; + } else if (major == 0 && minor == 9) { + tag = "http/0.9"; + } // else invalid http version + len = LogAccess::strlen(tag); + } else { + tag = "*"; + } + } else { + len = LogAccess::strlen(tag); + } + + if (buf) { + marshal_str(buf, tag, len); + } + + return len; +} + + +/*------------------------------------------------------------------------- + -------------------------------------------------------------------------*/ + +int LogAccessHttp::marshal_client_req_header_len(char *buf) { if (buf) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1a562416/proxy/logging/LogAccessHttp.h ---------------------------------------------------------------------- diff --git a/proxy/logging/LogAccessHttp.h b/proxy/logging/LogAccessHttp.h index 966f4b7..f7daf4a 100644 --- a/proxy/logging/LogAccessHttp.h +++ b/proxy/logging/LogAccessHttp.h @@ -68,6 +68,7 @@ public: virtual int marshal_client_req_url_path(char *); // STR virtual int marshal_client_req_url_scheme(char *); // STR virtual int marshal_client_req_http_version(char *); // INT + virtual int marshal_client_req_protocol_version(char *); // STR virtual int marshal_client_req_header_len(char *); // INT virtual int marshal_client_req_body_len(char *); // INT virtual int marshal_client_req_tcp_reused(char *); // INT http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1a562416/proxy/spdy/SpdyClientSession.h ---------------------------------------------------------------------- diff --git a/proxy/spdy/SpdyClientSession.h b/proxy/spdy/SpdyClientSession.h index 349942a..8b46c60 100644 --- a/proxy/spdy/SpdyClientSession.h +++ b/proxy/spdy/SpdyClientSession.h @@ -89,7 +89,7 @@ public: extern ClassAllocator<SpdyRequest> spdyRequestAllocator; // class SpdyClientSession : public Continuation, public PluginIdentity -class SpdyClientSession : public ProxyClientSession +class SpdyClientSession : public ProxyClientSession, public PluginIdentity { public: typedef ProxyClientSession super; ///< Parent type.
