You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2015/07/08 04:19:11 UTC

trafficserver git commit: [TS-2157] Replace addr with src_addr and dst_addr. This closes #182

Repository: trafficserver
Updated Branches:
  refs/heads/master 954f77ee1 -> 078a9a8c0


[TS-2157] Replace addr with src_addr and dst_addr.
This closes #182


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/078a9a8c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/078a9a8c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/078a9a8c

Branch: refs/heads/master
Commit: 078a9a8c0fa210f0f2d2a64f2aa0f285d602d13a
Parents: 954f77e
Author: es <es...@yahoo-inc.com>
Authored: Tue Mar 17 12:13:30 2015 -0700
Committer: Alan M. Carroll <am...@apache.org>
Committed: Tue Jul 7 21:13:42 2015 -0500

----------------------------------------------------------------------
 lib/ts/ink_inet.h                  | 13 ++++-
 proxy/InkAPI.cc                    | 12 ++---
 proxy/Prefetch.cc                  |  6 +--
 proxy/api/ts/ts.h                  |  4 ++
 proxy/http/HttpSM.cc               | 88 +++++++++++++++++----------------
 proxy/http/HttpTransact.cc         | 82 +++++++++++++++---------------
 proxy/http/HttpTransact.h          | 25 +++++-----
 proxy/http/HttpUpdateSM.cc         |  2 +-
 proxy/http/remap/RemapProcessor.cc |  6 +--
 proxy/http/remap/UrlRewrite.cc     |  4 +-
 proxy/logging/LogAccessHttp.cc     | 10 ++--
 11 files changed, 134 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/078a9a8c/lib/ts/ink_inet.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_inet.h b/lib/ts/ink_inet.h
index 553f444..1b77642 100644
--- a/lib/ts/ink_inet.h
+++ b/lib/ts/ink_inet.h
@@ -71,9 +71,12 @@ union IpEndpoint {
   struct sockaddr_in sin;   ///< IPv4
   struct sockaddr_in6 sin6; ///< IPv6
 
+  /** Assign from a socket address.
+      The entire address (all parts) are copied if the @a ip is valid.
+  */
   self &assign(sockaddr const *ip ///< Source address, family, port.
                );
-  /// Construct from an @a addr and @a port.
+  /// Assign from an @a addr and @a port.
   self &assign(IpAddr const &addr, ///< Address and address family.
                in_port_t port = 0  ///< Port (network order).
                );
@@ -103,6 +106,8 @@ union IpEndpoint {
   in_port_t &port();
   /// Port in network order.
   in_port_t port() const;
+  /// Port in host horder.
+  in_port_t host_order_port() const;
 
   operator sockaddr *() { return &sa; }
   operator sockaddr const *() const { return &sa; }
@@ -1465,6 +1470,12 @@ IpEndpoint::port() const
   return ats_ip_port_cast(&sa);
 }
 
+inline in_port_t
+IpEndpoint::host_order_port() const
+{
+  return ntohs(this->port());
+}
+
 inline bool
 IpEndpoint::isValid() const
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/078a9a8c/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 0c0995e..16973b1 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -5287,7 +5287,7 @@ TSHttpTxnServerAddrGet(TSHttpTxn txnp)
   sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
 
   HttpSM *sm = reinterpret_cast<HttpSM *>(txnp);
-  return &sm->t_state.server_info.addr.sa;
+  return &sm->t_state.server_info.dst_addr.sa;
 }
 
 TSReturnCode
@@ -5296,9 +5296,7 @@ TSHttpTxnServerAddrSet(TSHttpTxn txnp, struct sockaddr const *addr)
   sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
 
   HttpSM *sm = reinterpret_cast<HttpSM *>(txnp);
-  if (ats_ip_copy(&sm->t_state.server_info.addr.sa, addr)) {
-    ats_ip_port_cast(&sm->t_state.server_info.addr.sa) = ats_ip_port_cast(addr);
-    sm->t_state.server_info.port = htons(ats_ip_port_cast(addr));
+  if (ats_ip_copy(&sm->t_state.server_info.dst_addr.sa, addr)) {
     sm->t_state.api_server_addr_set = true;
     return TS_SUCCESS;
   } else {
@@ -5311,8 +5309,8 @@ TSHttpTxnClientIncomingPortSet(TSHttpTxn txnp, int port)
 {
   sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
 
-  HttpSM *sm = (HttpSM *)txnp;
-  sm->t_state.client_info.port = port;
+  HttpSM *sm = reinterpret_cast<HttpSM *>(txnp);
+  sm->t_state.client_info.dst_addr.port() = htons(port);
 }
 
 // [amc] This might use the port. The code path should do that but it
@@ -5349,7 +5347,7 @@ TSHttpTxnNextHopAddrGet(TSHttpTxn txnp)
   if (sm->t_state.current.server == NULL)
     return NULL;
 
-  return &sm->t_state.current.server->addr.sa;
+  return &sm->t_state.current.server->dst_addr.sa;
 }
 
 TSReturnCode

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/078a9a8c/proxy/Prefetch.cc
----------------------------------------------------------------------
diff --git a/proxy/Prefetch.cc b/proxy/Prefetch.cc
index 521aa83..5e3d9ff 100644
--- a/proxy/Prefetch.cc
+++ b/proxy/Prefetch.cc
@@ -579,7 +579,7 @@ PrefetchTransform::redirect(HTTPHdr *resp)
       }
 
       Debug("PrefetchTransform", "Found embedded URL: %s", redirect_url);
-      entry->req_ip = m_sm->t_state.client_info.addr;
+      entry->req_ip = m_sm->t_state.client_info.src_addr;
 
       PrefetchBlaster *blaster = prefetchBlasterAllocator.alloc();
       blaster->init(entry, &m_sm->t_state.hdr_info.client_request, this);
@@ -602,7 +602,7 @@ PrefetchTransform::parse_data(IOBufferReader *reader)
       continue;
     }
     // Debug("PrefetchParserURLs", "Found embedded URL: %s", url_start);
-    ats_ip_copy(&entry->req_ip, &m_sm->t_state.client_info.addr);
+    ats_ip_copy(&entry->req_ip, &m_sm->t_state.client_info.src_addr);
 
     PrefetchBlaster *blaster = prefetchBlasterAllocator.alloc();
     blaster->init(entry, &m_sm->t_state.hdr_info.client_request, this);
@@ -645,7 +645,7 @@ check_n_attach_prefetch_transform(HttpSM *sm, HTTPHdr *resp, bool from_cache)
   INKVConnInternal *prefetch_trans;
   ip_text_buffer client_ipb;
 
-  IpEndpoint client_ip = sm->t_state.client_info.addr;
+  IpEndpoint client_ip = sm->t_state.client_info.src_addr;
 
   // we depend on this to setup @a client_ipb for all subsequent Debug().
   Debug("PrefetchParser", "Checking response for request from %s\n", ats_ip_ntop(&client_ip, client_ipb, sizeof(client_ipb)));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/078a9a8c/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index 779f99c..882d10d 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -1284,6 +1284,10 @@ tsapi TSReturnCode TSHttpTxnCacheLookupStatusGet(TSHttpTxn txnp, int *lookup_sta
 
 tsapi TSReturnCode TSHttpTxnTransformRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *offset);
 
+/** Set the @a port value for the inbound (user agent) connection in the transaction @a txnp.
+    This is used primarily where the conection is synthetic and therefore does not have a port.
+    @note @a port is in @b host @b order.
+*/
 tsapi void TSHttpTxnClientIncomingPortSet(TSHttpTxn txnp, int port);
 
 /** Get SSL object of this session.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/078a9a8c/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 70520a9..37caa6e 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -487,8 +487,9 @@ HttpSM::attach_client_session(HttpClientSession *client_vc, IOBufferReader *buff
 
   NetVConnection *netvc = client_vc->get_netvc();
 
-  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.src_addr, netvc->get_remote_addr());
+  ats_ip_copy(&t_state.client_info.dst_addr, netvc->get_local_addr());
+  t_state.client_info.dst_addr.port() = netvc->get_local_port();
   t_state.client_info.is_transparent = netvc->get_is_transparent();
   t_state.backdoor_request = !client_vc->hooks_enabled();
   t_state.client_info.port_attribute = static_cast<HttpProxyPort::TransportType>(netvc->attributes);
@@ -1624,9 +1625,8 @@ HttpSM::state_http_server_open(int event, void *data)
        UnixNetVConnection *server_vc = (UnixNetVConnection*)data;
        printf("client fd is :%d , server fd is %d\n",vc->con.fd,
        server_vc->con.fd); */
-    ats_ip_copy(&session->server_ip, &t_state.current.server->addr);
-    session->new_connection((NetVConnection *)data);
-    ats_ip_port_cast(&session->server_ip) = htons(t_state.current.server->port);
+    ats_ip_copy(&session->server_ip, &t_state.current.server->dst_addr);
+    session->new_connection(static_cast<NetVConnection *>(data));
     session->state = HSS_ACTIVE;
 
     attach_server_session(session);
@@ -1660,8 +1660,8 @@ HttpSM::state_http_server_open(int event, void *data)
       if (is_debug_tag_set("http_tproxy")) {
         ip_port_text_buffer ip_c, ip_s;
         Debug("http_tproxy", "Force close of client connect (%s->%s) due to EADDRNOTAVAIL [%" PRId64 "]",
-              ats_ip_nptop(&t_state.client_info.addr.sa, ip_c, sizeof ip_c),
-              ats_ip_nptop(&t_state.server_info.addr.sa, ip_s, sizeof ip_s), sm_id);
+              ats_ip_nptop(&t_state.client_info.src_addr.sa, ip_c, sizeof ip_c),
+              ats_ip_nptop(&t_state.server_info.dst_addr.sa, ip_s, sizeof ip_s), sm_id);
       }
       t_state.client_info.keep_alive = HTTP_NO_KEEPALIVE; // part of the problem, clear it.
       terminate_sm = true;
@@ -2022,7 +2022,7 @@ HttpSM::process_hostdb_info(HostDBInfo *r)
         // may be very large, we cannot use client_request_time to approximate
         // current time when calling select_best_http().
         HostDBRoundRobin *rr = r->rr();
-        ret = rr->select_best_http(&t_state.client_info.addr.sa, now, (int)t_state.txn_conf->down_server_timeout);
+        ret = rr->select_best_http(&t_state.client_info.src_addr.sa, now, static_cast<int>(t_state.txn_conf->down_server_timeout));
 
         // set the srv target`s last_failure
         if (t_state.dns_info.srv_lookup_success) {
@@ -2114,7 +2114,7 @@ HttpSM::state_hostdb_lookup(int event, void *data)
 
     char *host_name = t_state.dns_info.srv_lookup_success ? t_state.dns_info.srv_hostname : t_state.dns_info.lookup_name;
     HostDBProcessor::Options opt;
-    opt.port = t_state.dns_info.srv_lookup_success ? t_state.dns_info.srv_port : t_state.server_info.port;
+    opt.port = t_state.dns_info.srv_lookup_success ? t_state.dns_info.srv_port : t_state.server_info.dst_addr.host_order_port();
     opt.flags = (t_state.cache_info.directives.does_client_permit_dns_storing) ? HostDBProcessor::HOSTDB_DO_NOT_FORCE_DNS :
                                                                                  HostDBProcessor::HOSTDB_FORCE_DNS_RELOAD;
     opt.timeout = (t_state.api_txn_dns_timeout_value != -1) ? t_state.api_txn_dns_timeout_value : 0;
@@ -2185,7 +2185,7 @@ HttpSM::state_mark_os_down(int event, void *data)
       ink_assert(t_state.current.server != NULL);
       ink_assert(t_state.current.request_to == HttpTransact::ORIGIN_SERVER);
       if (t_state.current.server) {
-        mark_down = r->rr()->find_ip(&t_state.current.server->addr.sa);
+        mark_down = r->rr()->find_ip(&t_state.current.server->dst_addr.sa);
       }
     } else {
       // No longer a round robin, check to see if our address is the same
@@ -3937,7 +3937,7 @@ HttpSM::do_hostdb_lookup()
       historical_action = pending_action;
     } else {
       char *host_name = t_state.dns_info.srv_lookup_success ? t_state.dns_info.srv_hostname : t_state.dns_info.lookup_name;
-      opt.port = t_state.dns_info.srv_lookup_success ? t_state.dns_info.srv_port : t_state.server_info.port;
+      opt.port = t_state.dns_info.srv_lookup_success ? t_state.dns_info.srv_port : t_state.server_info.dst_addr.isValid() ? t_state.server_info.dst_addr.host_order_port() : t_state.hdr_info.client_request.port_get();
       opt.flags = (t_state.cache_info.directives.does_client_permit_dns_storing) ? HostDBProcessor::HOSTDB_DO_NOT_FORCE_DNS :
                                                                                    HostDBProcessor::HOSTDB_FORCE_DNS_RELOAD;
       opt.timeout = (t_state.api_txn_dns_timeout_value != -1) ? t_state.api_txn_dns_timeout_value : 0;
@@ -3959,7 +3959,7 @@ HttpSM::do_hostdb_lookup()
 
     // If there is not a current server, we must be looking up the origin
     //  server at the beginning of the transaction
-    int server_port = t_state.current.server ? t_state.current.server->port : t_state.server_info.port;
+    int server_port = t_state.current.server ? t_state.current.server->dst_addr.host_order_port() : t_state.server_info.dst_addr.isValid() ? t_state.server_info.dst_addr.host_order_port() : t_state.hdr_info.client_request.port_get();
 
     if (t_state.api_txn_dns_timeout_value != -1) {
       DebugSM("http_timeout", "beginning DNS lookup. allowing %d mseconds for DNS lookup", t_state.api_txn_dns_timeout_value);
@@ -4019,7 +4019,7 @@ HttpSM::do_hostdb_update_if_necessary()
   }
   // If we failed back over to the origin server, we don't have our
   //   hostdb information anymore which means we shouldn't update the hostdb
-  if (!ats_ip_addr_eq(&t_state.current.server->addr.sa, t_state.host_db_info.ip())) {
+  if (!ats_ip_addr_eq(&t_state.current.server->dst_addr.sa, t_state.host_db_info.ip())) {
     DebugSM("http", "[%" PRId64 "] skipping hostdb update due to server failover", sm_id);
     return;
   }
@@ -4046,11 +4046,12 @@ HttpSM::do_hostdb_update_if_necessary()
   } else {
     if (t_state.host_db_info.app.http_data.last_failure != 0) {
       t_state.host_db_info.app.http_data.last_failure = 0;
-      ats_ip_port_cast(&t_state.current.server->addr) = htons(t_state.current.server->port);
       issue_update |= 1;
       char addrbuf[INET6_ADDRPORTSTRLEN];
       DebugSM("http", "[%" PRId64 "] hostdb update marking IP: %s as up", sm_id,
-              ats_ip_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)));
+              ats_ip_nptop(&t_state.current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
+      DebugSM("http", "[%" PRId64 "] hostdb update marking IP: %s as up", sm_id,
+              ats_ip_nptop(&t_state.current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
     }
 
     if (t_state.dns_info.srv_lookup_success && t_state.dns_info.srv_app.http_data.last_failure != 0) {
@@ -4061,12 +4062,12 @@ HttpSM::do_hostdb_update_if_necessary()
   }
 
   if (issue_update) {
-    hostDBProcessor.setby(t_state.current.server->name, strlen(t_state.current.server->name), &t_state.current.server->addr.sa,
+    hostDBProcessor.setby(t_state.current.server->name, strlen(t_state.current.server->name), &t_state.current.server->dst_addr.sa,
                           &t_state.host_db_info.app);
   }
 
   char addrbuf[INET6_ADDRPORTSTRLEN];
-  DebugSM("http", "server info = %s", ats_ip_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)));
+  DebugSM("http", "server info = %s", ats_ip_nptop(&t_state.current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
   return;
 }
 
@@ -4508,7 +4509,7 @@ HttpSM::do_cache_prepare_action(HttpCacheSM *c_sm, CacheHTTPInfo *object_read_in
 void
 HttpSM::do_http_server_open(bool raw)
 {
-  int ip_family = t_state.current.server->addr.sa.sa_family;
+  int ip_family = t_state.current.server->dst_addr.sa.sa_family;
   DebugSM("http_track", "entered inside do_http_server_open ][%s]", ats_ip_family_name(ip_family));
 
   ink_assert(server_entry == NULL);
@@ -4522,15 +4523,14 @@ HttpSM::do_http_server_open(bool raw)
   ink_assert(pending_action == NULL);
 
   if (false == t_state.api_server_addr_set) {
-    ink_assert(t_state.current.server->port > 0);
-    t_state.current.server->addr.port() = htons(t_state.current.server->port);
+    ink_assert(t_state.current.server->dst_addr.host_order_port() > 0);
   } else {
-    ink_assert(ats_ip_port_cast(&t_state.current.server->addr) != 0);
+    ink_assert(t_state.current.server->dst_addr.port() != 0); // verify the plugin set it to something.
   }
 
   char addrbuf[INET6_ADDRPORTSTRLEN];
   DebugSM("http", "[%" PRId64 "] open connection to %s: %s", sm_id, t_state.current.server->name,
-          ats_ip_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)));
+          ats_ip_nptop(&t_state.current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
 
   if (plugin_tunnel) {
     PluginVCCore *t = plugin_tunnel;
@@ -4606,11 +4606,11 @@ HttpSM::do_http_server_open(bool raw)
       (t_state.txn_conf->keep_alive_post_out == 1 || t_state.hdr_info.request_content_length == 0) && !is_private() &&
       ua_session != NULL) {
     HSMresult_t shared_result;
-    shared_result = httpSessionManager.acquire_session(this,                             // state machine
-                                                       &t_state.current.server->addr.sa, // ip + port
-                                                       t_state.current.server->name,     // hostname
-                                                       ua_session,                       // has ptr to bound ua sessions
-                                                       this                              // sm
+    shared_result = httpSessionManager.acquire_session(this,                                 // state machine
+                                                       &t_state.current.server->dst_addr.sa, // ip + port
+                                                       t_state.current.server->name,         // hostname
+                                                       ua_session,                           // has ptr to bound ua sessions
+                                                       this                                  // sm
                                                        );
 
     switch (shared_result) {
@@ -4640,7 +4640,7 @@ HttpSM::do_http_server_open(bool raw)
       // so there's no point in further checking on the match or pool values. But why check anything? The
       // client has already exchanged a request with this specific origin server and has sent another one
       // shouldn't we just automatically keep the association?
-      if (ats_ip_addr_port_eq(&existing_ss->server_ip.sa, &t_state.current.server->addr.sa)) {
+      if (ats_ip_addr_port_eq(&existing_ss->server_ip.sa, &t_state.current.server->dst_addr.sa)) {
         ua_session->attach_server_session(NULL);
         existing_ss->state = HSS_ACTIVE;
         this->attach_server_session(existing_ss);
@@ -4690,9 +4690,9 @@ HttpSM::do_http_server_open(bool raw)
     ConnectionCount *connections = ConnectionCount::getInstance();
 
     char addrbuf[INET6_ADDRSTRLEN];
-    if (connections->getCount((t_state.current.server->addr)) >= t_state.txn_conf->origin_max_connections) {
+    if (connections->getCount((t_state.current.server->dst_addr)) >= t_state.txn_conf->origin_max_connections) {
       DebugSM("http", "[%" PRId64 "] over the number of connection for this host: %s", sm_id,
-              ats_ip_ntop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)));
+              ats_ip_ntop(&t_state.current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
       ink_assert(pending_action == NULL);
       pending_action = eventProcessor.schedule_in(this, HRTIME_MSECONDS(100));
       return;
@@ -4720,7 +4720,7 @@ HttpSM::do_http_server_open(bool raw)
       opt.local_ip = outbound_ip;
     } else if (ua_session->f_outbound_transparent) {
       opt.addr_binding = NetVCOptions::FOREIGN_ADDR;
-      opt.local_ip = t_state.client_info.addr;
+      opt.local_ip = t_state.client_info.src_addr;
       /* If the connection is server side transparent, we can bind to the
          port that the client chose instead of randomly assigning one at
          the proxy.  This is controlled by the 'use_client_source_port'
@@ -4753,14 +4753,14 @@ HttpSM::do_http_server_open(bool raw)
     const char *host = t_state.hdr_info.server_request.host_get(&len);
     if (host && len > 0)
       opt.set_sni_servername(host, len);
-    connect_action_handle = sslNetProcessor.connect_re(this,                             // state machine
-                                                       &t_state.current.server->addr.sa, // addr + port
+    connect_action_handle = sslNetProcessor.connect_re(this,                                 // state machine
+                                                       &t_state.current.server->dst_addr.sa, // addr + port
                                                        &opt);
   } else {
     if (t_state.method != HTTP_WKSIDX_CONNECT) {
       DebugSM("http", "calling netProcessor.connect_re");
-      connect_action_handle = netProcessor.connect_re(this,                             // state machine
-                                                      &t_state.current.server->addr.sa, // addr + port
+      connect_action_handle = netProcessor.connect_re(this,                                 // state machine
+                                                      &t_state.current.server->dst_addr.sa, // addr + port
                                                       &opt);
     } else {
       // Setup the timeouts
@@ -4779,8 +4779,8 @@ HttpSM::do_http_server_open(bool raw)
           connect_timeout = t_state.txn_conf->connect_attempts_timeout;
       }
       DebugSM("http", "calling netProcessor.connect_s");
-      connect_action_handle = netProcessor.connect_s(this,                             // state machine
-                                                     &t_state.current.server->addr.sa, // addr + port
+      connect_action_handle = netProcessor.connect_s(this,                                 // state machine
+                                                     &t_state.current.server->dst_addr.sa, // addr + port
                                                      connect_timeout, &opt);
     }
   }
@@ -4926,7 +4926,7 @@ HttpSM::mark_host_failure(HostDBInfo *info, time_t time_down)
     char *url_str = t_state.hdr_info.client_request.url_string_get(&t_state.arena, 0);
     Log::error("CONNECT: could not connect to %s "
                "for '%s' (setting last failure time)",
-               ats_ip_ntop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)), url_str ? url_str : "<none>");
+               ats_ip_ntop(&t_state.current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)), url_str ? url_str : "<none>");
     if (url_str)
       t_state.arena.str_free(url_str);
   }
@@ -4939,7 +4939,9 @@ HttpSM::mark_host_failure(HostDBInfo *info, time_t time_down)
 #endif
 
   DebugSM("http", "[%" PRId64 "] hostdb update marking IP: %s as down", sm_id,
-          ats_ip_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)));
+          ats_ip_nptop(&t_state.current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
+  DebugSM("http", "[%" PRId64 "] hostdb update marking IP: %s as down", sm_id,
+          ats_ip_nptop(&t_state.current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
 }
 
 void
@@ -6691,7 +6693,7 @@ HttpSM::update_stats()
       status = t_state.hdr_info.client_response.status_get();
     }
     char client_ip[INET6_ADDRSTRLEN];
-    ats_ip_ntop(&t_state.client_info.addr, client_ip, sizeof(client_ip));
+    ats_ip_ntop(&t_state.client_info.src_addr, client_ip, sizeof(client_ip));
     Error("[%" PRId64 "] Slow Request: "
           "client_ip: %s:%u "
           "url: %s "
@@ -6717,7 +6719,7 @@ HttpSM::update_stats()
           "sm_finish: %.3f "
           "plugin_active: %.3f "
           "plugin_total: %.3f",
-          sm_id, client_ip, ats_ip_port_host_order(&t_state.client_info.addr), url_string, status, unique_id_string,
+          sm_id, client_ip, t_state.client_info.src_addr.host_order_port(), url_string, status, unique_id_string,
           redirection_tries, client_response_body_bytes, fd, t_state.client_info.state, t_state.server_info.state,
           milestones.difference(TransactionMilestones::SM_START, TransactionMilestones::UA_BEGIN),
           milestones.difference(TransactionMilestones::SM_START, TransactionMilestones::UA_FIRST_READ),
@@ -6907,9 +6909,9 @@ HttpSM::set_next_state()
        */
       ip_text_buffer ipb;
       DebugSM("dns", "[HttpTransact::HandleRequest] Skipping DNS lookup for API supplied target %s.\n",
-              ats_ip_ntop(&t_state.server_info.addr, ipb, sizeof(ipb)));
+              ats_ip_ntop(&t_state.server_info.dst_addr, ipb, sizeof(ipb)));
       // this seems wasteful as we will just copy it right back
-      ats_ip_copy(t_state.host_db_info.ip(), &t_state.server_info.addr);
+      ats_ip_copy(t_state.host_db_info.ip(), &t_state.server_info.dst_addr);
       t_state.dns_info.lookup_success = true;
       call_transact_and_set_next_state(NULL);
       break;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/078a9a8c/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 304a4eb..6c765b6 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -239,7 +239,7 @@ find_server_and_update_current_info(HttpTransact::State *s)
       //  to go the origin server, we can only obey this if we
       //  dns'ed the origin server
       if (s->parent_result.r == PARENT_DIRECT && s->http_config_param->no_dns_forward_to_parent != 0) {
-        ink_assert(!ats_is_ip(&s->server_info.addr));
+        ink_assert(!s->server_info.dst_addr.isValid());
         s->parent_result.r = PARENT_FAIL;
       }
       break;
@@ -268,7 +268,6 @@ find_server_and_update_current_info(HttpTransact::State *s)
   switch (s->parent_result.r) {
   case PARENT_SPECIFIED:
     s->parent_info.name = s->arena.str_store(s->parent_result.hostname, strlen(s->parent_result.hostname));
-    s->parent_info.port = s->parent_result.port;
     update_current_info(&s->current, &s->parent_info, HttpTransact::PARENT_PROXY, (s->current.attempts)++);
     update_dns_info(&s->dns_info, &s->current, 0, &s->arena);
     ink_assert(s->dns_info.looking_up == HttpTransact::PARENT_PROXY);
@@ -712,7 +711,7 @@ HttpTransact::StartRemapRequest(State *s)
   s->cop_test_page = (ptr_len_cmp(host, host_len, local_host_ip_str, sizeof(local_host_ip_str) - 1) == 0) &&
                      (ptr_len_cmp(path, path_len, syntxt, sizeof(syntxt) - 1) == 0) &&
                      port == s->http_config_param->synthetic_port && s->method == HTTP_WKSIDX_GET &&
-                     s->orig_scheme == URL_WKSIDX_HTTP && ats_ip4_addr_cast(&s->client_info.addr.sa) == htonl(INADDR_LOOPBACK);
+                     s->orig_scheme == URL_WKSIDX_HTTP && ats_ip4_addr_cast(&s->client_info.dst_addr.sa) == htonl(INADDR_LOOPBACK);
 
   //////////////////////////////////////////////////////////////////
   // FIX: this logic seems awfully convoluted and hard to follow; //
@@ -1367,7 +1366,7 @@ HttpTransact::HandleRequest(State *s)
       //  DNS service available, we just want to forward the request
       //  the parent proxy.  In this case, we never find out the
       //  origin server's ip.  So just skip past OSDNS
-      ats_ip_invalidate(&s->server_info.addr);
+      ats_ip_invalidate(&s->server_info.dst_addr);
       StartAccessControl(s);
       return;
     } else if (s->http_config_param->no_origin_server_dns) {
@@ -1435,6 +1434,8 @@ HttpTransact::setup_plugin_request_intercept(State *s)
   s->server_info.keep_alive = HTTP_NO_KEEPALIVE;
   s->host_db_info.app.http_data.http_version = HostDBApplicationInfo::HTTP_VERSION_10;
   s->host_db_info.app.http_data.pipeline_max = 1;
+  s->server_info.dst_addr.setToAnyAddr(AF_INET); // must set an address or we can't set the port.
+  s->server_info.dst_addr.port() = htons(s->hdr_info.client_request.port_get()); // this is the info that matters.
 
   // Build the request to the server
   build_request(s, &s->hdr_info.client_request, &s->hdr_info.server_request, s->client_info.http_version);
@@ -1523,7 +1524,7 @@ HttpTransact::PPDNSLookup(State *s)
   if (!s->dns_info.lookup_success) {
     // DNS lookup of parent failed, find next parent or o.s.
     find_server_and_update_current_info(s);
-    if (!ats_is_ip(&s->current.server->addr)) {
+    if (!s->current.server->dst_addr.isValid()) {
       if (s->current.request_to == PARENT_PROXY) {
         TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, PPDNSLookup);
       } else {
@@ -1536,13 +1537,14 @@ HttpTransact::PPDNSLookup(State *s)
     }
   } else {
     // lookup succeeded, open connection to p.p.
-    ats_ip_copy(&s->parent_info.addr, s->host_db_info.ip());
+    ats_ip_copy(&s->parent_info.dst_addr, s->host_db_info.ip());
+    s->parent_info.dst_addr.port() = htons(s->parent_result.port);
     get_ka_info_from_host_db(s, &s->parent_info, &s->client_info, &s->host_db_info);
     s->parent_info.dns_round_robin = s->host_db_info.round_robin;
 
     char addrbuf[INET6_ADDRSTRLEN];
     DebugTxn("http_trans", "[PPDNSLookup] DNS lookup for sm_id[%" PRId64 "] successful IP: %s", s->state_machine->sm_id,
-             ats_ip_ntop(&s->parent_info.addr.sa, addrbuf, sizeof(addrbuf)));
+             ats_ip_ntop(&s->parent_info.dst_addr.sa, addrbuf, sizeof(addrbuf)));
   }
 
   // Since this function can be called several times while retrying
@@ -1591,14 +1593,14 @@ HttpTransact::ReDNSRoundRobin(State *s)
 
     // Our ReDNS of the server succeeded so update the necessary
     //  information and try again
-    ats_ip_copy(&s->server_info.addr, s->host_db_info.ip());
-    ats_ip_copy(&s->request_data.dest_ip, &s->server_info.addr);
+    ats_ip_copy(&s->server_info.dst_addr, s->host_db_info.ip());
+    ats_ip_copy(&s->request_data.dest_ip, &s->server_info.dst_addr);
     get_ka_info_from_host_db(s, &s->server_info, &s->client_info, &s->host_db_info);
     s->server_info.dns_round_robin = s->host_db_info.round_robin;
 
     char addrbuf[INET6_ADDRSTRLEN];
     DebugTxn("http_trans", "[ReDNSRoundRobin] DNS lookup for O.S. successful IP: %s",
-             ats_ip_ntop(&s->server_info.addr.sa, addrbuf, sizeof(addrbuf)));
+             ats_ip_ntop(&s->server_info.dst_addr.sa, addrbuf, sizeof(addrbuf)));
 
     s->next_action = how_to_open_connection(s);
   } else {
@@ -1716,7 +1718,7 @@ HttpTransact::OSDNSLookup(State *s)
     // HostDB addresses. We use those if they're different from the CTA.
     // In all cases we now commit to client or HostDB for our source.
     if (s->host_db_info.round_robin) {
-      HostDBInfo *cta = s->host_db_info.rr()->select_next(&s->current.server->addr.sa);
+      HostDBInfo *cta = s->host_db_info.rr()->select_next(&s->current.server->dst_addr.sa);
       if (cta) {
         // found another addr, lock in host DB.
         s->host_db_info = *cta;
@@ -1725,7 +1727,7 @@ HttpTransact::OSDNSLookup(State *s)
         // nothing else there, continue with CTA.
         s->dns_info.os_addr_style = DNSLookupInfo::OS_ADDR_USE_CLIENT;
       }
-    } else if (ats_ip_addr_eq(s->host_db_info.ip(), &s->server_info.addr.sa)) {
+    } else if (ats_ip_addr_eq(s->host_db_info.ip(), &s->server_info.dst_addr.sa)) {
       s->dns_info.os_addr_style = DNSLookupInfo::OS_ADDR_USE_CLIENT;
     } else {
       s->dns_info.os_addr_style = DNSLookupInfo::OS_ADDR_USE_HOSTDB;
@@ -1735,15 +1737,16 @@ HttpTransact::OSDNSLookup(State *s)
   // Check to see if can fullfill expect requests based on the cached
   // update some state variables with hostdb information that has
   // been provided.
-  ats_ip_copy(&s->server_info.addr, s->host_db_info.ip());
-  ats_ip_copy(&s->request_data.dest_ip, &s->server_info.addr);
+  ats_ip_copy(&s->server_info.dst_addr, s->host_db_info.ip());
+  s->server_info.dst_addr.port() = htons(s->hdr_info.client_request.port_get()); // now we can set the port.
+  ats_ip_copy(&s->request_data.dest_ip, &s->server_info.dst_addr);
   get_ka_info_from_host_db(s, &s->server_info, &s->client_info, &s->host_db_info);
   s->server_info.dns_round_robin = s->host_db_info.round_robin;
 
   char addrbuf[INET6_ADDRSTRLEN];
   DebugTxn("http_trans", "[OSDNSLookup] DNS lookup for O.S. successful "
                          "IP: %s",
-           ats_ip_ntop(&s->server_info.addr.sa, addrbuf, sizeof(addrbuf)));
+           ats_ip_ntop(&s->server_info.dst_addr.sa, addrbuf, sizeof(addrbuf)));
 
   // so the dns lookup was a success, but the lookup succeeded on
   // a hostname which was expanded by the traffic server. we should
@@ -2688,7 +2691,7 @@ HttpTransact::HandleCacheOpenReadHit(State *s)
     if (server_up || s->stale_icp_lookup) {
       bool check_hostdb = get_ka_info_from_config(s, s->current.server);
       DebugTxn("http_trans", "CacheOpenReadHit - check_hostdb %d", check_hostdb);
-      if (!s->stale_icp_lookup && (check_hostdb || !ats_is_ip(&s->current.server->addr))) {
+      if (!s->stale_icp_lookup && (check_hostdb || !s->current.server->dst_addr.isValid())) {
         //        ink_release_assert(s->current.request_to == PARENT_PROXY ||
         //                    s->http_config_param->no_dns_forward_to_parent != 0);
 
@@ -3113,7 +3116,7 @@ HttpTransact::HandleCacheOpenReadMiss(State *s)
 
   if (!h->is_cache_control_set(HTTP_VALUE_ONLY_IF_CACHED)) {
     find_server_and_update_current_info(s);
-    if (!ats_is_ip(&s->current.server->addr)) {
+    if (!s->current.server->dst_addr.isValid()) {
       ink_release_assert(s->current.request_to == PARENT_PROXY || s->http_config_param->no_dns_forward_to_parent != 0);
       if (s->current.request_to == PARENT_PROXY) {
         TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, HttpTransact::PPDNSLookup);
@@ -3155,13 +3158,13 @@ HttpTransact::HandleICPLookup(State *s)
   if (s->icp_lookup_success == true) {
     HTTP_INCREMENT_TRANS_STAT(http_icp_suggested_lookups_stat);
     DebugTxn("http_trans", "[HandleICPLookup] Success, sending request to icp suggested host.");
-    ats_ip4_set(&s->icp_info.addr, s->icp_ip_result.sin_addr.s_addr);
-    s->icp_info.port = ntohs(s->icp_ip_result.sin_port);
+    ats_ip4_set(&s->icp_info.dst_addr, s->icp_ip_result.sin_addr.s_addr);
+    s->icp_info.dst_addr.port() = ntohs(s->icp_ip_result.sin_port);
 
     // TODO in this case we should go to the miss case
     // just a little shy about using goto's, that's all.
-    ink_release_assert((s->icp_info.port != s->client_info.port) ||
-                       (ats_ip_addr_cmp(&s->icp_info.addr.sa, &Machine::instance()->ip.sa) != 0));
+    ink_release_assert((s->icp_info.dst_addr.port() != s->client_info.dst_addr.port()) ||
+                       (ats_ip_addr_cmp(&s->icp_info.dst_addr.sa, &Machine::instance()->ip.sa) != 0));
 
     // Since the ICPDNSLookup is not called, these two
     //   values are not initialized.
@@ -3183,10 +3186,10 @@ HttpTransact::HandleICPLookup(State *s)
     SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_NOT_CACHED);
     DebugTxn("http_trans", "[HandleICPLookup] Failure, sending request to forward server.");
     s->parent_info.name = NULL;
-    ink_zero(s->parent_info.addr);
+    ink_zero(s->parent_info.dst_addr);
 
     find_server_and_update_current_info(s);
-    if (!ats_is_ip(&s->current.server->addr)) {
+    if (!ats_is_ip(&s->current.server->dst_addr)) {
       if (s->current.request_to == PARENT_PROXY) {
         TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, PPDNSLookup);
       } else {
@@ -3464,7 +3467,7 @@ HttpTransact::handle_response_from_icp_suggested_host(State *s)
     // send request to parent proxy now if there is
     // one or else directly to the origin server.
     find_server_and_update_current_info(s);
-    if (!ats_is_ip(&s->current.server->addr)) {
+    if (!ats_is_ip(&s->current.server->dst_addr)) {
       if (s->current.request_to == PARENT_PROXY) {
         TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, PPDNSLookup);
       } else {
@@ -3528,7 +3531,7 @@ HttpTransact::handle_response_from_parent(State *s)
 
     char addrbuf[INET6_ADDRSTRLEN];
     DebugTxn("http_trans", "[%d] failed to connect to parent %s", s->current.attempts,
-             ats_ip_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf)));
+             ats_ip_ntop(&s->current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
 
     // If the request is not retryable, just give up!
     if (!is_request_retryable(s)) {
@@ -3688,7 +3691,7 @@ HttpTransact::handle_response_from_server(State *s)
         // Force host resolution to have the same family as the client.
         // Because this is a transparent connection, we can't switch address
         // families - that is locked in by the client source address.
-        s->state_machine->ua_session->host_res_style = ats_host_res_match(&s->current.server->addr.sa);
+        s->state_machine->ua_session->host_res_style = ats_host_res_match(&s->current.server->dst_addr.sa);
         TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, OSDNSLookup);
       } else if ((s->dns_info.srv_lookup_success || s->server_info.dns_round_robin) &&
                  (s->txn_conf->connect_attempts_rr_retries > 0) &&
@@ -3740,7 +3743,7 @@ HttpTransact::delete_server_rr_entry(State *s, int max_retries)
   char addrbuf[INET6_ADDRSTRLEN];
 
   DebugTxn("http_trans", "[%d] failed to connect to %s", s->current.attempts,
-           ats_ip_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf)));
+           ats_ip_ntop(&s->current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
   DebugTxn("http_trans", "[delete_server_rr_entry] marking rr entry "
                          "down and finding next one");
   ink_assert(s->current.server->had_connect_fail());
@@ -3776,7 +3779,7 @@ HttpTransact::retry_server_connection_not_open(State *s, ServerState_t conn_stat
   char *url_string = s->hdr_info.client_request.url_string_get(&s->arena);
 
   DebugTxn("http_trans", "[%d] failed to connect [%d] to %s", s->current.attempts, conn_state,
-           ats_ip_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf)));
+           ats_ip_ntop(&s->current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)));
 
   //////////////////////////////////////////
   // on the first connect attempt failure //
@@ -3785,7 +3788,7 @@ HttpTransact::retry_server_connection_not_open(State *s, ServerState_t conn_stat
   if (0 == s->current.attempts)
     Log::error("CONNECT:[%d] could not connect [%s] to %s for '%s'", s->current.attempts,
                HttpDebugNames::get_server_state_name(conn_state),
-               ats_ip_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf)), url_string ? url_string : "<none>");
+               ats_ip_ntop(&s->current.server->dst_addr.sa, addrbuf, sizeof(addrbuf)), url_string ? url_string : "<none>");
 
   if (url_string) {
     s->arena.str_free(url_string);
@@ -3951,7 +3954,8 @@ HttpTransact::handle_forward_server_connection_open(State *s)
       s->api_server_response_ignore = true;
     }
     // s->cache_info.action = CACHE_PREPARE_TO_SERVE;
-    // xing xing in the tunneling case, need to check when the cache_read_vc is closed, make sure the cache_read_vc is closed right
+    // xing xing in the tunneling case, need to check when the cache_read_vc is closed, make sure the cache_read_vc is closed
+    // right
     // away
   }
 
@@ -5152,11 +5156,11 @@ HttpTransact::add_client_ip_to_outgoing_request(State *s, HTTPHdr *request)
   char ip_string[INET6_ADDRSTRLEN + 1] = {'\0'};
   size_t ip_string_size = 0;
 
-  if (!ats_is_ip(&s->client_info.addr.sa))
+  if (!ats_is_ip(&s->client_info.src_addr.sa))
     return;
 
   // Always prepare the IP string.
-  if (ats_ip_ntop(&s->client_info.addr.sa, ip_string, sizeof(ip_string)) != NULL) {
+  if (ats_ip_ntop(&s->client_info.src_addr.sa, ip_string, sizeof(ip_string)) != NULL) {
     ip_string_size += strlen(ip_string);
   } else {
     // Failure, omg
@@ -5520,13 +5524,12 @@ void
 HttpTransact::initialize_state_variables_for_origin_server(State *s, HTTPHdr *incoming_request, bool second_time)
 {
   if (s->server_info.name && !second_time) {
-    ink_assert(s->server_info.port != 0);
+    ink_assert(s->server_info.dst_addr.port() != 0);
   }
 
   int host_len;
   const char *host = incoming_request->host_get(&host_len);
   s->server_info.name = s->arena.str_store(host, host_len);
-  s->server_info.port = incoming_request->port_get();
 
   if (second_time) {
     s->dns_info.attempts = 0;
@@ -5589,7 +5592,6 @@ HttpTransact::initialize_state_variables_from_request(State *s, HTTPHdr *obsolet
 
   if (!s->server_info.name || s->redirect_info.redirect_in_process) {
     s->server_info.name = s->arena.str_store(host_name, host_len);
-    s->server_info.port = incoming_request->port_get();
   }
 
   s->next_hop_scheme = s->scheme = incoming_request->url_get()->scheme_get_wksidx();
@@ -5656,7 +5658,7 @@ HttpTransact::initialize_state_variables_from_request(State *s, HTTPHdr *obsolet
   s->request_data.hdr = &s->hdr_info.client_request;
 
   s->request_data.hostname_str = s->arena.str_store(host_name, host_len);
-  ats_ip_copy(&s->request_data.src_ip, &s->client_info.addr);
+  ats_ip_copy(&s->request_data.src_ip, &s->client_info.src_addr);
   memset(&s->request_data.dest_ip, 0, sizeof(s->request_data.dest_ip));
   if (s->state_machine->ua_session) {
     s->request_data.incoming_port = s->state_machine->ua_session->get_netvc()->get_local_port();
@@ -6528,7 +6530,7 @@ HttpTransact::process_quick_http_filter(State *s, int method)
     if (deny_request) {
       if (is_debug_tag_set("ip-allow")) {
         ip_text_buffer ipb;
-        Debug("ip-allow", "Quick filter denial on %s:%s with mask %x", ats_ip_ntop(&s->client_info.addr.sa, ipb, sizeof(ipb)),
+        Debug("ip-allow", "Quick filter denial on %s:%s with mask %x", ats_ip_ntop(&s->client_info.src_addr.sa, ipb, sizeof(ipb)),
               hdrtoken_index_to_wks(method), acl_record ? acl_record->_method_mask : 0x0);
       }
       s->client_connection_enabled = false;
@@ -6603,8 +6605,8 @@ HttpTransact::will_this_request_self_loop(State *s)
   ////////////////////////////////////////
   if (s->dns_info.lookup_success) {
     if (ats_ip_addr_eq(s->host_db_info.ip(), &Machine::instance()->ip.sa)) {
-      uint16_t host_port = s->hdr_info.client_request.url_get()->port_get();
-      uint16_t local_port = ats_ip_port_host_order(&s->client_info.addr);
+      in_port_t host_port = s->hdr_info.client_request.url_get()->port_get();
+      in_port_t local_port = s->client_info.src_addr.host_order_port();
       if (host_port == local_port) {
         switch (s->dns_info.looking_up) {
         case ORIGIN_SERVER:
@@ -8183,7 +8185,7 @@ HttpTransact::build_error_response(State *s, HTTPStatus status_code, const char
   if (s->http_config_param->errors_log_error_pages && status_code >= HTTP_STATUS_BAD_REQUEST) {
     char ip_string[INET6_ADDRSTRLEN];
 
-    Log::error("RESPONSE: sent %s status %d (%s) for '%s'", ats_ip_ntop(&s->client_info.addr.sa, ip_string, sizeof(ip_string)),
+    Log::error("RESPONSE: sent %s status %d (%s) for '%s'", ats_ip_ntop(&s->client_info.src_addr.sa, ip_string, sizeof(ip_string)),
                status_code, reason_phrase, (url_string ? url_string : "<none>"));
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/078a9a8c/proxy/http/HttpTransact.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h
index fa64940..e33bc7f 100644
--- a/proxy/http/HttpTransact.h
+++ b/proxy/http/HttpTransact.h
@@ -654,16 +654,15 @@ public:
     bool dns_round_robin;
     TransferEncoding_t transfer_encoding;
 
-    IpEndpoint addr; // replaces 'ip' field
-
-    // port to connect to, except for client
-    // connection where it is port on proxy
-    // that client connected to.
-    // This field is managed separately from the port
-    // part of 'addr' above as in various cases the two
-    // are set/manipulated independently and things are
-    // clearer this way.
-    uint16_t port; // host order.
+    /** This is the source address of the connection from the point of view of the transaction.
+	It is the address of the source of the request.
+    */
+    IpEndpoint src_addr;
+    /** This is the destination address of the connection from the point of view of the transaction.
+	It is the address of the target of the request.
+    */
+    IpEndpoint dst_addr;
+
     ServerState_t state;
     AbortState_t abort;
     HttpProxyPort::TransportType port_attribute;
@@ -690,10 +689,10 @@ public:
     ConnectionAttributes()
       : http_version(), keep_alive(HTTP_KEEPALIVE_UNDEFINED), receive_chunked_response(false), pipeline_possible(false),
         proxy_connect_hdr(false), connect_result(0), name(NULL), dns_round_robin(false), transfer_encoding(NO_TRANSFER_ENCODING),
-        port(0), state(STATE_UNDEFINED), abort(ABORT_UNDEFINED), port_attribute(HttpProxyPort::TRANSPORT_DEFAULT),
-        is_transparent(false)
+        state(STATE_UNDEFINED), abort(ABORT_UNDEFINED), port_attribute(HttpProxyPort::TRANSPORT_DEFAULT), is_transparent(false)
     {
-      memset(&addr, 0, sizeof(addr));
+      memset(&src_addr, 0, sizeof(src_addr));
+      memset(&dst_addr, 0, sizeof(dst_addr));
     }
   };
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/078a9a8c/proxy/http/HttpUpdateSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpUpdateSM.cc b/proxy/http/HttpUpdateSM.cc
index 7e14ecc..e90927d 100644
--- a/proxy/http/HttpUpdateSM.cc
+++ b/proxy/http/HttpUpdateSM.cc
@@ -74,7 +74,7 @@ HttpUpdateSM::start_scheduled_update(Continuation *cont, HTTPHdr *request)
 
   // Fix ME: What should these be set to since there is not a
   //   real client
-  ats_ip4_set(&t_state.client_info.addr, htonl(INADDR_LOOPBACK), 0);
+  ats_ip4_set(&t_state.client_info.src_addr, htonl(INADDR_LOOPBACK), 0);
   t_state.backdoor_request = 0;
   t_state.client_info.port_attribute = HttpProxyPort::TRANSPORT_DEFAULT;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/078a9a8c/proxy/http/remap/RemapProcessor.cc
----------------------------------------------------------------------
diff --git a/proxy/http/remap/RemapProcessor.cc b/proxy/http/remap/RemapProcessor.cc
index 3c47cb4..1c1e029 100644
--- a/proxy/http/remap/RemapProcessor.cc
+++ b/proxy/http/remap/RemapProcessor.cc
@@ -87,9 +87,9 @@ RemapProcessor::setup_for_remap(HttpTransact::State *s)
   Debug("url_rewrite", "[lookup] attempting %s lookup", proxy_request ? "proxy" : "normal");
 
   if (rewrite_table->num_rules_forward_with_recv_port) {
-    Debug("url_rewrite", "[lookup] forward mappings with recv port found; Using recv port %d", s->client_info.port);
-    if (rewrite_table->forwardMappingWithRecvPortLookup(request_url, s->client_info.port, request_host, request_host_len,
-                                                        s->url_map)) {
+    Debug("url_rewrite", "[lookup] forward mappings with recv port found; Using recv port %d", s->client_info.src_addr.port());
+    if (rewrite_table->forwardMappingWithRecvPortLookup(request_url, s->client_info.src_addr.host_order_port(), request_host,
+                                                        request_host_len, s->url_map)) {
       Debug("url_rewrite", "Found forward mapping with recv port");
       mapping_found = true;
     } else if (rewrite_table->num_rules_forward == 0) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/078a9a8c/proxy/http/remap/UrlRewrite.cc
----------------------------------------------------------------------
diff --git a/proxy/http/remap/UrlRewrite.cc b/proxy/http/remap/UrlRewrite.cc
index 0cf66f7..b74171c 100644
--- a/proxy/http/remap/UrlRewrite.cc
+++ b/proxy/http/remap/UrlRewrite.cc
@@ -388,7 +388,7 @@ UrlRewrite::PerformACLFiltering(HttpTransact::State *s, url_mapping *map)
     int method_wksidx = (method != -1) ? (method - HTTP_WKSIDX_CONNECT) : -1;
     bool client_enabled_flag = true;
 
-    ink_release_assert(ats_is_ip(&s->client_info.addr));
+    ink_release_assert(ats_is_ip(&s->client_info.src_addr));
 
     for (acl_filter_rule *rp = map->filter; rp && client_enabled_flag; rp = rp->next) {
       bool match = true;
@@ -406,7 +406,7 @@ UrlRewrite::PerformACLFiltering(HttpTransact::State *s, url_mapping *map)
       if (match && rp->src_ip_valid) {
         match = false;
         for (int j = 0; j < rp->src_ip_cnt && !match; j++) {
-          bool in_range = rp->src_ip_array[j].contains(s->client_info.addr);
+          bool in_range = rp->src_ip_array[j].contains(s->client_info.src_addr);
           if (rp->src_ip_array[j].invert) {
             if (!in_range) {
               match = true;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/078a9a8c/proxy/logging/LogAccessHttp.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc
index f5fc802..4b46475 100644
--- a/proxy/logging/LogAccessHttp.cc
+++ b/proxy/logging/LogAccessHttp.cc
@@ -234,7 +234,7 @@ LogAccessHttp::marshal_plugin_identity_tag(char *buf)
 int
 LogAccessHttp::marshal_client_host_ip(char *buf)
 {
-  return marshal_ip(buf, &m_http_sm->t_state.client_info.addr.sa);
+  return marshal_ip(buf, &m_http_sm->t_state.client_info.src_addr.sa);
 }
 
 /*-------------------------------------------------------------------------
@@ -260,7 +260,7 @@ int
 LogAccessHttp::marshal_client_host_port(char *buf)
 {
   if (buf) {
-    uint16_t port = ntohs(m_http_sm->t_state.client_info.addr.port());
+    uint16_t port = ntohs(m_http_sm->t_state.client_info.src_addr.port());
     marshal_int(buf, port);
   }
   return INK_MIN_ALIGN;
@@ -824,7 +824,7 @@ LogAccessHttp::marshal_proxy_req_server_name(char *buf)
 int
 LogAccessHttp::marshal_proxy_req_server_ip(char *buf)
 {
-  return marshal_ip(buf, m_http_sm->t_state.current.server != NULL ? &m_http_sm->t_state.current.server->addr.sa : 0);
+  return marshal_ip(buf, m_http_sm->t_state.current.server != NULL ? &m_http_sm->t_state.current.server->dst_addr.sa : 0);
 }
 
 /*-------------------------------------------------------------------------
@@ -848,10 +848,10 @@ int
 LogAccessHttp::marshal_server_host_ip(char *buf)
 {
   sockaddr const *ip = 0;
-  ip = &m_http_sm->t_state.server_info.addr.sa;
+  ip = &m_http_sm->t_state.server_info.dst_addr.sa;
   if (!ats_is_ip(ip)) {
     if (m_http_sm->t_state.current.server) {
-      ip = &m_http_sm->t_state.current.server->addr.sa;
+      ip = &m_http_sm->t_state.current.server->dst_addr.sa;
       if (!ats_is_ip(ip))
         ip = 0;
     } else {