This is an automated email from the ASF dual-hosted git repository.
maskit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 41523d163d Fix hii log field for UDS (#12107)
41523d163d is described below
commit 41523d163d4285aaccd0dbcdab3bd8aabc2a2a10
Author: Masakazu Kitajo <[email protected]>
AuthorDate: Mon Mar 24 18:20:23 2025 -0600
Fix hii log field for UDS (#12107)
* Fix hii log field for UDS
* Use ats_unix_set instead of UnAddr
* Check HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
---
include/tscore/ink_inet.h | 12 ++++++++++++
src/proxy/logging/LogAccess.cc | 8 ++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/include/tscore/ink_inet.h b/include/tscore/ink_inet.h
index 22cd738bbf..2a4fbc363e 100644
--- a/include/tscore/ink_inet.h
+++ b/include/tscore/ink_inet.h
@@ -1100,6 +1100,18 @@ ats_ip6_set(IpEndpoint *dst, ///< Destination
storage.
return ats_ip6_set(&dst->sin6, addr, port);
}
+inline sockaddr *
+ats_unix_set(IpEndpoint *dst, const char *path, int len)
+{
+ dst->sun.sun_family = AF_UNIX;
+ len = std::min(len, static_cast<int>(TS_UNIX_SIZE));
+ memcpy(dst->sun.sun_path, path, len);
+#if HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
+ dst->sun.sun_len = len;
+#endif
+ return ats_ip_sa_cast(&dst->sun);
+}
+
/** Write a null terminated string for @a addr to @a dst.
A buffer of size INET6_ADDRSTRLEN suffices, including a terminating nul.
*/
diff --git a/src/proxy/logging/LogAccess.cc b/src/proxy/logging/LogAccess.cc
index 5f9fcdd3e2..c5eefe748e 100644
--- a/src/proxy/logging/LogAccess.cc
+++ b/src/proxy/logging/LogAccess.cc
@@ -1062,6 +1062,10 @@ LogAccess::unmarshal_ip(char **buf, IpEndpoint *dest)
LogFieldIp6 *ip6 = static_cast<LogFieldIp6 *>(raw);
ats_ip6_set(dest, ip6->_addr);
len = sizeof(*ip6);
+ } else if (AF_UNIX == raw->_family) {
+ LogFieldUn *un = static_cast<LogFieldUn *>(raw);
+ ats_unix_set(dest, un->_path, TS_UNIX_SIZE);
+ len = sizeof(*un);
} else {
ats_ip_invalidate(dest);
}
@@ -1085,7 +1089,7 @@ LogAccess::unmarshal_ip_to_str(char **buf, char *dest,
int len)
if (len > 0) {
unmarshal_ip(buf, &ip);
- if (!ats_is_ip(&ip)) {
+ if (!ats_is_ip(&ip) && !ats_is_unix(ip)) {
*dest = '0';
Dbg(dbg_ctl_log_unmarshal_data, "Invalid IP address");
return 1;
@@ -1112,7 +1116,7 @@ LogAccess::unmarshal_ip_to_hex(char **buf, char *dest,
int len)
if (len > 0) {
unmarshal_ip(buf, &ip);
- if (!ats_is_ip(&ip)) {
+ if (!ats_is_ip(&ip) && !ats_is_unix(ip)) {
*dest = '0';
Dbg(dbg_ctl_log_unmarshal_data, "Invalid IP address");
return 1;