brintos

brintos / linux-shallow public Read only

0
0
Text · 1.9 KiB · 2f150a4 Raw
113 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4# This test uses standard topology for testing mirroring. See mirror_topo_lib.sh5# for more details.6#7# Test for "tc action mirred egress mirror" that mirrors to a vlan device.8 9ALL_TESTS="10	test_vlan11	test_tagged_vlan12"13 14NUM_NETIFS=615source lib.sh16source mirror_lib.sh17source mirror_topo_lib.sh18 19setup_prepare()20{21	h1=${NETIFS[p1]}22	swp1=${NETIFS[p2]}23 24	swp2=${NETIFS[p3]}25	h2=${NETIFS[p4]}26 27	swp3=${NETIFS[p5]}28	h3=${NETIFS[p6]}29 30	vrf_prepare31	mirror_topo_create32 33	vlan_create $swp3 55534 35	vlan_create $h3 555 v$h336	matchall_sink_create $h3.55537 38	vlan_create $h1 111 v$h1 192.0.2.17/2839	bridge vlan add dev $swp1 vid 11140 41	vlan_create $h2 111 v$h2 192.0.2.18/2842	bridge vlan add dev $swp2 vid 11143 44	trap_install $h3 ingress45}46 47cleanup()48{49	pre_cleanup50 51	trap_uninstall $h3 ingress52 53	vlan_destroy $h2 11154	vlan_destroy $h1 11155	vlan_destroy $h3 55556	vlan_destroy $swp3 55557 58	mirror_topo_destroy59	vrf_cleanup60}61 62test_vlan_dir()63{64	local direction=$1; shift65	local forward_type=$1; shift66	local backward_type=$1; shift67 68	RET=069 70	mirror_install $swp1 $direction $swp3.555 "matchall"71	test_span_dir "$h3.555" "$forward_type" "$backward_type"72	mirror_uninstall $swp1 $direction73 74	log_test "$direction mirror to vlan"75}76 77test_vlan()78{79	test_vlan_dir ingress 8 080	test_vlan_dir egress 0 881}82 83test_tagged_vlan_dir()84{85	local direction=$1; shift86	local forward_type=$1; shift87	local backward_type=$1; shift88 89	RET=090 91	mirror_install $swp1 $direction $swp3.555 "matchall"92	do_test_span_vlan_dir_ips '>= 10' "$h3.555" 111 ip 192.0.2.17 192.0.2.1893	do_test_span_vlan_dir_ips  0 "$h3.555" 555 ip 192.0.2.17 192.0.2.1894	mirror_uninstall $swp1 $direction95 96	log_test "$direction mirror tagged to vlan"97}98 99test_tagged_vlan()100{101	test_tagged_vlan_dir ingress 8 0102	test_tagged_vlan_dir egress 0 8103}104 105trap cleanup EXIT106 107setup_prepare108setup_wait109 110tests_run111 112exit $EXIT_STATUS113