The ROCK/UML Project

ROCK/UML Network Draft Guide

Anders Karlsson $Date: 2001/04/07 22:53:41 $

Below is a quick guide to how to get UML networking up and running on ROCK Linux. I have tested the following procedure and it works for me. There are caveats like permissions and ownership of /dev/misc/net/tun to remember, but that is covered in Lennerts HOWTO.

Files Needed

The files you need can be found at these places:

The NetFast diff for UML
Same NetFast diff for UML, but for the CVS 010407 drop umlnetfast2.4.2-010407.diff
The NetFast devfs diff for UML umlnetfast-devfs.diff
The tar-ball containing the bridge code
The tar-ball with the tuncfg command and the tun_patch for the kernel.
The patch for tuncfg.c to adhere to devfs path tuncfg-devfs.diff

To fetch the latest UML release via CVS, create a directory to keep it all in, cd into the directory and do the following:
cvs login
The password for anonymous is blank, so just press RETURN when it asks for a password.

There are three modules to check out, they are: 'linux', 'doc' and 'tools'.The command to check things out is as follows.
cvs -z3 co <modulename>

If you do not want the hassle of CVS, go to the UML download pages at where there is a 'Latest File Release' section where you can get both ready-compiled UML kernels and kernel-patches against stock kernel trees. If you want to do a spot of DIY, get the 'kernel patch'. Latest release on their pages is 0.39-2.4.2 from Feb., 24th which is for the 2.4.2 kernel.

UML Build Instructions

The paths and commands in the following instructions reflects my own environment, so you will have to amend it to suit your environment. To build a working UML executable, do the following.

cd to the project directory
cd /project/UML
Extract the kernel source
tar Ixf /project/sources/linux-2.4.0.tar.bz2
Patch it to 2.4.2
bzcat /project/sources/patch-2.4.1.bz2 | patch -p0
bzcat /project/sources/patch-2.4.2.bz2 | patch -p0
Copy in the stuff from the CVS repository
cp -Rf /project/UML/cvs/linux /project/UML/
cd into the UML kernel tree and apply the following patches
patch -p1 < /project/UML/backups/umlnetfast2.4.2-3.diff

--- linux/arch/um/drivers/eth_user_fast.c.orig  Thu Mar 22 20:38:16 2001
+++ linux/arch/um/drivers/eth_user_fast.c       Thu Mar 22 20:38:24 2001
@@ -74,7 +74,7 @@
        struct ifreq ifr;
        dprintk("do_connect [%p]\n", conn);
-       if ((fd = open("/dev/net/tun", O_RDWR)) < 0) {
+       if ((fd = open("/dev/misc/net/tun", O_RDWR)) < 0) {
                dprintk("do_connect 1 [%p]\n", conn);
                goto fail;

Then run these commands to create the UML executable itself.
make mrproper ARCH=um
cp /project/UML.config /project/UML/linux/.config
make dep ARCH=um
make linux ARCH=um

When finished, you have a 'linux' executable that you can copy to your test directory.
cp /project/UML/linux/linux /project/uml-test/

The Network Configuration

To create the correct bits in the network setup, you have to do the following. Extract the tun.tgz archive and apply the tun_patch to your 2.4 host kernel tree. It will only affect your tun.o module. (TUN/TAP device.) Recompile your modules and install them. Rebooting is not required unless you have it compiled in to the kernel or did not have it enabled at all.

Apply the following patch to tuncfg.c

--- tuncfg.c.orig       Thu Mar 22 21:02:45 2001
+++ tuncfg.c    Thu Mar 22 21:03:11 2001
@@ -23,7 +23,7 @@
        { 0 }
-#define TUN_NODE       "/dev/net/tun"
+#define TUN_NODE       "/dev/misc/net/tun"
 static char *dev    = NULL;
 static int  persist = -1;

Then compile it with 'gcc -o tuncfg tuncfg.c'

You then need the bridge-utils-0.9.2.tar.gz archive. Extract, and build according to instructions. You are really only after the brctl executable. You are now set for setting up the networking side. When you use tuncfg, remember that the device you create has to match the hostname in the UML you will start up, and the device in the UML you will configure. So the hostname uml0 and the device eth0 becomes uml0.eth0 - quite easy once you get the hang of it. :-) Also make sure that the user running the UML has R/W permissions to /dev/misc/net/tun. This is how I do it on my box.

brctl addbr br0
brctl setfd br0 4
brctl sethello br0 1
tuncfg -e -o anders -p uml0.eth0
brctl addif br0 uml0.eth0
ifconfig br0 up
ifconfig uml0.eth0 up

Boot the UML and issue the follwoing command inside the UML, 'ifconfig eth0 up'
Now ping the Host and jump for joy as it magically works. ;-)

According to the documentation I have read, you should be able to boot another UML and get it to talk to the Host and the first UML if you do the following on the Host.
tuncfg -e -o anders -p uml1.eth0
brctl addif br0 uml1.eth0
ifconfig uml1.eth0 up

And then in the second UML (with hostname uml1) you do the following.
ifconfig eth0 up

You should now from any of the UML's and the Host be able to ping anyone of the others. This is untested.

To Do List

ToDo List:

 o  Convert this document to DVI and PS.
 o  Tidy up this document to a more understandable level.
 o  Whatever you others can think of and make me agree to... ;-)