Skip to content

Commit

Permalink
[freebsd] don't use kf_sock_inpcb on modern versions
Browse files Browse the repository at this point in the history
In FreeBSD 14 and after the generic internet protocol control block and
protocol specific (TCP) control block are the same pointer.  The latter
embeds the former.  The kf_sock_inpcb is planned for removal in FreeBSD
15.
  • Loading branch information
glebius committed Mar 23, 2024
1 parent e30113e commit 003c846
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/dialects/freebsd/dsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,14 @@ void process_socket(struct lsof_context *ctx, struct kinfo_file *kf,
}
}
enter_dev_ch(ctx,
print_kptr((KA_T)(kf->kf_un.kf_sock.kf_sock_inpcb
? kf->kf_un.kf_sock.kf_sock_inpcb
: kf->kf_un.kf_sock.kf_sock_pcb),
print_kptr((KA_T)(
#if __FreeBSD_version >= 1400074
kf->kf_un.kf_sock.kf_sock_pcb),
#else
kf->kf_un.kf_sock.kf_sock_inpcb
? kf->kf_un.kf_sock.kf_sock_inpcb
: kf->kf_un.kf_sock.kf_sock_pcb),
#endif
(char *)NULL, 0));
la = (unsigned char *)&local_addr6->sin6_addr;
lp = (int)ntohs(local_addr6->sin6_port);
Expand Down Expand Up @@ -509,9 +514,14 @@ void process_socket(struct lsof_context *ctx, struct kinfo_file *kf,
return;
}
enter_dev_ch(ctx,
print_kptr((KA_T)(kf->kf_un.kf_sock.kf_sock_inpcb
? kf->kf_un.kf_sock.kf_sock_inpcb
: kf->kf_un.kf_sock.kf_sock_pcb),
print_kptr((KA_T)(
#if __FreeBSD_version >= 1400074
kf->kf_un.kf_sock.kf_sock_pcb),
#else
kf->kf_un.kf_sock.kf_sock_inpcb
? kf->kf_un.kf_sock.kf_sock_inpcb
: kf->kf_un.kf_sock.kf_sock_pcb),
#endif
(char *)NULL, 0));
lp = (int)ntohs(local_addr->sin_port);
la = (unsigned char *)&local_addr->sin_addr;
Expand Down

0 comments on commit 003c846

Please sign in to comment.