[Slirp] VDE convergence to liblisrp

Renzo Davoli renzo at cs.unibo.it
Mon Dec 30 19:40:55 UTC 2019


Hi Michael,

On Mon, Dec 30, 2019 at 09:19:45PM +0300, Michael Tokarev wrote:
> 30.12.2019 21:04, Renzo Davoli wrote:
> > More precisely I have implemented:
> > * libvdeslirp(3): a library that makes extremely simple to write Linux tools using (your) libslirp.
> >   libvdeslirp:
> > 	- provides a simple way to set up a default configuration (that fits 90% of common usages)
> >   - starts a thread for the stack management, taking care of the pollfd array, timers (those
> >     used for ipv6's router advertisements)
> >   - in short it is almost a drop-in replacements for tools using tuntap. Just use vdeslirp_init to
> >     open the stream, vdeslirp_send/vdeslirp_recv to send (virtual) ethernet packets, vdeslirp_fd
> >     provides a file descriptor for poll/select and vdeslirp_close teminates the service.
> >     (the library can manage several slirp instances concurrently if needed).
> 
> Can't this be implemented within slirp itself, to avoid making wrappers?
> Something like slirp_start_easy() :)
> I think this makes at least some sense..
I agree with you for what concerns the "default configuration" issue:
libvdeslirp's function:
vdeslirp_{init,setvprefix,setvprefix6} are just helper functions to fill in the SlirpConfig structure.
Either libslirp or libvdeslirp can provide these functions, it does not matter.

On the contrary the API including vdeslirp_{open,send,recv,fd,close} implements
another layer on libslirp.

Would libslirp and libvdeslirp source code be merged in one library they should 
still provide two different include files.
In fact either a program uses the libslirp layer (calls and callbacks for a main event loop)
or it uses the libvdeslirp layer providing a daemon which takes care of the emulated stack
and exposes a "stream of packets" interface.

Special care must be taken to avoid race conditions, e.g. a program using libvdeslirp cannot call
a function like slirp_add_hostfwd of the libslirp layer because it changes a data structure 
concurrently used by the daemon.

renzo


More information about the Slirp mailing list