Hi, Can someone please explain why are netlink sockets a better communication method between kernel space and userspace ? I know that with IOCTLs we cannot send asynchronous messages to userspace from kernel, and with netlink we can. Are there more things to it? I once heard something about that when passing with IOCTL a pointer from userspace, you can mess it, by advancing it too much for example. But I am not sure. regards, Kevin
Kevin Wilson <wkevils@gmail.com> wrote:
Hi, Can someone please explain why are netlink sockets a better communication method between kernel space and userspace ?
It's been a long time since I thought about it but I think the primary issue is the abi ends up not being architecture independent unless you are very careful. A structure definition in source code does not map one-to-one with a memory layout. It varies based on the architecture and the compiler options. Specifically because compilers insert dead space between structure members to force proper word alignment, resolving the issue of a common abi that allows 32bit userspace to have the exact same structure layout as a 64bit kernel is problematic. It can be done, but I believe it was the source of a lot if bugs, so the community decided to simply discourage there use. (The main discussion about this was a long time ago, I hope I am remembering right.) Greg -- Sent from my Android phone with K-9 Mail. Please excuse my brevity.
On Sun, Sep 1, 2013 at 3:16 PM, Greg Freemyer <greg.freemyer@gmail.com> wrote:
Kevin Wilson <wkevils@gmail.com> wrote:
Hi, Can someone please explain why are netlink sockets a better communication method between kernel space and userspace ?
Another reason is to make things easier to extend. Adding a parameter to a netlink message is as easy as adding an additional netlink attribute. User space applications that has not been updated to support your change, will not see this parameter as it is unknown to them when processing the attributes. Extending an ioctl would mean adding new paramteres to the struct that is passed to/from the kernel, which will cause all kinds of problems. For example, how to avoid overflows when returning it to user space. -Kristian
On Mon, Sep 2, 2013 at 1:30 AM, Kristian Evensen <kristian.evensen@gmail.com
wrote:
On Sun, Sep 1, 2013 at 3:16 PM, Greg Freemyer <greg.freemyer@gmail.com> wrote:
Kevin Wilson <wkevils@gmail.com> wrote:
Hi, Can someone please explain why are netlink sockets a better communication method between kernel space and userspace ?
Another reason is to make things easier to extend. Adding a parameter to a netlink message is as easy as adding an additional netlink attribute. User space applications that has not been updated to support your change, will not see this parameter as it is unknown to them when processing the attributes. Extending an ioctl would mean adding new paramteres to the struct that is passed to/from the kernel, which will cause all kinds of problems. For example, how to avoid overflows when returning it to user space.
-Kristian
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi, This should give you a lot of insight http://people.ee.ethz.ch/~arkeller/linux/kernel_user_space_howto.html - Rohan
participants (4)
-
Greg Freemyer -
Kevin Wilson -
Kristian Evensen -
Rohan Puri