This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 480e3f6769166b3ff1e71946751fcfad85318dbb
Author: vuori <[email protected]>
AuthorDate: Wed Sep 17 16:38:11 2025 +0300

    background_fetch: add Unix domain support. (#12504)
    
    * background_fetch: add Unix domain socket support.
    
    AF_UNIX client socket sockaddr structure is now handled correctly.
    Additionally a missing return in the error branch was added.
    
    * cache_fill: add Unix domain socket support.
    
    Ported fixes from background_fetch plugin.
    
    (cherry picked from commit bf7c2179253105ce9943a0bb31b87a47478d52b4)
    (cherry picked from commit 8f285632acbca0c8f38180f85356b6d6f13440a0)
---
 plugins/background_fetch/background_fetch.cc        | 4 ++++
 plugins/experimental/cache_fill/background_fetch.cc | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/plugins/background_fetch/background_fetch.cc 
b/plugins/background_fetch/background_fetch.cc
index 38c10b6775..aef4acb565 100644
--- a/plugins/background_fetch/background_fetch.cc
+++ b/plugins/background_fetch/background_fetch.cc
@@ -31,6 +31,7 @@
 #include <cinttypes>
 #include <string_view>
 #include <array>
+#include <sys/un.h>
 
 #include "ts/ts.h"
 #include "ts/remap.h"
@@ -238,8 +239,11 @@ BgFetchData::initialize(TSMBuffer request, TSMLoc req_hdr, 
TSHttpTxn txnp)
       memcpy(&client_ip, ip, sizeof(sockaddr_in));
     } else if (ip->sa_family == AF_INET6) {
       memcpy(&client_ip, ip, sizeof(sockaddr_in6));
+    } else if (ip->sa_family == AF_UNIX) {
+      memcpy(&client_ip, ip, sizeof(sockaddr_un));
     } else {
       TSError("[%s] Unknown address family %d", PLUGIN_NAME, ip->sa_family);
+      return false;
     }
   } else {
     TSError("[%s] Failed to get client host info", PLUGIN_NAME);
diff --git a/plugins/experimental/cache_fill/background_fetch.cc 
b/plugins/experimental/cache_fill/background_fetch.cc
index 621d9844d1..2cced083d5 100644
--- a/plugins/experimental/cache_fill/background_fetch.cc
+++ b/plugins/experimental/cache_fill/background_fetch.cc
@@ -34,6 +34,7 @@
 #include <array>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <sys/un.h>
 
 #include "ts/ts.h"
 #include "ts/remap.h"
@@ -157,8 +158,11 @@ BgFetchData::initialize(TSMBuffer request, TSMLoc req_hdr, 
TSHttpTxn txnp)
       memcpy(&client_ip, ip, sizeof(sockaddr_in));
     } else if (ip->sa_family == AF_INET6) {
       memcpy(&client_ip, ip, sizeof(sockaddr_in6));
+    } else if (ip->sa_family == AF_UNIX) {
+      memcpy(&client_ip, ip, sizeof(sockaddr_un));
     } else {
       TSError("[%s] Unknown address family %d", PLUGIN_NAME, ip->sa_family);
+      return false;
     }
   } else {
     TSError("[%s] Failed to get client host info", PLUGIN_NAME);

Reply via email to