3 ms·
Netlink sockets in Linux input and output packed C structures. Doesn't get more efficient than that. Such an interface definitely doesn't have to be strings-onl
by c00lio 3y ago
Netlink sockets in Linux input and output packed C structures. Doesn't get more efficient than that. Such an interface definitely doesn't have to be strings-only. But of course, you cannot use it with just 'echo' in that case.
- codedokode 3y agoWhy not make real syscalls rather than emulate them using socket-like interface? Doesn't make much sense to me. For example, if you want to filter syscalls then it becomes more difficult (need to remember which type of socket it is, need to parse the structures and so on).
- c00lio 3y agoThe original idea for netlink sockets (where the name comes from) is to be able to do some network packet processing in userspace. E.g. to do stuff like virus-scanning on TCP connections. The situation there is exactly the opposite of a syscall, it is rather that the kernel calls into userspace to perform a helper function. Communication with the socket is still read()/write()/..., so there are still syscalls. The userspace program will do a read() to get the next struct+packet out of the socket. The modern, syscall-less interface for stuff would be io_uring. There, you do not need to read(), you can just get your data written into a userspace buffer that you can mwait or poll on.
- markhahn 3y ago/proc pseudofiles could have a mode (perhaps on open) that determines whether the protocol is ascii or packed/binary. there could even be a side-band interface that provides the packed schema (assuming not everything is exploded to atomic type-evident items).
- mike_hock 3y agoHow is that "simple and elegant" design going for you?
- naasking 3y agoPassing data in registers is more efficient, that's what you lose with serialization. Serialization gets you generality at the cost of some performance.
- c00lio 3y agoRight, registers are even faster.