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