moonchen commented on code in PR #13667:
URL: https://github.com/apache/trafficserver/pull/13667#discussion_r3993570903


##########
src/iocore/net/P_UnixNetVConnection.h:
##########
@@ -304,6 +307,41 @@ UnixNetVConnection::set_mptcp_state()
 #endif
 }
 
+// Copy the TCP_INFO fields ATS reports out of the kernel.
+inline bool
+UnixNetVConnection::get_tcp_info(TcpInfoSnapshot &info) const
+{
+#if defined(TCP_INFO) && defined(HAVE_STRUCT_TCP_INFO) && \
+  (HAVE_STRUCT_TCP_INFO_TCPI_TOTAL_RETRANS || 
HAVE_STRUCT_TCP_INFO___TCPI_RETRANS)
+  struct tcp_info tinfo     = {};
+  int             tinfo_len = sizeof(tinfo);
+  int const       fd        = con.sock.get_fd();
+
+  if (0 != safe_getsockopt(fd, IPPROTO_TCP, TCP_INFO, &tinfo, &tinfo_len)) {
+    Dbg(_dbg_ctl_socket_tcp_info, "failed getsockopt(%d, TCP_INFO): %s", fd, 
strerror(errno));
+    return false;
+  }
+
+  info.rtt      = tinfo.tcpi_rtt;
+  info.rttvar   = tinfo.tcpi_rttvar;
+  info.snd_cwnd = tinfo.tcpi_snd_cwnd;
+#if HAVE_STRUCT_TCP_INFO_TCPI_TOTAL_RETRANS
+  info.retrans = tinfo.tcpi_total_retrans;
+#elif HAVE_STRUCT_TCP_INFO___TCPI_RETRANS
+  // FreeBSD spells the cumulative count differently; __tcpi_retrans is the
+  // currently outstanding count, which is not what this reports.
+  info.retrans = tinfo.tcpi_snd_rexmitpack;
+#endif

Review Comment:
   Fixed in 909ee65539: CMake now probes `tcpi_snd_rexmitpack` directly, and 
both the outer feature guard and the FreeBSD field selection use 
`HAVE_STRUCT_TCP_INFO_TCPI_SND_REXMITPACK`.
   
   Verified the Linux build and checked the probe against the published FreeBSD 
14.3 header plus a negative fixture without that member. Native FreeBSD 
execution remains unverified; the AuTest remains Linux-only.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to