This document briefly introduces how to set up the virtual network and connect the subhurd with the main hurd.
1. Set up the virtual network.
1.1 Patch and install GNU Hurd, GNU Mach and the GNU C library.
Step 1: Get the Hurd and compile it.
cvs -z3 -d:pserver:email@example.com:/sources/hurd co -r zhengda-soc2008-virt-branch hurd
Step 2: apply the patch on the GNU Mach.
In order to connect the virtual network created in hurd with the external network, we need this patch. It enables the Hurd to set the Mach device into the promiscuous mode, so the real device can accept the packet that goes to the virtual device in hurd. (This step is optional if we are only interested in creating a internal virtual network.)
Step 3: apply the patch on glibc.
This patch enables the user to override the default socket server by using the environment variables SOCK_SERV_DIR or SOCK_SERV_%d (%d is the domain of the socket server).
1.2 Set up the Hurd components to build the virtual network.
In this section, I show how to create two virtual interfaces and run three pfinet servers. I assume that the source code of Hurd is in /root/hurd.
Step 4: create the network device file in /dev with devnode. The network device file is used to help other translators open the device.
# settrans -acfg /dev/eth0 /root/hurd/devnode/devnode eth0
Step 5: create the virtual network device with eth-multiplexer.
eth-multiplexer is responsible to create the virtual network device and dispatch the packet to the right clients that connect to the virtual device. It also connects the virtual network and the external network. Eth-multiplexer of the current version is a netfs translator and can create virtual devices and the device files dynamically, according to the request from the client.
# settrans -acfg /root/multiplexer /root/hurd/eth-multiplexer/eth-multiplexer -i /dev/eth0
Step 6: setup the filter translator eth-filter on the network device. This step is optional.
eth-filter is used by the user to force the traffic policy on the network device.
# settrans -acfg /dev/fveth0 /root/hurd/eth-filter/eth-filter -i /root/multiplexer/veth0 -S 192.168.8.0/24 -R 192.168.8.0/24 # settrans -acfg /dev/fveth1 /root/hurd/eth-filter/eth-filter -i /root/multiplexer/veth1 -S 192.168.8.0/24 -R 192.168.8.0/24
Step 7: setup the pfinet server on the virtual network device.
# settrans -afgc /root/socket0/2 /root/hurd/pfinet/pfinet -i /dev/fveth0 -a 192.168.8.10 -g 192.168.8.1 -m 255.255.255.0 # settrans -afgc /root/socket1/2 /root/hurd/pfinet/pfinet -i /dev/fveth1 -a 192.168.8.11 -g 192.168.8.1 -m 255.255.255.0
1.3 Run the command with the customized pfinet server.
Step 8: Set environment variables to use the customized pfinet server.
The environment variable of SOCK_SERV_DIR is used to override all socket servers and SOCK_SERV_%d to override a specific socket server. %d after SOCK_SERV_ is the domain of the protocol that the socket server supports. The environment variable SOCK_SERV_%d has the higher priority than SOCK_SERV_DIR.
# export SOCK_SERV_2=/root/socket1/2
If the modified glibc isn't installed as the system default C library, set LD_LIBRARY_PATH environment.
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/the/path/of/glibc
We can run any command now, for example, ping.
A SHELL script is provided to run all translators I mentioned automatically: http://www.assembla.com/spaces/VNetHurd/documents/c2W71ABser3AIxab7jnrAJ/download/runmultiplexer. To use this script, the user must specify the source of the hurd tree (the default value is /root/hurd) and the path of the servers (the default value is /root) where they should be created. This script is only used to test all translators I mentioned above and shows all steps to set up the virtual network.
2. Connect the subhurd with the main hurd.
In the main hurd, we still need to do Step 1-8. We run subhurd,
# /root/hurd/boot/boot -m eth0=/dev/fveth0 -m eth1=/dev/fveth1 servers.boot /dev/hd1s1
In the subhurd, we do Step 1, 4, 8. Step 4: # settrans -acfg /dev/veth0 /root/hurd/devnode/devnode -d veth0 Step 7: # settrans -afgc /servers/socket/2 /root/hurd/pfinet/pfinet -i /dev/veth0 -a 192.168.8.20 -g 192.168.8.1 -m 255.255.255.0
Now we can communicate from the subhurd with any pfinet server of the main Hurd that runs in the virtual network.