My GSoC 2026 project is to implement udmabuf, which needs to pass
variable-length structures (flexible arrays) to the kernel. Neither FreeBSD's
native ioctl nor linuxkpi ioctl supports this well. Therefore, we plan to use
generic netlink, which natively supports flexible arrays.
The problem is that FreeBSD's netlink is asynchronous. It uses a taskqueue,
meaning the callback is not executed in the user's thread context. Because of
this, operations that depend on the user's process, such as translating an fd
to a file structure, cannot be implemented.
A similar issue was solved in Linux, see commit cd40b7d3983c
("[NET]: make netlink user -> kernel interface synchronious").
To solve this problem, this diff adds a sync path in nl_sosend and introduces
a new socket option NETLINK_SND_SYNC to turn it on.
And, the success of sync send() does not depend on whether the receive buffer is full. For example, if there is only room for 2 replies in the receive buffer but the user requests 5 messages in a single send(), the send() will still succeed and process all 5 messages. However, it will only queue 2 replies, drop the remaining 3, and record how many replies were dropped. The next recv() call will then return ENOBUFS.