network protocol stacks in userspace

From: Maksim Yevmenkin <maksim.yevmenkin_at_gmail.com>
Date: Thu, 10 Jul 2008 09:47:58 -0700
hello,

i'd like to run an idea past the network gurus here. lets say i'd like
to implement a network protocol stack (or part of it) in user space.
however, i also want to have a socket interface so all the client
applications can simply use socket(), bind(), connect() etc. calls
just as they would with in-kernel stack.

so, one crazy idea is to implement "loop" socket layer that simply
loops all the requests back to userspace (similar to
tun/tap/fuse/etc.) so there would be another domain, PF_LOOP (or
PF_NULL) and possibly 3 or 4 pre-canned protocol families (i.e. one
for each STREAM, DGRAM, RAW and SEQPACKET protocol types) with
somewhat generic implementation. each pru_xxx request loops back to
user space in a form of an event/message. such events could be
completely synchronous (blocking connect(), accept(), read() etc.) or
asynchronous (non-blocking connect(), etc.). each "loop" socket will
have either no or very little pcb associated with it - it will just
the socket's state. from user space each "loop" socket will be
accessible using its file descriptor and regular socket api and via
/dev/loopsock device node (or possibly create device node for each
"loop" socket).

finally, client applications could simply

#define PF_NEW_DOMAIN         PF_LOOP
#define NEW_DOMAIN_PROTO      PF_PROTO_STREAM

s = socket(PF_NEW_DOMAIN, SOCK_STREAM, NEW_DOMAIN_PROTO);
bind(s, (struct sockaddr *) &sa, sizeof(sa));
...

so what do you guys think? am i way off base here? is there a better
way to do it?

oh, and one more thing, netgraph is out (sorry Julian :) i personally
think netgraph is very cool, but i need something different here.

thanks,
max
Received on Thu Jul 10 2008 - 15:16:22 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:32 UTC