~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/forwarding/tc_flower_router.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 ALL_TESTS="match_indev_egress_test"
  5 NUM_NETIFS=6
  6 source tc_common.sh
  7 source lib.sh
  8 
  9 h1_create()
 10 {
 11         simple_if_init $h1 192.0.1.1/24
 12 
 13         ip route add 192.0.2.0/24 vrf v$h1 nexthop via 192.0.1.2
 14         ip route add 192.0.3.0/24 vrf v$h1 nexthop via 192.0.1.2
 15 }
 16 
 17 h1_destroy()
 18 {
 19         ip route del 192.0.3.0/24 vrf v$h1
 20         ip route del 192.0.2.0/24 vrf v$h1
 21 
 22         simple_if_fini $h1 192.0.1.1/24
 23 }
 24 
 25 h2_create()
 26 {
 27         simple_if_init $h2 192.0.2.1/24
 28 
 29         ip route add 192.0.1.0/24 vrf v$h2 nexthop via 192.0.2.2
 30         ip route add 192.0.3.0/24 vrf v$h2 nexthop via 192.0.2.2
 31 }
 32 
 33 h2_destroy()
 34 {
 35         ip route del 192.0.3.0/24 vrf v$h2
 36         ip route del 192.0.1.0/24 vrf v$h2
 37 
 38         simple_if_fini $h2 192.0.2.1/24
 39 }
 40 
 41 h3_create()
 42 {
 43         simple_if_init $h3 192.0.3.1/24
 44 
 45         ip route add 192.0.1.0/24 vrf v$h3 nexthop via 192.0.3.2
 46         ip route add 192.0.2.0/24 vrf v$h3 nexthop via 192.0.3.2
 47 }
 48 
 49 h3_destroy()
 50 {
 51         ip route del 192.0.2.0/24 vrf v$h3
 52         ip route del 192.0.1.0/24 vrf v$h3
 53 
 54         simple_if_fini $h3 192.0.3.1/24
 55 }
 56 
 57 
 58 router_create()
 59 {
 60         ip link set dev $rp1 up
 61         ip link set dev $rp2 up
 62         ip link set dev $rp3 up
 63 
 64         tc qdisc add dev $rp3 clsact
 65 
 66         ip address add 192.0.1.2/24 dev $rp1
 67         ip address add 192.0.2.2/24 dev $rp2
 68         ip address add 192.0.3.2/24 dev $rp3
 69 }
 70 
 71 router_destroy()
 72 {
 73         ip address del 192.0.3.2/24 dev $rp3
 74         ip address del 192.0.2.2/24 dev $rp2
 75         ip address del 192.0.1.2/24 dev $rp1
 76 
 77         tc qdisc del dev $rp3 clsact
 78 
 79         ip link set dev $rp3 down
 80         ip link set dev $rp2 down
 81         ip link set dev $rp1 down
 82 }
 83 
 84 match_indev_egress_test()
 85 {
 86         RET=0
 87 
 88         tc filter add dev $rp3 egress protocol ip pref 1 handle 101 flower \
 89                 $tcflags indev $rp1 dst_ip 192.0.3.1 action drop
 90         tc filter add dev $rp3 egress protocol ip pref 2 handle 102 flower \
 91                 $tcflags indev $rp2 dst_ip 192.0.3.1 action drop
 92 
 93         $MZ $h1 -c 1 -p 64 -a $h1mac -b $rp1mac -A 192.0.1.1 -B 192.0.3.1 \
 94                 -t ip -q
 95 
 96         tc_check_packets "dev $rp3 egress" 102 1
 97         check_fail $? "Matched on a wrong filter"
 98 
 99         tc_check_packets "dev $rp3 egress" 101 1
100         check_err $? "Did not match on correct filter"
101 
102         $MZ $h2 -c 1 -p 64 -a $h2mac -b $rp2mac -A 192.0.2.1 -B 192.0.3.1 \
103                 -t ip -q
104 
105         tc_check_packets "dev $rp3 egress" 101 2
106         check_fail $? "Matched on a wrong filter"
107 
108         tc_check_packets "dev $rp3 egress" 102 1
109         check_err $? "Did not match on correct filter"
110 
111         tc filter del dev $rp3 egress protocol ip pref 2 handle 102 flower
112         tc filter del dev $rp3 egress protocol ip pref 1 handle 101 flower
113 
114         log_test "indev egress match ($tcflags)"
115 }
116 
117 setup_prepare()
118 {
119         h1=${NETIFS[p1]}
120         rp1=${NETIFS[p2]}
121 
122         h2=${NETIFS[p3]}
123         rp2=${NETIFS[p4]}
124 
125         h3=${NETIFS[p5]}
126         rp3=${NETIFS[p6]}
127 
128         h1mac=$(mac_get $h1)
129         rp1mac=$(mac_get $rp1)
130         h2mac=$(mac_get $h2)
131         rp2mac=$(mac_get $rp2)
132 
133         vrf_prepare
134 
135         h1_create
136         h2_create
137         h3_create
138 
139         router_create
140 
141         forwarding_enable
142 }
143 
144 cleanup()
145 {
146         pre_cleanup
147 
148         forwarding_restore
149 
150         router_destroy
151 
152         h3_destroy
153         h2_destroy
154         h1_destroy
155 
156         vrf_cleanup
157 }
158 
159 trap cleanup EXIT
160 
161 setup_prepare
162 setup_wait
163 
164 tc_offload_check
165 if [[ $? -ne 0 ]]; then
166         log_info "Could not test offloaded functionality"
167 else
168         tcflags="skip_sw"
169         tests_run
170 fi
171 
172 exit $EXIT_STATUS

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php