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

kichan 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 a1e1ffec7a Wasm plugin: Handle AF_INET6 case for port extraction 
(#12635)
a1e1ffec7a is described below

commit a1e1ffec7a5e20b0daada3d8bb2c0dbe0366f99c
Author: Kit Chan <[email protected]>
AuthorDate: Tue Nov 4 07:22:31 2025 -0800

    Wasm plugin: Handle AF_INET6 case for port extraction (#12635)
    
    * Wasm plugin: Handle AF_INET6 case for port extraction
    
    Wasm plugin: Handle AF_INET6 case for port extraction
    
    * Update plugins/experimental/wasm/ats_context.cc
    
    Co-authored-by: Copilot <[email protected]>
    
    * Log unsupported address family in ats_context.cc
    
    Add debug logging for unsupported address families.
    
    * Update plugins/experimental/wasm/ats_context.cc
    
    Co-authored-by: Copilot <[email protected]>
    
    ---------
    
    Co-authored-by: Copilot <[email protected]>
---
 plugins/experimental/wasm/ats_context.cc | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/plugins/experimental/wasm/ats_context.cc 
b/plugins/experimental/wasm/ats_context.cc
index 01fcf16870..c617fd5293 100644
--- a/plugins/experimental/wasm/ats_context.cc
+++ b/plugins/experimental/wasm/ats_context.cc
@@ -126,6 +126,10 @@ print_address(struct sockaddr const *ip, std::string 
*result)
       const auto *s_sockaddr_in6 = reinterpret_cast<const struct sockaddr_in6 
*>(ip);
       inet_ntop(AF_INET6, &s_sockaddr_in6->sin6_addr, cip, sizeof(cip));
       port = s_sockaddr_in6->sin6_port;
+    } else {
+      Dbg(dbg_ctl, "[%s] unsupported address family: %d", __FUNCTION__, 
static_cast<int>(ip->sa_family));
+      *result = pv_empty;
+      return;
     }
     Dbg(dbg_ctl, "[%s] property retrieval - address: %.*s", __FUNCTION__, 
static_cast<int>(sizeof(cip)), cip);
     std::string cip_str(cip);
@@ -143,9 +147,13 @@ print_port(struct sockaddr const *ip, std::string *result)
     if (ip->sa_family == AF_INET) {
       const auto *s_sockaddr_in = reinterpret_cast<const struct sockaddr_in 
*>(ip);
       port                      = s_sockaddr_in->sin_port;
-    } else {
+    } else if (ip->sa_family == AF_INET6) {
       const auto *s_sockaddr_in6 = reinterpret_cast<const struct sockaddr_in6 
*>(ip);
       port                       = s_sockaddr_in6->sin6_port;
+    } else {
+      Dbg(dbg_ctl, "[%s] unsupported address family: %d", __FUNCTION__, 
static_cast<int>(ip->sa_family));
+      *result = pv_empty;
+      return;
     }
     Dbg(dbg_ctl, "[%s] looking for source port: %d", __FUNCTION__, 
static_cast<int>(port));
     result->assign(reinterpret_cast<const char *>(&port), sizeof(int64_t));

Reply via email to