summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2024-03-27 07:06:27 -0700
committerGitHub <noreply@github.com>2024-03-27 16:06:27 +0200
commite1425343ec6db0b5d7ed1665be547171cf5b1e4a (patch)
treeafdb860c823115b8f28469397f79c4e6936918d9
parent92c55f8165219dd28db62ceccf1e27b1c01c055c (diff)
apps_proc_pid_fd: ignore kf_sock_inpcb on modern FreeBSD (#17243)
In legacy versions TCP control block had a different pointer. In modern FreeBSD the generic inpcb and protocol specific pcb is the same pointer. For reference two FreeBSD commits: * merge inpcb with tcpcb e68b3792440cac248347afe08ba5881a00ba6523 * netstat(1) to use the new pointer 8e813d07c6804f80e1380b54f6e5fa6d34a3be52 and a test build to detect software that uses legacy pointer: * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277659
-rw-r--r--src/collectors/apps.plugin/apps_proc_pid_fd.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/collectors/apps.plugin/apps_proc_pid_fd.c b/src/collectors/apps.plugin/apps_proc_pid_fd.c
index 44c4274651..519b0794da 100644
--- a/src/collectors/apps.plugin/apps_proc_pid_fd.c
+++ b/src/collectors/apps.plugin/apps_proc_pid_fd.c
@@ -551,9 +551,11 @@ static bool read_pid_file_descriptors_per_os(struct pid_stat *p, void *ptr) {
switch (fds->kf_sock_domain) {
case AF_INET:
case AF_INET6:
+#if __FreeBSD_version < 1400074
if (fds->kf_sock_protocol == IPPROTO_TCP)
sprintf(fdsname, "socket: %d %lx", fds->kf_sock_protocol, fds->kf_un.kf_sock.kf_sock_inpcb);
else
+#endif
sprintf(fdsname, "socket: %d %lx", fds->kf_sock_protocol, fds->kf_un.kf_sock.kf_sock_pcb);
break;
case AF_UNIX: