trafficserver-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wolfgang Walter <trafficser...@stwm.de>
Subject Re: Logging: add %<csi> and %<csp>
Date Thu, 10 Apr 2014 09:00:40 GMT
Am Donnerstag, 10. April 2014, 10:29:27 schrieb Yunkai Zhang:
> Why we need to log these information?

We here need them to distinquish how the client used the proxy. We have 
different ips (and ports) for explicit and transparent use.

> 
> And there are client_host_{ip|port}, the name of client_server_{ip|port}
> are really confusing me.
> 
> On Thu, Apr 10, 2014 at 4:28 AM, Wolfgang Walter 
<trafficserver@stwm.de>wrote:
> > From a625520d878e455a62f2f890920915e482d36e73 Mon Sep 17 00:00:00 2001
> > From: Wolfgang Walter <tintenfisch@stusta.de>
> > Date: Sun, 6 Apr 2014 13:20:07 +0200
> > Subject: [PATCH 5/6] Logging: add %<csi> and %<csp>
> > 
> > csi logs the ip address (which is one of the Traffic Server) the client
> > request arrived.
> > 
> > csp logs the port the client request arrived.
> > ---
> > 
> >  proxy/http/HttpSM.cc           |  1 +
> >  proxy/logging/Log.cc           | 15 +++++++++++++++
> >  proxy/logging/LogAccess.cc     | 18 ++++++++++++++++++
> >  proxy/logging/LogAccess.h      |  2 ++
> >  proxy/logging/LogAccessHttp.cc | 22 ++++++++++++++++++++++
> >  proxy/logging/LogAccessHttp.h  |  2 ++
> >  6 files changed, 60 insertions(+)
> > 
> > diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
> > index 2a65209..b45d5ba 100644
> > --- a/proxy/http/HttpSM.cc
> > +++ b/proxy/http/HttpSM.cc
> > @@ -544,6 +544,7 @@ HttpSM::attach_client_session(HttpClientSession *
> > client_vc, IOBufferReader * bu
> > 
> >    ats_ip_copy(&t_state.client_info.addr, netvc->get_remote_addr());
> >    t_state.client_info.port = netvc->get_local_port();
> > 
> > +  ats_ip_copy(&t_state.client_info.local_addr, netvc->get_local_addr());
> > 
> >    t_state.client_info.is_transparent = netvc->get_is_transparent();
> >    t_state.backdoor_request = client_vc->backdoor_connect;
> >    t_state.client_info.port_attribute =
> > 
> > static_cast<HttpProxyPort::TransportType>(netvc->attributes);
> > diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
> > index fe671d0..1a8d6bd 100644
> > --- a/proxy/logging/Log.cc
> > +++ b/proxy/logging/Log.cc
> > @@ -358,6 +358,21 @@ Log::init_fields()
> > 
> >    global_field_list.add(field, false);
> >    ink_hash_table_insert(field_symbol_hash, "chih", field);
> > 
> > +  field = NEW(new LogField("client_server_ip", "csi",
> > +                           LogField::IP,
> > +                           &LogAccess::marshal_client_server_ip,
> > +                           &LogAccess::unmarshal_ip_to_str));
> > +  global_field_list.add(field, false);
> > +  ink_hash_table_insert(field_symbol_hash, "csi", field);
> > +
> > +  field = NEW(new LogField("client_server_port", "csp",
> > +                           LogField::sINT,
> > +                           &LogAccess::marshal_client_server_port,
> > +                           &LogAccess::unmarshal_int_to_str));
> > +  global_field_list.add(field, false);
> > +  ink_hash_table_insert(field_symbol_hash, "csp", field);
> > +
> > +
> > 
> >    field = NEW (new LogField ("client_auth_user_name", "caun",
> >    
> >                               LogField::STRING,
> >                               &LogAccess::marshal_client_auth_user_name,
> > 
> > diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
> > index 9a14391..004dfc9 100644
> > --- a/proxy/logging/LogAccess.cc
> > +++ b/proxy/logging/LogAccess.cc
> > @@ -99,6 +99,24 @@ LogAccess::marshal_client_host_port(char *buf)
> > 
> >  -------------------------------------------------------------------------
> >  */
> >  
> >  int
> > 
> > +LogAccess::marshal_client_server_ip(char *buf)
> > +{
> > +  DEFAULT_IP_FIELD;
> > +}
> > +
> > 
> > +/*-----------------------------------------------------------------------
> > -- +
> > 
> >  -------------------------------------------------------------------------
> >  */
> > 
> > +
> > +int
> > +LogAccess::marshal_client_server_port(char *buf)
> > +{
> > +  DEFAULT_INT_FIELD;
> > +}
> > +
> > 
> > +/*-----------------------------------------------------------------------
> > -- +
> > 
> >  -------------------------------------------------------------------------
> >  */
> > 
> > +
> > +int
> > 
> >  LogAccess::marshal_client_auth_user_name(char *buf)
> >  {
> >  
> >    DEFAULT_STR_FIELD;
> > 
> > diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
> > index 2ef5ca5..568f14f 100644
> > --- a/proxy/logging/LogAccess.h
> > +++ b/proxy/logging/LogAccess.h
> > 
> > @@ -169,6 +169,8 @@ public:
> >    //
> >    inkcoreapi virtual int marshal_client_host_ip(char *);        // STR
> >    inkcoreapi virtual int marshal_client_host_port(char *);      // INT
> > 
> > +  inkcoreapi virtual int marshal_client_server_ip(char *);        // STR
> > +  inkcoreapi virtual int marshal_client_server_port(char *);      // INT
> > 
> >    inkcoreapi virtual int marshal_client_auth_user_name(char *); // STR
> >    int marshal_client_req_timestamp_sec(char *); // INT
> > 
> > diff --git a/proxy/logging/LogAccessHttp.cc
> > b/proxy/logging/LogAccessHttp.cc
> > index 8d82aab..9fd4370 100644
> > --- a/proxy/logging/LogAccessHttp.cc
> > +++ b/proxy/logging/LogAccessHttp.cc
> > @@ -167,6 +167,28 @@ LogAccessHttp::marshal_client_host_port(char *buf)
> > 
> >  }
> >  
> >  
> >  /*-----------------------------------------------------------------------
> >  --
> > 
> > +
> > 
> >  -------------------------------------------------------------------------
> >  */
> > 
> > +
> > +int
> > +LogAccessHttp::marshal_client_server_ip(char *buf)
> > +{
> > +  return marshal_ip(buf, &m_http_sm->t_state.client_info.local_addr.sa);
> > +}
> > +
> > 
> > +/*-----------------------------------------------------------------------
> > -- +
> > 
> >  -------------------------------------------------------------------------
> >  */
> > 
> > +
> > +int
> > +LogAccessHttp::marshal_client_server_port(char *buf)
> > +{
> > +  if (buf) {
> > +    uint16_t port = ats_ip_port_host_order(&m_http_sm->
> > t_state.client_info.local_addr.sa);
> > +    marshal_int(buf, port);
> > +  }
> > +  return INK_MIN_ALIGN;
> > +}
> > +
> > 
> > +/*-----------------------------------------------------------------------
> > --> 
> >    user authenticated to the proxy (RFC931)
> >  
> >  -------------------------------------------------------------------------
> >  */
> > 
> > diff --git a/proxy/logging/LogAccessHttp.h b/proxy/logging/LogAccessHttp.h
> > index 133cd94..980c5c7 100644
> > --- a/proxy/logging/LogAccessHttp.h
> > +++ b/proxy/logging/LogAccessHttp.h
> > 
> > @@ -57,6 +57,8 @@ public:
> >    //
> >    virtual int marshal_client_host_ip(char *);   // STR
> >    virtual int marshal_client_host_port(char *); // INT
> > 
> > +  virtual int marshal_client_server_ip(char *);   // STR
> > +  virtual int marshal_client_server_port(char *); // INT
> > 
> >    virtual int marshal_client_auth_user_name(char *);    // STR
> >    virtual int marshal_client_protocol_stack(char *);    // INT
> >    virtual int marshal_client_req_text(char *);  // STR
> > 
> > --
> > 1.9.1

Regards,
-- 
Wolfgang Walter
Studentenwerk München
Anstalt des öffentlichen Rechts

Mime
View raw message