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


##########
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:
   The FreeBSD branch is gated by `HAVE_STRUCT_TCP_INFO___TCPI_RETRANS`, but it 
reads the separate `tcpi_snd_rexmitpack` member. `CMakeLists.txt:771` only 
probes `__tcpi_retrans`, so a supported header variant can pass configuration 
and then fail to compile here; add a probe for the member actually used and 
include it in the feature guard.



-- 
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