Skip to content

Commit 6d36bdb

Browse files
maskitcmcfarlen
authored andcommitted
Fix ppa log field (#12863)
- Copy a whole pp_info for logging - Calculate the length with alignment in consideration - Put null terminator at the end of the log field value (cherry picked from commit 24e0170)
1 parent 492ab3b commit 6d36bdb

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/proxy/http/HttpTransact.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5744,11 +5744,7 @@ HttpTransact::initialize_state_variables_from_request(State *s, HTTPHdr *obsolet
57445744
memset(&s->request_data.dest_ip, 0, sizeof(s->request_data.dest_ip));
57455745
if (vc) {
57465746
s->request_data.incoming_port = vc->get_local_port();
5747-
s->pp_info.version = vc->get_proxy_protocol_version();
5748-
if (s->pp_info.version != ProxyProtocolVersion::UNDEFINED) {
5749-
ats_ip_copy(s->pp_info.src_addr, vc->get_proxy_protocol_src_addr());
5750-
ats_ip_copy(s->pp_info.dst_addr, vc->get_proxy_protocol_dst_addr());
5751-
}
5747+
s->pp_info = vc->get_proxy_protocol_info();
57525748
}
57535749
s->request_data.xact_start = s->client_request_time;
57545750
s->request_data.api_info = &s->api_info;

src/proxy/logging/LogAccess.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,14 +1609,18 @@ LogAccess::marshal_proxy_protocol_dst_ip(char *buf)
16091609
int
16101610
LogAccess::marshal_proxy_protocol_authority(char *buf)
16111611
{
1612-
if (buf && m_http_sm) {
1612+
int len = INK_MIN_ALIGN;
1613+
1614+
if (m_http_sm) {
16131615
if (auto authority = m_http_sm->t_state.pp_info.get_tlv(PP2_TYPE_AUTHORITY)) {
1614-
int len = static_cast<int>(authority->size());
1615-
marshal_str(buf, authority->data(), len);
1616-
return len;
1616+
len = padded_length(authority->size() + 1);
1617+
if (buf) {
1618+
marshal_str(buf, authority->data(), len);
1619+
buf[authority->size()] = '\0';
1620+
}
16171621
}
16181622
}
1619-
return 0;
1623+
return len;
16201624
}
16211625

16221626
/*-------------------------------------------------------------------------

0 commit comments

Comments
 (0)