]> git.proxmox.com Git - pve-common.git/blob - test/etc_network_interfaces/t.create_network.pl
inotify: fix compatibillity with address + netmask separate passed
[pve-common.git] / test / etc_network_interfaces / t.create_network.pl
1 save('proc_net_dev', <<'/proc/net/dev');
2 eth0:
3 eth1:
4 eth2:
5 eth3:
6 eth4:
7 eth5:
8 /proc/net/dev
9
10 r(load('brbase'));
11
12 #
13 # Variables used for the various interfaces:
14 #
15
16 my $ip = '192.168.0.2/24';
17 my $gw = '192.168.0.1';
18 my $svcnodeip = '239.192.105.237';
19 my $physdev = 'eth0';
20 my $remoteip1 = '192.168.0.3';
21 my $remoteip2 = '192.168.0.4';
22
23 #
24 # Hunk for the default bridge of the 'brbase' configuration
25 #
26
27 my $vmbr0_part = <<"PART";
28 auto vmbr0
29 iface vmbr0 inet static
30 address 10.0.0.2/24
31 gateway 10.0.0.1
32 bridge-ports eth0
33 bridge-stp off
34 bridge-fd 0
35 PART
36 chomp $vmbr0_part;
37
38 #
39 # Configure eth1 statically, store its expected interfaces hunk in $eth1_part
40 # and test!
41 #
42
43 $config->{ifaces}->{eth1} = {
44 type => 'eth',
45 method => 'static',
46 address => $ip,
47 gateway => $gw,
48 families => ['inet'],
49 autostart => 1
50 };
51
52 my $eth1_part = <<"PART";
53 auto eth1
54 iface eth1 inet static
55 address $ip
56 gateway $gw
57 PART
58 chomp $eth1_part;
59
60 expect load('loopback') . <<"CHECK";
61 source-directory interfaces.d
62
63 iface eth0 inet manual
64
65 $eth1_part
66
67 iface eth2 inet manual
68
69 iface eth3 inet manual
70
71 iface eth4 inet manual
72
73 iface eth5 inet manual
74
75 $vmbr0_part
76
77 CHECK
78
79 #
80 # Add a bond for eth2 & 3 and check the new output
81 #
82
83 $config->{ifaces}->{bond0} = {
84 type => 'bond',
85 mtu => 1400,
86 slaves => 'eth2 eth3',
87 bond_mode => '802.3ad',
88 bond_xmit_hash_policy => 'layer3+4',
89 bond_miimon => 100,
90 method => 'manual',
91 families => ['inet'],
92 autostart => 1
93 };
94 my $bond0_part = <<"PART";
95 auto bond0
96 iface bond0 inet manual
97 bond-slaves eth2 eth3
98 bond-miimon 100
99 bond-mode 802.3ad
100 bond-xmit-hash-policy layer3+4
101 mtu 1400
102 PART
103 chomp $bond0_part;
104
105 expect load('loopback') . <<"CHECK";
106 source-directory interfaces.d
107
108 iface eth0 inet manual
109
110 $eth1_part
111
112 iface eth2 inet manual
113
114 iface eth3 inet manual
115
116 iface eth4 inet manual
117
118 iface eth5 inet manual
119
120 $bond0_part
121
122 $vmbr0_part
123
124 CHECK
125
126 #
127 # Add vxlan1 and 2
128 #
129
130 $config->{ifaces}->{vxlan1} = {
131 type => 'vxlan',
132 method => 'manual',
133 families => ['inet'],
134 'vxlan-id' => 1,
135 'vxlan-svcnodeip' => $svcnodeip,
136 'vxlan-physdev' => $physdev,
137 autostart => 1
138 };
139
140 $config->{ifaces}->{vxlan2} = {
141 type => 'vxlan',
142 method => 'manual',
143 families => ['inet'],
144 'vxlan-id' => 2,
145 'vxlan-local-tunnelip' => $ip,
146 autostart => 1
147 };
148
149 my $vxlan12_part = <<"PART";
150 auto vxlan1
151 iface vxlan1 inet manual
152 vxlan-id 1
153 vxlan-svcnodeip $svcnodeip
154 vxlan-physdev $physdev
155
156 auto vxlan2
157 iface vxlan2 inet manual
158 vxlan-id 2
159 vxlan-local-tunnelip $ip
160 PART
161 chomp $vxlan12_part;
162
163 expect load('loopback') . <<"CHECK";
164 source-directory interfaces.d
165
166 iface eth0 inet manual
167
168 $eth1_part
169
170 iface eth2 inet manual
171
172 iface eth3 inet manual
173
174 iface eth4 inet manual
175
176 iface eth5 inet manual
177
178 $bond0_part
179
180 $vmbr0_part
181
182 $vxlan12_part
183
184 CHECK
185
186 #
187 # Add vxlan3 and 3 bridges using vxlan1..3
188 #
189
190 $config->{ifaces}->{vmbr1} = {
191 mtu => 1400,
192 type => 'bridge',
193 method => 'manual',
194 families => ['inet'],
195 bridge_stp => 'off',
196 bridge_fd => 0,
197 bridge_ports => 'vxlan1',
198 bridge_vlan_aware => 'yes',
199 autostart => 1
200 };
201
202 $config->{ifaces}->{vmbr2} = {
203 type => 'bridge',
204 method => 'manual',
205 families => ['inet'],
206 bridge_stp => 'off',
207 bridge_fd => 0,
208 bridge_ports => 'vxlan2',
209 autostart => 1
210 };
211
212 $config->{ifaces}->{vmbr3} = {
213 type => 'bridge',
214 method => 'manual',
215 families => ['inet'],
216 bridge_stp => 'off',
217 bridge_fd => 0,
218 bridge_ports => 'vxlan3',
219 bridge_vlan_aware => 'yes',
220 bridge_vids => '2-10',
221 autostart => 1
222 };
223
224 my $vmbr123_part = <<"PART";
225 auto vmbr1
226 iface vmbr1 inet manual
227 bridge-ports vxlan1
228 bridge-stp off
229 bridge-fd 0
230 bridge-vlan-aware yes
231 bridge-vids 2-4094
232 mtu 1400
233
234 auto vmbr2
235 iface vmbr2 inet manual
236 bridge-ports vxlan2
237 bridge-stp off
238 bridge-fd 0
239
240 auto vmbr3
241 iface vmbr3 inet manual
242 bridge-ports vxlan3
243 bridge-stp off
244 bridge-fd 0
245 bridge-vlan-aware yes
246 bridge-vids 2-10
247 PART
248 chomp $vmbr123_part;
249
250 $config->{ifaces}->{vxlan3} = {
251 type => 'vxlan',
252 method => 'manual',
253 families => ['inet'],
254 'vxlan-id' => 3,
255 'vxlan-remoteip' => [$remoteip1, $remoteip2],
256 'bridge-access' => 3,
257 autostart => 1
258 };
259
260 my $vx = $config->{ifaces}->{vxlan2};
261 $vx->{'bridge-learning'} = 'off';
262 $vx->{'bridge-arp-nd-suppress'} = 'on';
263 $vx->{'bridge-unicast-flood'} = 'off';
264 $vx->{'bridge-multicast-flood'} = 'off';
265 my $vxlan123_part = $vxlan12_part ."\n" . <<"PART";
266 bridge-arp-nd-suppress on
267 bridge-learning off
268 bridge-multicast-flood off
269 bridge-unicast-flood off
270
271 auto vxlan3
272 iface vxlan3 inet manual
273 vxlan-id 3
274 vxlan-remoteip $remoteip1
275 vxlan-remoteip $remoteip2
276 bridge-access 3
277 PART
278 chomp $vxlan123_part;
279
280 expect load('loopback') . <<"CHECK";
281 source-directory interfaces.d
282
283 iface eth0 inet manual
284
285 $eth1_part
286
287 iface eth2 inet manual
288
289 iface eth3 inet manual
290
291 iface eth4 inet manual
292
293 iface eth5 inet manual
294
295 $bond0_part
296
297 $vmbr0_part
298
299 $vmbr123_part
300
301 $vxlan123_part
302
303 CHECK
304
305 #
306 # Now add vlans on all types of interfaces: vmbr1, bond0 and eth1
307 #
308
309 $config->{ifaces}->{'vmbr1.100'} = {
310 type => 'vlan',
311 mtu => 1300,
312 method => 'manual',
313 families => ['inet'],
314 autostart => 1
315 };
316
317 $config->{ifaces}->{'bond0.100'} = {
318 type => 'vlan',
319 mtu => 1300,
320 method => 'manual',
321 families => ['inet'],
322 'vlan-protocol' => '802.1ad',
323 autostart => 1
324 };
325
326 $config->{ifaces}->{'bond0.100.10'} = {
327 type => 'vlan',
328 mtu => 1300,
329 method => 'manual',
330 families => ['inet'],
331 autostart => 1
332 };
333
334 $config->{ifaces}->{'eth1.100'} = {
335 type => 'vlan',
336 mtu => 1400,
337 method => 'manual',
338 families => ['inet'],
339 autostart => 1
340 };
341
342 $config->{ifaces}->{'vmbr4'} = {
343 mtu => 1200,
344 type => 'bridge',
345 method => 'manual',
346 families => ['inet'],
347 bridge_stp => 'off',
348 bridge_fd => 0,
349 bridge_ports => 'bond0.100',
350 autostart => 1
351 };
352
353 $config->{ifaces}->{'vmbr5'} = {
354 mtu => 1100,
355 type => 'bridge',
356 method => 'manual',
357 families => ['inet'],
358 bridge_stp => 'off',
359 bridge_fd => 0,
360 bridge_ports => 'vmbr4.99',
361 autostart => 1
362 };
363
364 $config->{ifaces}->{vmbr6} = {
365 ovs_mtu => 1400,
366 type => 'OVSBridge',
367 ovs_ports => 'bond1 ovsintvlan',
368 method => 'manual',
369 families => ['inet'],
370 autostart => 1
371 };
372
373 $config->{ifaces}->{bond1} = {
374 ovs_mtu => 1300,
375 type => 'OVSBond',
376 ovs_bridge => 'vmbr6',
377 ovs_bonds => 'eth4 eth5',
378 ovs_options => 'bond_mode=active-backup',
379 method => 'manual',
380 families => ['inet'],
381 autostart => 1
382 };
383
384 $config->{ifaces}->{ovsintvlan} = {
385 ovs_mtu => 1300,
386 type => 'OVSIntPort',
387 ovs_bridge => 'vmbr6',
388 ovs_options => 'tag=14',
389 method => 'manual',
390 families => ['inet'],
391 autostart => 1
392 };
393
394 expect load('loopback') . <<"CHECK";
395 source-directory interfaces.d
396
397 iface eth0 inet manual
398
399 $eth1_part
400
401 iface eth2 inet manual
402
403 iface eth3 inet manual
404
405 iface eth4 inet manual
406
407 iface eth5 inet manual
408
409 auto eth1.100
410 iface eth1.100 inet manual
411 mtu 1400
412
413 allow-vmbr6 ovsintvlan
414 iface ovsintvlan inet manual
415 ovs_type OVSIntPort
416 ovs_bridge vmbr6
417 ovs_mtu 1300
418 ovs_options tag=14
419
420 $bond0_part
421
422 allow-vmbr6 bond1
423 iface bond1 inet manual
424 ovs_bonds eth4 eth5
425 ovs_type OVSBond
426 ovs_bridge vmbr6
427 ovs_mtu 1300
428 ovs_options bond_mode=active-backup
429
430 auto bond0.100
431 iface bond0.100 inet manual
432 mtu 1300
433 vlan-protocol 802.1ad
434
435 auto bond0.100.10
436 iface bond0.100.10 inet manual
437 mtu 1300
438
439 $vmbr0_part
440
441 $vmbr123_part
442
443 auto vmbr4
444 iface vmbr4 inet manual
445 bridge-ports bond0.100
446 bridge-stp off
447 bridge-fd 0
448 mtu 1200
449
450 auto vmbr5
451 iface vmbr5 inet manual
452 bridge-ports vmbr4.99
453 bridge-stp off
454 bridge-fd 0
455 mtu 1100
456
457 allow-ovs vmbr6
458 iface vmbr6 inet manual
459 ovs_type OVSBridge
460 ovs_ports bond1 ovsintvlan
461 ovs_mtu 1400
462
463 auto vmbr1.100
464 iface vmbr1.100 inet manual
465 mtu 1300
466
467 $vxlan123_part
468
469 CHECK
470
471 #
472 # Now check the new config for idempotency:
473 #
474
475 save('if', w());
476 r(load('if'));
477 expect load('if');
478
479 #
480 # Check a brbase with an ipv6 address on eth1
481 #
482
483 r(load('brbase'));
484
485 my $ip = 'fc05::2';
486 my $nm = '112';
487 my $gw = 'fc05::1';
488
489 $config->{ifaces}->{eth1} = {
490 type => 'eth',
491 method6 => 'static',
492 address6 => $ip,
493 netmask6 => $nm,
494 gateway6 => $gw,
495 families => ['inet6'],
496 autostart => 1
497 };
498
499 expect load('loopback') . <<"CHECK";
500 source-directory interfaces.d
501
502 iface eth0 inet manual
503
504 auto eth1
505 iface eth1 inet6 static
506 address $ip/$nm
507 gateway $gw
508
509 iface eth2 inet manual
510
511 iface eth3 inet manual
512
513 iface eth4 inet manual
514
515 iface eth5 inet manual
516
517 auto vmbr0
518 iface vmbr0 inet static
519 address 10.0.0.2/24
520 gateway 10.0.0.1
521 bridge-ports eth0
522 bridge-stp off
523 bridge-fd 0
524
525 CHECK
526
527 save('if', w());
528 r(load('if'));
529 expect load('if');
530
531 1;