Skip to content

Commit d967264

Browse files
authored
Keep a copy of the effective client ip for logging (#12818)
1 parent 7cd2c9a commit d967264

3 files changed

Lines changed: 5 additions & 10 deletions

File tree

include/proxy/http/HttpTransact.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,9 @@ class HttpTransact
713713
ConnectionAttributes client_info;
714714
ConnectionAttributes parent_info;
715715
ConnectionAttributes server_info;
716+
// This is a copy of the effective client IP address (see pp-clnt) to
717+
// ensure this is available for logging
718+
IpEndpoint effective_client_addr;
716719

717720
Source_t source = Source_t::NONE;
718721
Source_t pre_transform_source = Source_t::NONE;

src/proxy/http/HttpSM.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ HttpSM::attach_client_session(ProxyTransaction *txn)
448448

449449
ats_ip_copy(&t_state.client_info.src_addr, netvc->get_remote_addr());
450450
ats_ip_copy(&t_state.client_info.dst_addr, netvc->get_local_addr());
451+
ats_ip_copy(&t_state.effective_client_addr, netvc->get_effective_remote_addr());
451452
t_state.client_info.is_transparent = netvc->get_is_transparent();
452453
t_state.client_info.port_attribute = static_cast<HttpProxyPort::TransportType>(netvc->attributes);
453454

src/proxy/logging/LogAccess.cc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,16 +1442,7 @@ LogAccess::marshal_plugin_identity_tag(char *buf)
14421442
int
14431443
LogAccess::marshal_client_host_ip(char *buf)
14441444
{
1445-
if (m_http_sm) {
1446-
auto txn = m_http_sm->get_ua_txn();
1447-
if (txn) {
1448-
sockaddr const *addr = txn->get_client_addr();
1449-
if (addr && ats_is_ip(addr)) {
1450-
return marshal_ip(buf, addr);
1451-
}
1452-
}
1453-
}
1454-
return INK_MIN_ALIGN;
1445+
return marshal_ip(buf, &m_http_sm->t_state.effective_client_addr.sa);
14551446
}
14561447

14571448
int

0 commit comments

Comments
 (0)