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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/forwarding/tc_tunnel_key.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="tunnel_key_nofrag_test"
  5 
  6 NUM_NETIFS=4
  7 source tc_common.sh
  8 source lib.sh
  9 
 10 tcflags="skip_hw"
 11 
 12 h1_create()
 13 {
 14         simple_if_init $h1 192.0.2.1/24
 15         forwarding_enable
 16         mtu_set $h1 1500
 17         tunnel_create h1-et vxlan 192.0.2.1 192.0.2.2 dev $h1 dstport 0 external
 18         tc qdisc add dev h1-et clsact
 19         mtu_set h1-et 1230
 20         mtu_restore $h1
 21         mtu_set $h1 1000
 22 }
 23 
 24 h1_destroy()
 25 {
 26         tc qdisc del dev h1-et clsact
 27         tunnel_destroy h1-et
 28         forwarding_restore
 29         mtu_restore $h1
 30         simple_if_fini $h1 192.0.2.1/24
 31 }
 32 
 33 h2_create()
 34 {
 35         simple_if_init $h2 192.0.2.2/24
 36 }
 37 
 38 h2_destroy()
 39 {
 40         simple_if_fini $h2 192.0.2.2/24
 41 }
 42 
 43 switch_create()
 44 {
 45         simple_if_init $swp1 192.0.2.2/24
 46         tc qdisc add dev $swp1 clsact
 47         simple_if_init $swp2 192.0.2.1/24
 48 }
 49 
 50 switch_destroy()
 51 {
 52         simple_if_fini $swp2 192.0.2.1/24
 53         tc qdisc del dev $swp1 clsact
 54         simple_if_fini $swp1 192.0.2.2/24
 55 }
 56 
 57 setup_prepare()
 58 {
 59         h1=${NETIFS[p1]}
 60         swp1=${NETIFS[p2]}
 61 
 62         swp2=${NETIFS[p3]}
 63         h2=${NETIFS[p4]}
 64 
 65         h1mac=$(mac_get $h1)
 66         h2mac=$(mac_get $h2)
 67 
 68         swp1origmac=$(mac_get $swp1)
 69         swp2origmac=$(mac_get $swp2)
 70         ip link set $swp1 address $h2mac
 71         ip link set $swp2 address $h1mac
 72 
 73         vrf_prepare
 74 
 75         h1_create
 76         h2_create
 77         switch_create
 78 
 79         if ! tc action add action tunnel_key help 2>&1 | grep -q nofrag; then
 80                 log_test "SKIP: iproute doesn't support nofrag"
 81                 exit $ksft_skip
 82         fi
 83 }
 84 
 85 cleanup()
 86 {
 87         pre_cleanup
 88 
 89         switch_destroy
 90         h2_destroy
 91         h1_destroy
 92 
 93         vrf_cleanup
 94 
 95         ip link set $swp2 address $swp2origmac
 96         ip link set $swp1 address $swp1origmac
 97 }
 98 
 99 tunnel_key_nofrag_test()
100 {
101         RET=0
102         local i
103 
104         tc filter add dev $swp1 ingress protocol ip pref 100 handle 100 \
105                 flower src_ip 192.0.2.1 dst_ip 192.0.2.2 ip_proto udp \
106                 ip_flags nofrag action drop
107         tc filter add dev $swp1 ingress protocol ip pref 101 handle 101 \
108                 flower src_ip 192.0.2.1 dst_ip 192.0.2.2 ip_proto udp \
109                 ip_flags firstfrag action drop
110         tc filter add dev $swp1 ingress protocol ip pref 102 handle 102 \
111                 flower src_ip 192.0.2.1 dst_ip 192.0.2.2 ip_proto udp \
112                 ip_flags nofirstfrag action drop
113 
114         # test 'nofrag' set
115         tc filter add dev h1-et egress protocol all pref 1 handle 1 matchall $tcflags \
116                 action tunnel_key set src_ip 192.0.2.1 dst_ip 192.0.2.2 id 42 nofrag index 10
117         $MZ h1-et -c 1 -p 930 -a 00:aa:bb:cc:dd:ee -b 00:ee:dd:cc:bb:aa -t ip -q
118         tc_check_packets "dev $swp1 ingress" 100 1
119         check_err $? "packet smaller than MTU was not tunneled"
120 
121         $MZ h1-et -c 1 -p 931 -a 00:aa:bb:cc:dd:ee -b 00:ee:dd:cc:bb:aa -t ip -q
122         tc_check_packets "dev $swp1 ingress" 100 1
123         check_err $? "packet bigger than MTU matched nofrag (nofrag was set)"
124         tc_check_packets "dev $swp1 ingress" 101 0
125         check_err $? "packet bigger than MTU matched firstfrag (nofrag was set)"
126         tc_check_packets "dev $swp1 ingress" 102 0
127         check_err $? "packet bigger than MTU matched nofirstfrag (nofrag was set)"
128 
129         # test 'nofrag' cleared
130         tc actions change action tunnel_key set src_ip 192.0.2.1 dst_ip 192.0.2.2 id 42 index 10
131         $MZ h1-et -c 1 -p 931 -a 00:aa:bb:cc:dd:ee -b 00:ee:dd:cc:bb:aa -t ip -q
132         tc_check_packets "dev $swp1  ingress" 100 1
133         check_err $? "packet bigger than MTU matched nofrag (nofrag was unset)"
134         tc_check_packets "dev $swp1  ingress" 101 1
135         check_err $? "packet bigger than MTU didn't match firstfrag (nofrag was unset) "
136         tc_check_packets "dev $swp1 ingress" 102 1
137         check_err $? "packet bigger than MTU didn't match nofirstfrag (nofrag was unset) "
138 
139         for i in 100 101 102; do
140                 tc filter del dev $swp1 ingress protocol ip pref $i handle $i flower
141         done
142         tc filter del dev h1-et egress pref 1 handle 1 matchall
143 
144         log_test "tunnel_key nofrag ($tcflags)"
145 }
146 
147 trap cleanup EXIT
148 
149 setup_prepare
150 setup_wait
151 
152 tests_run
153 
154 tc_offload_check
155 if [[ $? -ne 0 ]]; then
156         log_info "Could not test offloaded functionality"
157 else
158         tcflags="skip_sw"
159         tests_run
160 fi
161 
162 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