Project

General

Profile

Dynamic Uml Mesh Modeler » History » Version 29

Tobias Brunner, 12.09.2018 15:56

1 16 Martin Willi
h1. Dynamic Uml Mesh Modeler
2 16 Martin Willi
3 29 Tobias Brunner
---
4 29 Tobias Brunner
> *Note:* The Dumm framework was removed with version:5.7.0. This information is provided for historical reasons only.
5 29 Tobias Brunner
---
6 29 Tobias Brunner
7 16 Martin Willi
_Dumm_ is a framework to set up a virtual network using user mode linux guests.
8 1 Martin Willi
It cleverly glues together some nice technologies to build networks dynamically.
9 1 Martin Willi
To change the network topology, hosts are not required to reboot, changes apply
10 1 Martin Willi
instantly and configuration can be done on the host (no network connection
11 1 Martin Willi
required to change anything).
12 1 Martin Willi
13 1 Martin Willi
14 16 Martin Willi
h2. Status
15 1 Martin Willi
16 17 Tobias Brunner
_Dumm_ is experimental and in development (see source:src/dumm). 
17 16 Martin Willi
Along with the _dumm_ library, two frontends are currently usable:
18 17 Tobias Brunner
* A graphical GTK client
19 17 Tobias Brunner
* A console client with Ruby bindings to script scenarios in Ruby
20 16 Martin Willi
21 10 Martin Willi
The graphical client is incomplete. It is missing:
22 17 Tobias Brunner
* Removal of added switches
23 17 Tobias Brunner
* Disconnecting guests from switches
24 17 Tobias Brunner
* Scenario management
25 1 Martin Willi
26 1 Martin Willi
The Ruby console client also misses a surrounding testing infrastructure which
27 1 Martin Willi
will be built with ruby in the near future.
28 1 Martin Willi
29 16 Martin Willi
30 16 Martin Willi
h2. Why UML?
31 16 Martin Willi
32 1 Martin Willi
UML is a senior in vitualization technologies, and there is a lot of new
33 1 Martin Willi
hyped stuff about virtualization around. However, UML is lightweight, easy to
34 1 Martin Willi
set up and allows dynamic reconfiguration (e.g. add/remove interfaces at
35 1 Martin Willi
runtime), allows access to the hosts filesystem through hostfs and has some
36 1 Martin Willi
other neat features.
37 1 Martin Willi
Performance is not critical for our needs, and maybe we get hardware
38 1 Martin Willi
virtualization support soon in UML.
39 1 Martin Willi
It is free and fits perfectly.
40 1 Martin Willi
41 1 Martin Willi
42 16 Martin Willi
h2. Requirements
43 1 Martin Willi
44 17 Tobias Brunner
* Host:
45 17 Tobias Brunner
** Kernel:
46 17 Tobias Brunner
*** A recent 2.6 kernel
47 17 Tobias Brunner
*** "SKAS3 patch":http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/ recommended
48 17 Tobias Brunner
*** "FUSE":http://fuse.sourceforge.net/ enabled
49 17 Tobias Brunner
*** support for TAP devices
50 17 Tobias Brunner
** Userland:
51 17 Tobias Brunner
*** [[libstrongswan]]
52 17 Tobias Brunner
*** libbridge from "bridge-utils":http://linux-net.osdl.org/index.php/Bridge
53 17 Tobias Brunner
*** using the GTK client:
54 17 Tobias Brunner
**** GTK+2 with developement headers
55 17 Tobias Brunner
**** Gnome VteTerminal with developement headers
56 17 Tobias Brunner
*** using the Ruby client:
57 17 Tobias Brunner
**** Ruby 1.8 with developement headers
58 17 Tobias Brunner
**** IRB
59 17 Tobias Brunner
* Guest:
60 17 Tobias Brunner
** Kernel:
61 17 Tobias Brunner
*** hostfs
62 17 Tobias Brunner
*** tuntap networking
63 17 Tobias Brunner
*** our extended mconsole exec patch (see source:src/dumm/patches)
64 17 Tobias Brunner
** Userland:
65 17 Tobias Brunner
*** ip from iproute2
66 16 Martin Willi
67 16 Martin Willi
68 16 Martin Willi
h2. Architecture
69 16 Martin Willi
70 16 Martin Willi
71 16 Martin Willi
72 16 Martin Willi
h3. Working set
73 16 Martin Willi
74 1 Martin Willi
Dumm needs a directory to store all its files, guest configurations and other
75 1 Martin Willi
stuff. Inside that working directory, you'll find:
76 1 Martin Willi
77 16 Martin Willi
<pre>
78 1 Martin Willi
workingdir/      - root folder containing a set of hosts and scenarios
79 2 Martin Willi
  guests/        - contains all created guests
80 3 Martin Willi
    alice/       - subdirectory for host "alice"
81 1 Martin Willi
      alice/     - UML created folder (named umid) containing UML runtime files
82 19 Martin Willi
      args       - additional arguments to pass to guest, such as memory configuration
83 1 Martin Willi
      pid        - PID file if guest is running, handy to attach gdb to kernel
84 1 Martin Willi
      linux      - symlinked UML kernel this host uses
85 1 Martin Willi
      master/    - symlinked master root file system for this host
86 1 Martin Willi
      diff/      - copy-on-write overlay to master this host uses
87 1 Martin Willi
      union/     - mounted unified filesystem (master + diff + optional scenario)
88 1 Martin Willi
    bob/
89 10 Martin Willi
      ...        - same stuff as in alice
90 1 Martin Willi
  templates/     - contains all scenario templates
91 1 Martin Willi
    test1/       - a scenario folder
92 1 Martin Willi
      diff/      - copy-on-write overlays for each guest's union folder
93 1 Martin Willi
        alice/   - COW for alice
94 1 Martin Willi
        bob/     - COW for bob
95 1 Martin Willi
</pre>
96 16 Martin Willi
97 16 Martin Willi
98 16 Martin Willi
h3. Networking
99 16 Martin Willi
100 16 Martin Willi
Network connectivity is realized through tap devices. When creating a _eth0_
101 1 Martin Willi
network device on _alice_, a _alice-eth0_ tap device appears on the host. These
102 1 Martin Willi
are directly connected, when _alice_ sends traffic to _eth0_, it appears on the
103 1 Martin Willi
host at _alice-eth0_. You can see that as a small network segment (or just a
104 1 Martin Willi
cable), where these interfaces are attached directly.
105 1 Martin Willi
To build larger network segments, linux bridging on the host comes into play.
106 1 Martin Willi
Segments are created by creating a bridge (as with brctl), and then attaching
107 1 Martin Willi
our tap devices to that bridge. Routing can be done on a UML guest, or even on
108 16 Martin Willi
the host.
109 1 Martin Willi
This setup has some advantages over the _uml_switch_ solution. Bridging works
110 8 Tobias Brunner
more reliable in the kernel, and as we see every network interface on the host,
111 16 Martin Willi
we can sniff at every interface to get some clue what the guests are doing.
112 1 Martin Willi
113 1 Martin Willi
114 17 Tobias Brunner
h2. HowTo
115 16 Martin Willi
116 1 Martin Willi
In this mini-howto, we build and boot a minimalistic debian guest on a ubuntu host.
117 1 Martin Willi
We do everything as root here to simplify things!
118 16 Martin Willi
119 1 Martin Willi
120 16 Martin Willi
h3. Host setup
121 1 Martin Willi
122 25 Tobias Brunner
* Install required packages: <pre>
123 28 Andreas Steffen
apt-get install libfuse-dev libgtk2.0-dev libvte-dev ruby ruby1.8-dev irb1.8
124 1 Martin Willi
</pre>
125 17 Tobias Brunner
126 25 Tobias Brunner
* Install libbridge manually: <pre>
127 1 Martin Willi
git clone git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/bridge-utils.git
128 1 Martin Willi
cd bridge-utils
129 1 Martin Willi
autoconf
130 1 Martin Willi
./configure
131 1 Martin Willi
cd libbridge
132 18 Martin Willi
gcc -fPIC -c libbridge_devif.c libbridge_if.c libbridge_init.c libbridge_misc.c
133 18 Martin Willi
ar rcs libbridge.a libbridge_devif.o libbridge_if.o libbridge_init.o libbridge_misc.o
134 18 Martin Willi
ranlib libbridge.a
135 18 Martin Willi
install libbridge.a /usr/local/lib
136 18 Martin Willi
install libbridge.h /usr/local/include
137 10 Martin Willi
</pre>
138 17 Tobias Brunner
139 17 Tobias Brunner
* Build and install strongSwan from Git sources: <pre>
140 17 Tobias Brunner
git clone http://git.strongswan.org/strongswan.git
141 1 Martin Willi
cd strongswan
142 16 Martin Willi
less HACKING
143 1 Martin Willi
./autogen
144 16 Martin Willi
./configure --enable-dumm [other options]
145 1 Martin Willi
make
146 1 Martin Willi
make install
147 1 Martin Willi
</pre>
148 16 Martin Willi
149 17 Tobias Brunner
* Ubuntu kernels almost fit our needs, they have FUSE and TAP device support. However, SKAS3 mode is missing. Build your own kernel based on the "Ubuntu Howto":https://wiki.ubuntu.com/KernelCustomBuild, patched with the "SKAS3 patch":http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/. SKAS3 is not required, but guests run much faster with SKAS3 enabled on the host.
150 10 Martin Willi
151 10 Martin Willi
152 16 Martin Willi
h3. Guest master filesystem setup
153 16 Martin Willi
154 25 Tobias Brunner
* Create a clean directory and a directory for our master filesystem in it: <pre>
155 16 Martin Willi
mkdir umldir
156 10 Martin Willi
cd umldir
157 10 Martin Willi
mkdir master
158 16 Martin Willi
</pre>
159 17 Tobias Brunner
160 1 Martin Willi
* Bootstrap a debian sid system into master: <pre>
161 28 Andreas Steffen
apt-get install debootstrap
162 16 Martin Willi
debootstrap sid master http://mirror.switch.ch/ftp/pub/debian/
163 22 Martin Willi
</pre>To build a x86 guest on a x64 host, use the --arch option.
164 17 Tobias Brunner
165 25 Tobias Brunner
* Enter chroot <pre>
166 16 Martin Willi
chroot master
167 16 Martin Willi
</pre>
168 17 Tobias Brunner
169 17 Tobias Brunner
* Enable main repository <pre>
170 4 Martin Willi
echo deb http://mirror.switch.ch/ftp/pub/debian sid main contrib > /etc/apt/sources.list
171 23 Tobias Brunner
apt-get update
172 16 Martin Willi
</pre>
173 17 Tobias Brunner
174 17 Tobias Brunner
* Install proper locales support <pre>
175 23 Tobias Brunner
apt-get install locales
176 16 Martin Willi
dpkg-reconfigure locales
177 16 Martin Willi
</pre>
178 17 Tobias Brunner
179 20 Martin Willi
* For Ubuntu lucid guests, you'll have to specify the locales before generating them: <pre>
180 20 Martin Willi
echo "en_US.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local
181 20 Martin Willi
</pre>
182 20 Martin Willi
183 17 Tobias Brunner
* Install some packages for strongSwan <pre>
184 23 Tobias Brunner
apt-get install libgmp3c2 libsqlite3-0 libcurl3 dropbear gdb binutils
185 16 Martin Willi
</pre>
186 1 Martin Willi
187 28 Andreas Steffen
* Remove the root password by deleting the asterisk in /etc/shadow <pre>
188 28 Andreas Steffen
grep root /etc/shadow
189 28 Andreas Steffen
root:*:15173:0:99999:7:::
190 28 Andreas Steffen
vi /etc/shadow
191 28 Andreas Steffen
grep root /etc/shadow
192 28 Andreas Steffen
root::15173:0:99999:7:::
193 28 Andreas Steffen
</pre>
194 28 Andreas Steffen
195 16 Martin Willi
* Leave chroot <pre>
196 16 Martin Willi
exit
197 1 Martin Willi
</pre>
198 1 Martin Willi
199 28 Andreas Steffen
h3. Build a UML guest kernel
200 28 Andreas Steffen
201 28 Andreas Steffen
<pre>
202 27 Andreas Steffen
git clone git://git.strongswan.org/linux-dumm.git
203 27 Andreas Steffen
cd linux-dumm
204 27 Andreas Steffen
git checkout -b uml-ha-2.6.39 uml-ha-2.6.39
205 27 Andreas Steffen
wget http://download.strongswan.org/uml/config-2.6.39
206 27 Andreas Steffen
mv config-2.6.39 .config
207 27 Andreas Steffen
make linux ARCH=um SUBARCH=i386
208 25 Tobias Brunner
</pre>
209 25 Tobias Brunner
210 16 Martin Willi
211 16 Martin Willi
h3. Start a network
212 16 Martin Willi
213 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_.
214 17 Tobias Brunner
215 17 Tobias Brunner
* Invoke the graphical client <pre>
216 16 Martin Willi
sudo ipsec dumm
217 10 Martin Willi
</pre>
218 1 Martin Willi
Add guests, select our master filesystem and the compiled kernel. Add a bridges and connect your guests to it.
219 10 Martin Willi
Start your guests and configure them. 
220 1 Martin Willi
221 16 Martin Willi
* Using the _irdumm_ ruby client <pre>
222 17 Tobias Brunner
sudo ipsec irdumm
223 21 Martin Willi
irb> sun = Guest.new("sun", "path/to/linux-2.6.27/linux", "path/to/master/", "mem=64M con1=xterm")
224 1 Martin Willi
irb> sun.start
225 1 Martin Willi
irb> sun.exec("echo sun > /etc/hostname")
226 1 Martin Willi
irb> sun.add("eth0").connect(Bridge.new("br0")).add("192.168.0.1")
227 1 Martin Willi
irb> sun.exec("ifconfig") { |line| puts line }
228 1 Martin Willi
irb> quit
229 16 Martin Willi
</pre>
230 1 Martin Willi
231 16 Martin Willi
232 16 Martin Willi
h2. Installing strongSwan on guests
233 16 Martin Willi
234 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
235 16 Martin Willi
<pre>
236 1 Martin Willi
cd path/to/strongswan/
237 1 Martin Willi
DESTDIR=/full/path/to/master make install
238 16 Martin Willi
</pre>
239 24 Martin Willi
240 24 Martin Willi
h2. Troubleshooting
241 24 Martin Willi
242 24 Martin Willi
h3. The kernel cant find _init_, but it's there!?
243 24 Martin Willi
244 26 Martin Willi
Double check you are using the same architecture for kernel and filesystem. A i386 kernel can't boot a x64 init, and it currently does not work vice-versa, either. Pass the ARCH/SUBARCH variables after _make_, otherwise they get ignored!
245 24 Martin Willi
246 24 Martin Willi
h3. Debugging with gdb inside a x64 UML guest fails with an Input/Output error!
247 24 Martin Willi
248 24 Martin Willi
This is a known issue, but has not yet been solved.
249 24 Martin Willi
250 24 Martin Willi
h3. I'm using a maverick i386 guest on a x64 host, but condition variables behave strangely.
251 24 Martin Willi
252 24 Martin Willi
This is a known issue, somehow related to eglibc version. Threads waiting in condvars don't get
253 1 Martin Willi
wakened up while signaled. Not yet solved.
254 26 Martin Willi
255 26 Martin Willi
h3. Unix sockets created in the guest through hostfs are inaccessible in the guest.
256 26 Martin Willi
257 26 Martin Willi
Looks like an issue with hostfs, not yet solved. Creating Unix Sockets on an in-guest mounted tmpfs should work.