Skip to content

Commit 003c846

Browse files
committed
[freebsd] don't use kf_sock_inpcb on modern versions
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.
1 parent e30113e commit 003c846

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

lib/dialects/freebsd/dsock.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,14 @@ void process_socket(struct lsof_context *ctx, struct kinfo_file *kf,
472472
}
473473
}
474474
enter_dev_ch(ctx,
475-
print_kptr((KA_T)(kf->kf_un.kf_sock.kf_sock_inpcb
476-
? kf->kf_un.kf_sock.kf_sock_inpcb
477-
: kf->kf_un.kf_sock.kf_sock_pcb),
475+
print_kptr((KA_T)(
476+
#if __FreeBSD_version >= 1400074
477+
kf->kf_un.kf_sock.kf_sock_pcb),
478+
#else
479+
kf->kf_un.kf_sock.kf_sock_inpcb
480+
? kf->kf_un.kf_sock.kf_sock_inpcb
481+
: kf->kf_un.kf_sock.kf_sock_pcb),
482+
#endif
478483
(char *)NULL, 0));
479484
la = (unsigned char *)&local_addr6->sin6_addr;
480485
lp = (int)ntohs(local_addr6->sin6_port);
@@ -509,9 +514,14 @@ void process_socket(struct lsof_context *ctx, struct kinfo_file *kf,
509514
return;
510515
}
511516
enter_dev_ch(ctx,
512-
print_kptr((KA_T)(kf->kf_un.kf_sock.kf_sock_inpcb
513-
? kf->kf_un.kf_sock.kf_sock_inpcb
514-
: kf->kf_un.kf_sock.kf_sock_pcb),
517+
print_kptr((KA_T)(
518+
#if __FreeBSD_version >= 1400074
519+
kf->kf_un.kf_sock.kf_sock_pcb),
520+
#else
521+
kf->kf_un.kf_sock.kf_sock_inpcb
522+
? kf->kf_un.kf_sock.kf_sock_inpcb
523+
: kf->kf_un.kf_sock.kf_sock_pcb),
524+
#endif
515525
(char *)NULL, 0));
516526
lp = (int)ntohs(local_addr->sin_port);
517527
la = (unsigned char *)&local_addr->sin_addr;

0 commit comments

Comments
 (0)