Skip to content

Commit 5fea8bb

Browse files
vladimirolteandavem330
authored andcommitted
selftests: net: local_termination: introduce new tests which capture VLAN behavior
Add more coverage to the local termination selftest as follows: - 8021q upper of $h2 - 8021q upper of $h2, where $h2 is a port of a VLAN-unaware bridge - 8021q upper of $h2, where $h2 is a port of a VLAN-aware bridge - 8021q upper of VLAN-unaware br0, which is the upper of $h2 - 8021q upper of VLAN-aware br0, which is the upper of $h2 Especially the cases with traffic sent through the VLAN upper of a VLAN-aware bridge port will be immediately relevant when we will start transmitting PTP packets as an additional kind of traffic. Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5b8e741 commit 5fea8bb

File tree

1 file changed

+110
-7
lines changed

1 file changed

+110
-7
lines changed

tools/testing/selftests/net/forwarding/local_termination.sh

Lines changed: 110 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4-
ALL_TESTS="standalone vlan_unaware_bridge vlan_aware_bridge"
4+
ALL_TESTS="standalone vlan_unaware_bridge vlan_aware_bridge test_vlan \
5+
vlan_over_vlan_unaware_bridged_port vlan_over_vlan_aware_bridged_port \
6+
vlan_over_vlan_unaware_bridge vlan_over_vlan_aware_bridge"
57
NUM_NETIFS=2
68
PING_COUNT=1
79
REQUIRE_MTOOLS=yes
@@ -231,6 +233,30 @@ h2_destroy()
231233
simple_if_fini $h2 $H2_IPV4/24 $H2_IPV6/64
232234
}
233235

236+
h1_vlan_create()
237+
{
238+
simple_if_init $h1
239+
vlan_create $h1 100 v$h1 $H1_IPV4/24 $H1_IPV6/64
240+
}
241+
242+
h1_vlan_destroy()
243+
{
244+
vlan_destroy $h1 100
245+
simple_if_fini $h1
246+
}
247+
248+
h2_vlan_create()
249+
{
250+
simple_if_init $h2
251+
vlan_create $h2 100 v$h2 $H2_IPV4/24 $H2_IPV6/64
252+
}
253+
254+
h2_vlan_destroy()
255+
{
256+
vlan_destroy $h2 100
257+
simple_if_fini $h2
258+
}
259+
234260
bridge_create()
235261
{
236262
local vlan_filtering=$1
@@ -241,14 +267,10 @@ bridge_create()
241267

242268
ip link set $h2 master br0
243269
ip link set $h2 up
244-
245-
simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64
246270
}
247271

248272
bridge_destroy()
249273
{
250-
simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64
251-
252274
ip link del br0
253275
}
254276

@@ -272,7 +294,7 @@ standalone()
272294
h2_create
273295
macvlan_create $h2
274296

275-
run_test $h1 $h2
297+
run_test $h1 $h2 "$h2"
276298

277299
macvlan_destroy
278300
h2_destroy
@@ -285,11 +307,13 @@ test_bridge()
285307

286308
h1_create
287309
bridge_create $vlan_filtering
310+
simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64
288311
macvlan_create br0
289312

290-
run_test $h1 br0
313+
run_test $h1 br0 "vlan_filtering=$vlan_filtering bridge"
291314

292315
macvlan_destroy
316+
simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64
293317
bridge_destroy
294318
h1_destroy
295319
}
@@ -304,6 +328,85 @@ vlan_aware_bridge()
304328
test_bridge 1
305329
}
306330

331+
test_vlan()
332+
{
333+
h1_vlan_create
334+
h2_vlan_create
335+
macvlan_create $h2.100
336+
337+
run_test $h1.100 $h2.100 "VLAN upper"
338+
339+
macvlan_destroy
340+
h2_vlan_destroy
341+
h1_vlan_destroy
342+
}
343+
344+
vlan_over_bridged_port()
345+
{
346+
local vlan_filtering=$1
347+
348+
h1_vlan_create
349+
h2_vlan_create
350+
bridge_create $vlan_filtering
351+
macvlan_create $h2.100
352+
353+
run_test $h1.100 $h2.100 "VLAN over vlan_filtering=$vlan_filtering bridged port"
354+
355+
macvlan_destroy
356+
bridge_destroy
357+
h2_vlan_destroy
358+
h1_vlan_destroy
359+
}
360+
361+
vlan_over_vlan_unaware_bridged_port()
362+
{
363+
vlan_over_bridged_port 0
364+
}
365+
366+
vlan_over_vlan_aware_bridged_port()
367+
{
368+
vlan_over_bridged_port 1
369+
}
370+
371+
vlan_over_bridge()
372+
{
373+
local vlan_filtering=$1
374+
375+
h1_vlan_create
376+
bridge_create $vlan_filtering
377+
simple_if_init br0
378+
vlan_create br0 100 vbr0 $H2_IPV4/24 $H2_IPV6/64
379+
macvlan_create br0.100
380+
381+
if [ $vlan_filtering = 1 ]; then
382+
bridge vlan add dev $h2 vid 100 master
383+
bridge vlan add dev br0 vid 100 self
384+
fi
385+
386+
run_test $h1.100 br0.100 "VLAN over vlan_filtering=$vlan_filtering bridge"
387+
388+
if [ $vlan_filtering = 1 ]; then
389+
bridge vlan del dev br0 vid 100 self
390+
bridge vlan del dev $h2 vid 100 master
391+
fi
392+
393+
macvlan_destroy
394+
vlan_destroy br0 100
395+
simple_if_fini br0
396+
bridge_destroy
397+
h1_vlan_destroy
398+
}
399+
400+
vlan_over_vlan_unaware_bridge()
401+
{
402+
vlan_over_bridge 0
403+
}
404+
405+
vlan_over_vlan_aware_bridge()
406+
{
407+
vlan_over_bridge 1
408+
}
409+
307410
cleanup()
308411
{
309412
pre_cleanup

0 commit comments

Comments
 (0)