in_pcb.h contains the definition of struct xinpcb for use by userspace applications. While it does have some sections of the file that are #ifdef _KERNEL, there are many other kernel parts that are not guarded, for example the first block of includes has kernel epoch and locking headers. My expectation is that these should not be pulled in when compiling user space code that uses the struct xinpcb.
Thanks Nick, that's a correct observation and needs to be improved. If you have a patch that is ready and tested (passes buildworld at least, but better pass tinderbox) I can push with your name as author.
Created attachment 268732 [details] Suggested patch Sorry for the delay but here's a patch that works for me against main. I don't have tinderbox setup, but it passes buildworld and buildkernel
Thanks a lot, Nick! I will probably also collapse all kernel related stuff into single piece and commit after some testing.
Ok, so appeared to be not so trivial, given presence of _WANT_INPCB. And I really want to do it right rather than quick fix. Good news is that we have only once consumer of _WANT_INPCB left in the tree and I really want to remove it. I know there is also lsof outside of FreeBSD tree. But they will need to fix it themselves. We got all the APIs required to get data from kernel without going in there with dirty hands :) I'll do that this month, as I'm already in the inpcb area right now.
Sure, sounds good. Thanks!
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=041e9eb1ae094a81e55fbcaba37eb2ac194658cc commit 041e9eb1ae094a81e55fbcaba37eb2ac194658cc Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2026-03-12 18:02:27 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2026-03-12 18:32:30 +0000 inpcb: overhaul in_pcb.h Pull up all user-visible stuff to the top of the file and isolate the rest under _KERNEL. The user visible parts are: - struct in_conninfo - struct xinpcb - defines for inp_flags bits, that are shared between xinpcb and inpcb PR: 293493 sys/netinet/in_pcb.h | 477 +++++++++++++++++++++++++-------------------------- 1 file changed, 231 insertions(+), 246 deletions(-)
Done properly in the main branch. The change won't be merged to stable branches.