问题
I have a user-space process (daemon) that communicates with a Network Kernel Extension using the "Kernel Control API" (https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/NKEConceptual/control/control.html)
Specifically, I have an NKE that is responsible for modifying the source address of sockets belonging to specific applications. However the NKE does not have all the information or abilities it needs - and often needs to communicate with a daemon process to perform other actions (such as finding paths associated with PIDs, and also adding firewall rules).
However, it seems the "kernel control api" is non-blocking -- but i need the NKE to block in a callback (such as the sf_bind()
callback) while it gathers the extra information or performs the actions in the daemon.
How do i implement this blocking communication with the daemon in my NKE using the Kernel Control API?
Basically I want to be able to halt the bind()
callback while the NKE requests an action from the daemon (via the kernel control api), and then only continue the bind()
callback after that information is received.
来源:https://stackoverflow.com/questions/57145678/how-to-have-synchronous-communication-between-kext-and-user-space-on-macos