[zeromq-dev] kzmq - zmq sockets for Linux kernel modules

Michael Haberler mail17 at mah.priv.at
Mon Oct 8 11:45:08 CEST 2012

I created some basic support for 0MQ sockets in Linux kernel modules: http://git.mah.priv.at/gitweb/kzmq.git

- Michael

--- README ---
kzmq - 0MQ sockets for Linux kernel modules

This is a first cut of a kernel-level implementation of ZMQ
sockets. It serves a limited purpose - to enable kernel modules to act
as 0MQ sockets (TCP only) - it is NOT a general socket implementation
for the linux kernel.


The kzmq module implements a ZMQ REQ socket which connects to a
userland REP listener. You need pyzmq installed for the userland

runnning the example:
$ make
$ python userland.py &
$ ./load
$ dmesg
$ ./unload

- bring function naming more in line with czmq
- the debug output is naive - strings assumed
- reconnect on failure is not yet automatic
- tested on 2.6.32-32-generic only as of now

Parts reused:

ksocket library: 
by song.xian-guang at hotmail.com 

sp_encoder, sp_decoder: 
by Martin Sustrik and Martin Lucina

Michael Haberler fecit A.D. 2012

Unix domain sockets:
I tried Unix domain sockets, and they work in principle; however,
there's one scenario I'm unable to resolve and which make Unix domain
sockets pretty much unusable for this purpose:

- userland server binds ipc://tmp/foo , which creates the socket path '/tmp/foo'
- kmod loaded, connects to '/tmp/foo', interaction fine
- I unload the kmod AND '/tmp/foo' --> gets unlinked <---, preventing other clients to connect to server
- kmod loaded again: complains about '/tmp/foo' ENOENT - of course, since the unload unlinked it :-/

obviously this has to do with ownership of the socket created in the
module, and a cleanup routine called on the socket when the module
gets unloaded; I'd like to prevent the kmod unlinking the socket path,
but I dont get it how, and actually why it does that - it shouldnt be
its business in the first place since it didnt bind() it.

More information about the zeromq-dev mailing list