Hi,
I managed to implement my taprouter software into DOSemu (taprouter is my standalone project: http://www.viste-family.net/mateusz/software/taprouter )
It means that it's possible for users to get an internet connectivity
inside DOSemu that 'just works', without needing to play with bridges,
routing, nat, etc etc etc, and without having to run anything with root
privileges.
The only required actions are:
The DOSemu configuration file would need to be changed as follows:
$_vnet = "slirp"
$_netdev = "/usr/bin/slirp"
How does it work?
when the $_vnet="slirp" backend is used, DOSemu calls my
librouter_init() function, that creates a unix socket pair, and forks
itself. Since then, DOSemu uses a 'normal' dgram socket to tunnel
ethernet-level communications, thus from the DOSemu point of view, it's
almost identical to using a tun interface.
the librouter code handles all the ARP-level connectivity, DHCP requests
interception, SLIP encapsulation and DNS forwarding on its own, routing
all traffic for non-local destinations to the slirp executable
configured in $_netdev.
I hope I haven't broken anything in the process, but I believe I have
not, since my modifications on DOSemu are minimal (mostly recognizing
the new configuration file token, and adding a new 'VNET_TYPE_SLIRP'
case here and there.
99% of my modifications are inside new files, that I've put in a
dedicated directory in src/dosext/net/net/librouter
Do not hesitate to ask me should you have any questions, doubts, or
suggestions about improving the quality of this contribution.
Known bugs
It only works for udp/tcp traffic. this is a 'by design' limitation of
SLIRP, due to the fact that it uses unprivileged user sockets to emulate
a routed environment. This simply means that you won't be able to ping
anything from within DOSemu, but wget, htget, fdnpkg etc tools will work
just fine.
cheers,
Mateusz Viste
Here is a new version of the patch - I explicitely added GNU GPL headers to all new files.
I don't know how I did it, but it looks like at some point git reverted all my changes in /src/base/init/parser.c ... (and maybe others, don't know yet)... will redo all modifications and repost a patch very soon.
I am not in a hurry, and I won't test
them too soon anyway. :)
If you screwed up something, do
git reset --h origin/devel
to get the clean state, and then
git am your-patch.patch
to get everything back.
I have no idea what happened... but in the patches the parser.c file is also in its 'clean' state (without my modifications). It's okay in my 'hard' copy here, though: http://www.viste-family.net/mateusz/temp/dosemu-slirp/
Is by any chance src/base/init/parser.c computed automatically during the build process?
Ah, yes!
So you modify parser.y.in and lexer.l.in
Okay, that's a good thing to know then - I was starting to think that git is playing some nasty jokes on me :)
I modified the parser.y.in file and redone a new patch (hopefully this one is good now).
I created a "slirp" branch in git and
pushed your patch there with some changes.
So you can do the further work based on
that branch from now on.
that's cool, thanks! But I have to admit I don't really know what to do with this information :) Do I have to re-checkout the dosemu project from git, but specifying some special 'slirp' parameter?
git pull
git checkout slirp
got it. thanks!
Hello, I noticed you haven't patched one file in git: src/dosext/net/net/Makefile
This file is having such line:
CFILES = ipx.c ipxglt.c libpacket.c pktnew.c
altough in my patch, it has this:
CFILES = ipx.c ipxglt.c libpacket.c pktnew.c librouter/librouter.c
Also, I see now that during build, the building thing tries to find a Makefile in librouter/ - I guess you declared this new directory somewhere, and I should add a separate Makefile there, am I right?
I'm sorry for the trouble, I don't understand very well how the whole building process works yet.
Arr, I have forgot to do 'git add'. :)
Fixed now.
Now it makes more sense indeed.
However my building stops with such message:
lib/libdosext_net_net_librouter.a(librouter.o): In function
librouter_init': librouter.c:(.text+0x0): multiple definition of
librouter_init'lib/libdosext_net_net.a(librouter.o):librouter.c:(.text+0x0): first defined here
collect2: ld returned 1 exit status
I really have no clue what to do.. Could you tell me please what is wrong here? I understand that you transformed librouter into a static library, and that's nice, but why is the librouter_init() function appearing twice now - in the static libdosext_net_net_librouter.a AND in libdosext_net_net.a ? As I see it, it should not be present in the libdosext_net_net.a anymore, since this lib doesn't include librouter.c, but only a header of it (librouter.h) with prototypes..
make clean
autoconf
./default-configure -d
make -j 2
networking works again :) thanks!
Hi, I fixed a bug in librouter that was causing a dosemu instance to stay alive even after the user quited the visible dosemu instance, and I made librouter a bit more intelligent, so if the slirp executable is not configured (or not configured properly), it tries to fallback to any slirp in the $PATH.
I tried to recreate the slirp patch, and followed your instructions about git and amending commits, but it seems that I have done something wrong, because my 'amendment' was attached to one of your commits:
Could you please advise what I should do to make things straight?
If I understand correctly, my commits are not 'real' (as in svn), and are not landing anywhere on the repo, so I have to go through the 'creating a patch' procedure anyway, right?
Hi, you don't need to amend any more,
since the commits that were pushed to
remote, can no longer be amended.
Now you just need to create a small
patches on top of the "slirp" branch.
Okay, I understand the idea now. Any chance I could 'uncommit' my local amendment, without loosing my modifications in the process?
Probably not directly with git...
The simplest thing that comes to mind,
is to format-patch for your amended
commit, format-patch for the original
commit, and the do 'interdiff' on them.
Or maybe you actually can.
Try
git reset origin/slirp
Without --h it will not remove your changes.
this worked perfectly. thanks again :)
here I am attaching the newest patch (might be the last one, since it all seem to work pretty well now).
Looks like you forgot -a option
to git commit
right. done now - attaching the 'patch of the patch'.
Thanks, applied.
For the future, the changelog should be
written the following way in git:
short log msg
<empty line="">
full description
Hmm, I don't think I like your last patch.
Would it be possible to exit on EOF, instead
of PR_SET_PDEATHSIG?
Or, if you really need SIGHUP (why would you),
then you can use pty which sends sighup
automatically.
But I think EOF solution would be enough.
prctl() is something not to use on a regular
basis.