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
Gleb Smirnoff committed
Mar 27, 2024 at 07:06 UTC
e1425343ec6db0b5d7ed1665be547171cf5b1e4a
1 file changed
+2
src/collectors/apps.plugin/apps_proc_pid_fd.c
+2
@@ -551,9 +551,11 @@ static bool read_pid_file_descriptors_per_os(struct pid_stat *p, void *ptr) {
551
switch (fds->kf_sock_domain) {
552
case AF_INET:
553
case AF_INET6:
554
+#if __FreeBSD_version < 1400074
555
if (fds->kf_sock_protocol == IPPROTO_TCP)
556
sprintf(fdsname, "socket: %d %lx", fds->kf_sock_protocol, fds->kf_un.kf_sock.kf_sock_inpcb);
557
else
558
+#endif
559
sprintf(fdsname, "socket: %d %lx", fds->kf_sock_protocol, fds->kf_un.kf_sock.kf_sock_pcb);
560
break;
561
case AF_UNIX: