can a netfilter hook interact with userspace ?
I want to write a netfilter hook to do some specialized packet routing with greatest efficiency. However, the actions taken in my netfilter hook need to be driven by decisions made in a user process (ie which ports to forward, etc change based on knowledge only known to my user process).
By what means can my userspace program call into my netfilter hook to communicate this information?
Quoted 4 lines · Dave
By what means can my userspace program call into my netfilter hook to communicate this information?
You can use nf_register_sockopt/nf_unregister_sockopt to do so. See Sect 4.6. Writing New modules -> Receiving Commands From Userspace in the netfilter hacking how to. You can find an example in ip_tables.c.
If you don't like using getsocksopt/setsocksopt to pass information to kernel space, you could also use netlinks sockets.
regards,
Pablo