0001
0002
0003
0004
0005
0006
0007
0008
0009 ALL_TESTS="
0010 test_vlan
0011 test_tagged_vlan
0012 "
0013
0014 NUM_NETIFS=6
0015 source lib.sh
0016 source mirror_lib.sh
0017 source mirror_topo_lib.sh
0018
0019 setup_prepare()
0020 {
0021 h1=${NETIFS[p1]}
0022 swp1=${NETIFS[p2]}
0023
0024 swp2=${NETIFS[p3]}
0025 h2=${NETIFS[p4]}
0026
0027 swp3=${NETIFS[p5]}
0028 h3=${NETIFS[p6]}
0029
0030 vrf_prepare
0031 mirror_topo_create
0032
0033 vlan_create $swp3 555
0034
0035 vlan_create $h3 555 v$h3
0036 matchall_sink_create $h3.555
0037
0038 vlan_create $h1 111 v$h1 192.0.2.17/28
0039 bridge vlan add dev $swp1 vid 111
0040
0041 vlan_create $h2 111 v$h2 192.0.2.18/28
0042 bridge vlan add dev $swp2 vid 111
0043 }
0044
0045 cleanup()
0046 {
0047 pre_cleanup
0048
0049 vlan_destroy $h2 111
0050 vlan_destroy $h1 111
0051 vlan_destroy $h3 555
0052 vlan_destroy $swp3 555
0053
0054 mirror_topo_destroy
0055 vrf_cleanup
0056 }
0057
0058 test_vlan_dir()
0059 {
0060 local direction=$1; shift
0061 local forward_type=$1; shift
0062 local backward_type=$1; shift
0063
0064 RET=0
0065
0066 mirror_install $swp1 $direction $swp3.555 "matchall $tcflags"
0067 test_span_dir "$h3.555" "$direction" "$forward_type" "$backward_type"
0068 mirror_uninstall $swp1 $direction
0069
0070 log_test "$direction mirror to vlan ($tcflags)"
0071 }
0072
0073 test_vlan()
0074 {
0075 test_vlan_dir ingress 8 0
0076 test_vlan_dir egress 0 8
0077 }
0078
0079 test_tagged_vlan_dir()
0080 {
0081 local direction=$1; shift
0082 local forward_type=$1; shift
0083 local backward_type=$1; shift
0084
0085 RET=0
0086
0087 mirror_install $swp1 $direction $swp3.555 "matchall $tcflags"
0088 do_test_span_vlan_dir_ips 10 "$h3.555" 111 "$direction" ip \
0089 192.0.2.17 192.0.2.18
0090 do_test_span_vlan_dir_ips 0 "$h3.555" 555 "$direction" ip \
0091 192.0.2.17 192.0.2.18
0092 mirror_uninstall $swp1 $direction
0093
0094 log_test "$direction mirror tagged to vlan ($tcflags)"
0095 }
0096
0097 test_tagged_vlan()
0098 {
0099 test_tagged_vlan_dir ingress 8 0
0100 test_tagged_vlan_dir egress 0 8
0101 }
0102
0103 test_all()
0104 {
0105 slow_path_trap_install $swp1 ingress
0106 slow_path_trap_install $swp1 egress
0107 trap_install $h3 ingress
0108
0109 tests_run
0110
0111 trap_uninstall $h3 ingress
0112 slow_path_trap_uninstall $swp1 egress
0113 slow_path_trap_uninstall $swp1 ingress
0114 }
0115
0116 trap cleanup EXIT
0117
0118 setup_prepare
0119 setup_wait
0120
0121 tcflags="skip_hw"
0122 test_all
0123
0124 if ! tc_offload_check; then
0125 echo "WARN: Could not test offloaded functionality"
0126 else
0127 tcflags="skip_sw"
0128 test_all
0129 fi
0130
0131 exit $EXIT_STATUS