Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jul 2008 09:47:58 -0700
From:      "Maksim Yevmenkin" <maksim.yevmenkin@gmail.com>
To:        freebsd-current@freebsd.org
Subject:   network protocol stacks in userspace
Message-ID:  <bb4a86c70807100947g5d4abff8w73fcdfca12fa384e@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bb4a86c70807100947g5d4abff8w73fcdfca12fa384e>