173 lines · bash
1# SPDX-License-Identifier: GPL-2.02 3source "$net_forwarding_dir/mirror_lib.sh"4 5quick_test_span_gre_dir_ips()6{7 local tundev=$1; shift8 local ip1=$1; shift9 local ip2=$1; shift10 local forward_type=$1; shift11 local backward_type=$1; shift12 13 do_test_span_dir_ips 10 h3-$tundev "$ip1" "$ip2" \14 "$forward_type" "$backward_type"15}16 17fail_test_span_gre_dir_ips()18{19 local tundev=$1; shift20 local ip1=$1; shift21 local ip2=$1; shift22 23 do_test_span_dir_ips 0 h3-$tundev "$ip1" "$ip2"24}25 26test_span_gre_dir_ips()27{28 local tundev=$1; shift29 local forward_type=$1; shift30 local backward_type=$1; shift31 local ip1=$1; shift32 local ip2=$1; shift33 34 test_span_dir_ips h3-$tundev "$forward_type" \35 "$backward_type" "$ip1" "$ip2"36}37 38full_test_span_gre_dir_ips()39{40 local tundev=$1; shift41 local direction=$1; shift42 local forward_type=$1; shift43 local backward_type=$1; shift44 local what=$1; shift45 local ip1=$1; shift46 local ip2=$1; shift47 48 RET=049 50 mirror_install $swp1 $direction $tundev "matchall"51 test_span_dir_ips "h3-$tundev" "$forward_type" \52 "$backward_type" "$ip1" "$ip2"53 mirror_uninstall $swp1 $direction54 55 log_test "$direction $what"56}57 58full_test_span_gre_dir_vlan_ips()59{60 local tundev=$1; shift61 local direction=$1; shift62 local vlan_match=$1; shift63 local forward_type=$1; shift64 local backward_type=$1; shift65 local what=$1; shift66 local ip1=$1; shift67 local ip2=$1; shift68 69 RET=070 71 mirror_install $swp1 $direction $tundev "matchall"72 73 test_span_dir_ips "h3-$tundev" "$forward_type" \74 "$backward_type" "$ip1" "$ip2"75 76 tc filter add dev $h3 ingress pref 77 prot 802.1q \77 flower $vlan_match \78 action pass79 mirror_test v$h1 $ip1 $ip2 $h3 77 '>= 10'80 tc filter del dev $h3 ingress pref 7781 82 mirror_uninstall $swp1 $direction83 84 log_test "$direction $what"85}86 87quick_test_span_gre_dir()88{89 local tundev=$1; shift90 local forward_type=${1-8}; shift91 local backward_type=${1-0}; shift92 93 quick_test_span_gre_dir_ips "$tundev" 192.0.2.1 192.0.2.2 \94 "$forward_type" "$backward_type"95}96 97fail_test_span_gre_dir()98{99 local tundev=$1; shift100 101 fail_test_span_gre_dir_ips "$tundev" 192.0.2.1 192.0.2.2102}103 104full_test_span_gre_dir()105{106 local tundev=$1; shift107 local direction=$1; shift108 local forward_type=$1; shift109 local backward_type=$1; shift110 local what=$1; shift111 112 full_test_span_gre_dir_ips "$tundev" "$direction" "$forward_type" \113 "$backward_type" "$what" 192.0.2.1 192.0.2.2114}115 116full_test_span_gre_dir_vlan()117{118 local tundev=$1; shift119 local direction=$1; shift120 local vlan_match=$1; shift121 local forward_type=$1; shift122 local backward_type=$1; shift123 local what=$1; shift124 125 full_test_span_gre_dir_vlan_ips "$tundev" "$direction" "$vlan_match" \126 "$forward_type" "$backward_type" \127 "$what" 192.0.2.1 192.0.2.2128}129 130full_test_span_gre_stp_ips()131{132 local tundev=$1; shift133 local nbpdev=$1; shift134 local what=$1; shift135 local ip1=$1; shift136 local ip2=$1; shift137 local forward_type=$1; shift138 local backward_type=$1; shift139 local h3mac=$(mac_get $h3)140 141 RET=0142 143 mirror_install $swp1 ingress $tundev "matchall"144 quick_test_span_gre_dir_ips $tundev $ip1 $ip2 \145 "$forward_type" "$backward_type"146 147 bridge link set dev $nbpdev state disabled148 sleep 1149 fail_test_span_gre_dir_ips $tundev $ip1 $ip2150 151 bridge link set dev $nbpdev state forwarding152 sleep 1153 quick_test_span_gre_dir_ips $tundev $ip1 $ip2 \154 "$forward_type" "$backward_type"155 156 mirror_uninstall $swp1 ingress157 158 log_test "$what: STP state"159}160 161full_test_span_gre_stp()162{163 local tundev=$1; shift164 local nbpdev=$1; shift165 local what=$1; shift166 local forward_type=${1-8}; shift167 local backward_type=${1-0}; shift168 169 full_test_span_gre_stp_ips "$tundev" "$nbpdev" "$what" \170 192.0.2.1 192.0.2.2 \171 "$forward_type" "$backward_type"172}173