Project

General

Profile

Dynamic Uml Mesh Modeler » History » Version 16

Martin Willi, 14.10.2008 11:12

1 16 Martin Willi
2 16 Martin Willi
h1. Dynamic Uml Mesh Modeler
3 16 Martin Willi
4 16 Martin Willi
_Dumm_ is a framework to set up a virtual network using user mode linux guests.
5 1 Martin Willi
It cleverly glues together some nice technologies to build networks dynamically.
6 1 Martin Willi
To change the network topology, hosts are not required to reboot, changes apply
7 1 Martin Willi
instantly and configuration can be done on the host (no network connection
8 1 Martin Willi
required to change anything).
9 1 Martin Willi
10 1 Martin Willi
11 16 Martin Willi
h2. Status
12 16 Martin Willi
13 16 Martin Willi
_Dumm_ is experimental and [source:trunk/src/dumm in developement]. 
14 16 Martin Willi
Along with the _dumm_ library, two frontends are currently usable:
15 16 Martin Willi
** A graphical GTK client
16 16 Martin Willi
** A console client with Ruby bindings to script scenarios in Ruby
17 16 Martin Willi
18 10 Martin Willi
The graphical client is incomplete. It is missing:
19 16 Martin Willi
** Removal of added switches
20 16 Martin Willi
** Disconnecting guests from switches
21 16 Martin Willi
** Scenario management
22 1 Martin Willi
23 1 Martin Willi
The Ruby console client also misses a surrounding testing infrastructure which
24 1 Martin Willi
will be built with ruby in the near future.
25 1 Martin Willi
26 16 Martin Willi
27 16 Martin Willi
h2. Why UML?
28 16 Martin Willi
29 1 Martin Willi
UML is a senior in vitualization technologies, and there is a lot of new
30 1 Martin Willi
hyped stuff about virtualization around. However, UML is lightweight, easy to
31 1 Martin Willi
set up and allows dynamic reconfiguration (e.g. add/remove interfaces at
32 1 Martin Willi
runtime), allows access to the hosts filesystem through hostfs and has some
33 1 Martin Willi
other neat features.
34 1 Martin Willi
Performance is not critical for our needs, and maybe we get hardware
35 1 Martin Willi
virtualization support soon in UML.
36 1 Martin Willi
It is free and fits perfectly.
37 1 Martin Willi
38 1 Martin Willi
39 16 Martin Willi
h2. Requirements
40 1 Martin Willi
41 16 Martin Willi
** Host:
42 16 Martin Willi
**** Kernel:
43 16 Martin Willi
****** A recent 2.6 kernel
44 16 Martin Willi
****** "SKAS3 patch":http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/ recommended
45 16 Martin Willi
****** "FUSE":http://fuse.sourceforge.net/ enabled
46 16 Martin Willi
****** support for TAP devices
47 16 Martin Willi
**** Userland:
48 16 Martin Willi
****** [source:trunk/src/libstrongswan libstrongswan]
49 16 Martin Willi
****** libbridge from "bridge-utils":http://linux-net.osdl.org/index.php/Bridge
50 16 Martin Willi
****** using the GTK client:
51 16 Martin Willi
******** GTK+2 with developement headers
52 16 Martin Willi
******** Gnome VteTerminal with developement headers
53 16 Martin Willi
****** using the Ruby client:
54 16 Martin Willi
******** Ruby 1.8 with developement headers
55 16 Martin Willi
******** IRB
56 16 Martin Willi
** Guest:
57 16 Martin Willi
**** Kernel:
58 16 Martin Willi
****** hostfs
59 16 Martin Willi
****** tuntap networking
60 16 Martin Willi
****** our extended [source:trunk/src/dumm/patches mconsole exec patch]
61 16 Martin Willi
**** Userland:
62 16 Martin Willi
****** ip from iproute2
63 16 Martin Willi
64 16 Martin Willi
65 16 Martin Willi
h2. Architecture
66 16 Martin Willi
67 16 Martin Willi
68 16 Martin Willi
69 16 Martin Willi
h3. Working set
70 16 Martin Willi
71 1 Martin Willi
Dumm needs a directory to store all its files, guest configurations and other
72 1 Martin Willi
stuff. Inside that working directory, you'll find:
73 1 Martin Willi
74 16 Martin Willi
<pre>
75 1 Martin Willi
workingdir/      - root folder containing a set of hosts and scenarios
76 2 Martin Willi
  guests/        - contains all created guests
77 3 Martin Willi
    alice/       - subdirectory for host "alice"
78 1 Martin Willi
      alice/     - UML created folder (named umid) containing UML runtime files
79 1 Martin Willi
      mem        - memory configuration file (contains amount of guest memory in MB)
80 1 Martin Willi
      pid        - PID file if guest is running, handy to attach gdb to kernel
81 1 Martin Willi
      linux      - symlinked UML kernel this host uses
82 1 Martin Willi
      master/    - symlinked master root file system for this host
83 1 Martin Willi
      diff/      - copy-on-write overlay to master this host uses
84 1 Martin Willi
      union/     - mounted unified filesystem (master + diff + optional scenario)
85 1 Martin Willi
    bob/
86 10 Martin Willi
      ...        - same stuff as in alice
87 1 Martin Willi
  templates/     - contains all scenario templates
88 1 Martin Willi
    test1/       - a scenario folder
89 1 Martin Willi
      diff/      - copy-on-write overlays for each guest's union folder
90 1 Martin Willi
        alice/   - COW for alice
91 1 Martin Willi
        bob/     - COW for bob
92 16 Martin Willi
</pre>
93 1 Martin Willi
94 16 Martin Willi
95 16 Martin Willi
h3. Networking
96 16 Martin Willi
97 16 Martin Willi
Network connectivity is realized through tap devices. When creating a _eth0_
98 16 Martin Willi
network device on _alice_, a _alice-eth0_ tap device appears on the host. These
99 16 Martin Willi
are directly connected, when _alice_ sends traffic to _eth0_, it appears on the
100 16 Martin Willi
host at _alice-eth0_. You can see that as a small network segment (or just a
101 1 Martin Willi
cable), where these interfaces are attached directly.
102 1 Martin Willi
To build larger network segments, linux bridging on the host comes into play.
103 1 Martin Willi
Segments are created by creating a bridge (as with brctl), and then attaching
104 1 Martin Willi
our tap devices to that bridge. Routing can be done on a UML guest, or even on
105 1 Martin Willi
the host.
106 16 Martin Willi
This setup has some advantages over the _uml_switch_ solution. Bridging works
107 8 Tobias Brunner
more reliable in the kernel, and as we see every network interface on the host,
108 4 Martin Willi
we can sniff at every interface to get some clue what the guests are doing.
109 4 Martin Willi
110 16 Martin Willi
111 16 Martin Willi
h2. Howto
112 16 Martin Willi
113 1 Martin Willi
In this mini-howto, we build and boot a minimalistic debian guest on a ubuntu host.
114 1 Martin Willi
We do everything as root here to simplify things!
115 1 Martin Willi
116 16 Martin Willi
117 16 Martin Willi
h3. Host setup
118 16 Martin Willi
119 16 Martin Willi
** install required packages:
120 16 Martin Willi
<pre>
121 1 Martin Willi
aptitude install libfuse-dev libgtk2.0-dev libvte-dev ruby1.8-dev irb1.8
122 16 Martin Willi
</pre>
123 16 Martin Willi
** install libbridge:
124 16 Martin Willi
<pre>
125 1 Martin Willi
git clone git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/bridge-utils.git
126 1 Martin Willi
cd bridge-utils
127 1 Martin Willi
autoconf
128 1 Martin Willi
./configure
129 1 Martin Willi
cd libbridge
130 1 Martin Willi
make
131 1 Martin Willi
make install
132 16 Martin Willi
</pre>
133 16 Martin Willi
** Build and install strongSwan from SVN sources.
134 16 Martin Willi
<pre>
135 10 Martin Willi
svn co www.strongswan.org/ikev2/trunk strongswan
136 1 Martin Willi
cd strongswan
137 10 Martin Willi
less HACKING
138 1 Martin Willi
./autogen
139 1 Martin Willi
./configure --enable-dumm [other options]
140 1 Martin Willi
make
141 1 Martin Willi
make install
142 16 Martin Willi
</pre>
143 1 Martin Willi
144 16 Martin Willi
** Ubuntu kernels almost fit our needs, they have FUSE and TAP device support. However, 
145 1 Martin Willi
    SKAS3 mode is missing. Build your own kernel based on the 
146 16 Martin Willi
    "Ubuntu Howto":https://wiki.ubuntu.com/KernelCustomBuild, patched with the
147 16 Martin Willi
    "SKAS3 patch":http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/. SKAS3 is
148 10 Martin Willi
    not required, but guests run much faster with SKAS3 enabled on the host.
149 10 Martin Willi
150 16 Martin Willi
151 16 Martin Willi
h3. Guest master filesystem setup
152 16 Martin Willi
153 16 Martin Willi
** create a clean directory and a directory for our master filesystem in it:
154 16 Martin Willi
<pre>
155 10 Martin Willi
mkdir umldir
156 10 Martin Willi
cd umldir
157 10 Martin Willi
mkdir master
158 16 Martin Willi
</pre>
159 16 Martin Willi
** bootstrap a debian sid system into master:
160 16 Martin Willi
<pre>
161 1 Martin Willi
debootstrap sid master http://mirror.switch.ch/ftp/pub/debian/
162 16 Martin Willi
</pre>
163 16 Martin Willi
** enter chroot
164 16 Martin Willi
<pre>
165 10 Martin Willi
chroot master
166 16 Martin Willi
</pre>
167 16 Martin Willi
** enable login on tty0
168 16 Martin Willi
<pre>
169 10 Martin Willi
echo "0:2345:respawn:/sbin/getty 38400 tty0" >> /etc/inittab
170 10 Martin Willi
echo "tty0" >> /etc/securetty
171 16 Martin Willi
</pre>
172 16 Martin Willi
** Enable main repository
173 16 Martin Willi
<pre>
174 10 Martin Willi
echo deb http://mirror.switch.ch/ftp/pub/debian sid main contrib > /etc/apt/sources.list
175 4 Martin Willi
aptitude update
176 16 Martin Willi
</pre>
177 16 Martin Willi
** Install proper locales support
178 16 Martin Willi
<pre>
179 14 Martin Willi
aptitude install locales
180 1 Martin Willi
dpkg-reconfigure locales
181 16 Martin Willi
</pre>
182 16 Martin Willi
** Install some packages for strongSwan
183 16 Martin Willi
<pre>
184 1 Martin Willi
aptitude install libgmp3c2 libsqlite3-0 libcurl3 dropbear gdb binutils
185 16 Martin Willi
</pre>
186 16 Martin Willi
** leave chroot
187 16 Martin Willi
<pre>
188 4 Martin Willi
exit
189 16 Martin Willi
</pre>
190 16 Martin Willi
** build a vanilla UML kernel (using "my config":http://trac.strongswan.org/attachment/wiki/DynamicUmlMeshModeler/.config):
191 16 Martin Willi
<pre>
192 6 Martin Willi
wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.tar.bz2
193 10 Martin Willi
tar jxvf linux-2.6.27.tar.bz2
194 10 Martin Willi
cd linux-2.6.27
195 10 Martin Willi
make mrproper
196 11 Martin Willi
wget -O - http://trac.strongswan.org/browser/trunk/src/dumm/patches/mconsole-exec-2.6.27.patch?format=txt | patch -p1
197 10 Martin Willi
wget http://trac.strongswan.org/attachment/wiki/DynamicUmlMeshModeler/.config?format=raw -O .config
198 11 Martin Willi
ARCH=um make menuconfig
199 14 Martin Willi
ARCH=um make
200 16 Martin Willi
</pre>
201 11 Martin Willi
202 16 Martin Willi
203 16 Martin Willi
h3. Start a network
204 16 Martin Willi
205 16 Martin Willi
You'll have to run the tools as root. Make sure you have a DISPLAY set, e.g. by starting it under _sudo_.
206 16 Martin Willi
** Invoke the graphical client
207 16 Martin Willi
<pre>
208 10 Martin Willi
sudo ipsec dumm
209 16 Martin Willi
</pre>
210 10 Martin Willi
Add guests, select our master filesystem and the compiled kernel. Add a bridges and connect your guests to it.
211 10 Martin Willi
Start your guests and configure them. 
212 1 Martin Willi
213 16 Martin Willi
** Using the _irdumm_ ruby client
214 16 Martin Willi
<pre>
215 1 Martin Willi
sudo ipsec irdumm
216 1 Martin Willi
irb> sun = Guest.new("sun", "path/to/linux-2.6.27/linux", "path/to/master/", "mem=64M con0=xterm")
217 1 Martin Willi
irb> sun.start
218 1 Martin Willi
irb> sun.exec("echo sun > /etc/hostname")
219 1 Martin Willi
irb> sun.add("eth0").connect(Bridge.new("br0")).add("192.168.0.1")
220 1 Martin Willi
irb> sun.exec("ifconfig") { |line| puts line }
221 1 Martin Willi
irb> quit
222 16 Martin Willi
</pre>
223 1 Martin Willi
224 16 Martin Willi
225 16 Martin Willi
h2. Installing strongSwan on guests
226 16 Martin Willi
227 1 Martin Willi
As we have full access to the master filesystem on the host, we can build strongSwan on the host and install it to the guests
228 16 Martin Willi
<pre>
229 1 Martin Willi
cd path/to/strongswan/
230 1 Martin Willi
DESTDIR=/full/path/to/master make install
231 16 Martin Willi
</pre>