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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/forwarding/tc_shblocks.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="shared_block_test match_indev_test"
  5 NUM_NETIFS=4
  6 source tc_common.sh
  7 source lib.sh
  8 
  9 tcflags="skip_hw"
 10 
 11 h1_create()
 12 {
 13         simple_if_init $h1 192.0.2.1/24
 14 }
 15 
 16 h1_destroy()
 17 {
 18         simple_if_fini $h1 192.0.2.1/24
 19 }
 20 
 21 h2_create()
 22 {
 23         simple_if_init $h2 192.0.2.1/24
 24 }
 25 
 26 h2_destroy()
 27 {
 28         simple_if_fini $h2 192.0.2.1/24
 29 }
 30 
 31 switch_create()
 32 {
 33         simple_if_init $swp1 192.0.2.2/24
 34         tc qdisc add dev $swp1 ingress_block 22 egress_block 23 clsact
 35 
 36         simple_if_init $swp2 192.0.2.2/24
 37         tc qdisc add dev $swp2 ingress_block 22 egress_block 23 clsact
 38 }
 39 
 40 switch_destroy()
 41 {
 42         tc qdisc del dev $swp2 clsact
 43         simple_if_fini $swp2 192.0.2.2/24
 44 
 45         tc qdisc del dev $swp1 clsact
 46         simple_if_fini $swp1 192.0.2.2/24
 47 }
 48 
 49 shared_block_test()
 50 {
 51         RET=0
 52 
 53         tc filter add block 22 protocol ip pref 1 handle 101 flower \
 54                 $tcflags dst_ip 192.0.2.2 action drop
 55 
 56         $MZ $h1 -c 1 -p 64 -a $h1mac -b $swmac -A 192.0.2.1 -B 192.0.2.2 \
 57                 -t ip -q
 58 
 59         tc_check_packets "block 22" 101 1
 60         check_err $? "Did not match first incoming packet on a block"
 61 
 62         $MZ $h2 -c 1 -p 64 -a $h2mac -b $swmac -A 192.0.2.1 -B 192.0.2.2 \
 63                 -t ip -q
 64 
 65         tc_check_packets "block 22" 101 2
 66         check_err $? "Did not match second incoming packet on a block"
 67 
 68         tc filter del block 22 protocol ip pref 1 handle 101 flower
 69 
 70         log_test "shared block ($tcflags)"
 71 }
 72 
 73 match_indev_test()
 74 {
 75         RET=0
 76 
 77         tc filter add block 22 protocol ip pref 1 handle 101 flower \
 78                 $tcflags indev $swp1 dst_mac $swmac action drop
 79         tc filter add block 22 protocol ip pref 2 handle 102 flower \
 80                 $tcflags indev $swp2 dst_mac $swmac action drop
 81 
 82         $MZ $h1 -c 1 -p 64 -a $h1mac -b $swmac -A 192.0.2.1 -B 192.0.2.2 \
 83                 -t ip -q
 84 
 85         tc_check_packets "block 22" 101 1
 86         check_err $? "Did not match first incoming packet on a block"
 87 
 88         $MZ $h2 -c 1 -p 64 -a $h2mac -b $swmac -A 192.0.2.1 -B 192.0.2.2 \
 89                 -t ip -q
 90 
 91         tc_check_packets "block 22" 102 1
 92         check_err $? "Did not match second incoming packet on a block"
 93 
 94         tc filter del block 22 protocol ip pref 1 handle 101 flower
 95         tc filter del block 22 protocol ip pref 2 handle 102 flower
 96 
 97         log_test "indev match ($tcflags)"
 98 }
 99 
100 setup_prepare()
101 {
102         h1=${NETIFS[p1]}
103         swp1=${NETIFS[p2]}
104 
105         swp2=${NETIFS[p3]}
106         h2=${NETIFS[p4]}
107 
108         h1mac=$(mac_get $h1)
109         h2mac=$(mac_get $h2)
110 
111         swmac=$(mac_get $swp1)
112         swp2origmac=$(mac_get $swp2)
113         ip link set $swp2 address $swmac
114 
115         vrf_prepare
116 
117         h1_create
118         h2_create
119         switch_create
120 }
121 
122 cleanup()
123 {
124         pre_cleanup
125 
126         switch_destroy
127         h2_destroy
128         h1_destroy
129 
130         vrf_cleanup
131 
132         ip link set $swp2 address $swp2origmac
133 }
134 
135 check_tc_shblock_support
136 
137 trap cleanup EXIT
138 
139 setup_prepare
140 setup_wait
141 
142 tests_run
143 
144 tc_offload_check
145 if [[ $? -ne 0 ]]; then
146         log_info "Could not test offloaded functionality"
147 else
148         tcflags="skip_sw"
149         tests_run
150 fi
151 
152 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