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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/big_tcp.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 # Testing For IPv4 and IPv6 BIG TCP.
  5 # TOPO: CLIENT_NS (link0)<--->(link1) ROUTER_NS (link2)<--->(link3) SERVER_NS
  6 
  7 CLIENT_NS=$(mktemp -u client-XXXXXXXX)
  8 CLIENT_IP4="198.51.100.1"
  9 CLIENT_IP6="2001:db8:1::1"
 10 
 11 SERVER_NS=$(mktemp -u server-XXXXXXXX)
 12 SERVER_IP4="203.0.113.1"
 13 SERVER_IP6="2001:db8:2::1"
 14 
 15 ROUTER_NS=$(mktemp -u router-XXXXXXXX)
 16 SERVER_GW4="203.0.113.2"
 17 CLIENT_GW4="198.51.100.2"
 18 SERVER_GW6="2001:db8:2::2"
 19 CLIENT_GW6="2001:db8:1::2"
 20 
 21 MAX_SIZE=128000
 22 CHK_SIZE=65535
 23 
 24 # Kselftest framework requirement - SKIP code is 4.
 25 ksft_skip=4
 26 
 27 setup() {
 28         ip netns add $CLIENT_NS
 29         ip netns add $SERVER_NS
 30         ip netns add $ROUTER_NS
 31         ip -net $ROUTER_NS link add link1 type veth peer name link0 netns $CLIENT_NS
 32         ip -net $ROUTER_NS link add link2 type veth peer name link3 netns $SERVER_NS
 33 
 34         ip -net $CLIENT_NS link set link0 up
 35         ip -net $CLIENT_NS link set link0 mtu 1442
 36         ip -net $CLIENT_NS addr add $CLIENT_IP4/24 dev link0
 37         ip -net $CLIENT_NS addr add $CLIENT_IP6/64 dev link0 nodad
 38         ip -net $CLIENT_NS route add $SERVER_IP4 dev link0 via $CLIENT_GW4
 39         ip -net $CLIENT_NS route add $SERVER_IP6 dev link0 via $CLIENT_GW6
 40         ip -net $CLIENT_NS link set dev link0 \
 41                 gro_ipv4_max_size $MAX_SIZE gso_ipv4_max_size $MAX_SIZE
 42         ip -net $CLIENT_NS link set dev link0 \
 43                 gro_max_size $MAX_SIZE gso_max_size $MAX_SIZE
 44         ip net exec $CLIENT_NS sysctl -wq net.ipv4.tcp_window_scaling=10
 45 
 46         ip -net $ROUTER_NS link set link1 up
 47         ip -net $ROUTER_NS link set link2 up
 48         ip -net $ROUTER_NS addr add $CLIENT_GW4/24 dev link1
 49         ip -net $ROUTER_NS addr add $CLIENT_GW6/64 dev link1 nodad
 50         ip -net $ROUTER_NS addr add $SERVER_GW4/24 dev link2
 51         ip -net $ROUTER_NS addr add $SERVER_GW6/64 dev link2 nodad
 52         ip -net $ROUTER_NS link set dev link1 \
 53                 gro_ipv4_max_size $MAX_SIZE gso_ipv4_max_size $MAX_SIZE
 54         ip -net $ROUTER_NS link set dev link2 \
 55                 gro_ipv4_max_size $MAX_SIZE gso_ipv4_max_size $MAX_SIZE
 56         ip -net $ROUTER_NS link set dev link1 \
 57                 gro_max_size $MAX_SIZE gso_max_size $MAX_SIZE
 58         ip -net $ROUTER_NS link set dev link2 \
 59                 gro_max_size $MAX_SIZE gso_max_size $MAX_SIZE
 60         # test for nf_ct_skb_network_trim in nf_conntrack_ovs used by TC ct action.
 61         ip net exec $ROUTER_NS tc qdisc add dev link1 ingress
 62         ip net exec $ROUTER_NS tc filter add dev link1 ingress \
 63                 proto ip flower ip_proto tcp action ct
 64         ip net exec $ROUTER_NS tc filter add dev link1 ingress \
 65                 proto ipv6 flower ip_proto tcp action ct
 66         ip net exec $ROUTER_NS sysctl -wq net.ipv4.ip_forward=1
 67         ip net exec $ROUTER_NS sysctl -wq net.ipv6.conf.all.forwarding=1
 68 
 69         ip -net $SERVER_NS link set link3 up
 70         ip -net $SERVER_NS addr add $SERVER_IP4/24 dev link3
 71         ip -net $SERVER_NS addr add $SERVER_IP6/64 dev link3 nodad
 72         ip -net $SERVER_NS route add $CLIENT_IP4 dev link3 via $SERVER_GW4
 73         ip -net $SERVER_NS route add $CLIENT_IP6 dev link3 via $SERVER_GW6
 74         ip -net $SERVER_NS link set dev link3 \
 75                 gro_ipv4_max_size $MAX_SIZE gso_ipv4_max_size $MAX_SIZE
 76         ip -net $SERVER_NS link set dev link3 \
 77                 gro_max_size $MAX_SIZE gso_max_size $MAX_SIZE
 78         ip net exec $SERVER_NS sysctl -wq net.ipv4.tcp_window_scaling=10
 79         ip net exec $SERVER_NS netserver 2>&1 >/dev/null
 80 }
 81 
 82 cleanup() {
 83         ip net exec $SERVER_NS pkill netserver
 84         ip -net $ROUTER_NS link del link1
 85         ip -net $ROUTER_NS link del link2
 86         ip netns del "$CLIENT_NS"
 87         ip netns del "$SERVER_NS"
 88         ip netns del "$ROUTER_NS"
 89 }
 90 
 91 start_counter() {
 92         local ipt="iptables"
 93         local iface=$1
 94         local netns=$2
 95 
 96         [ "$NF" = "6" ] && ipt="ip6tables"
 97         ip net exec $netns $ipt -t raw -A PREROUTING -i $iface \
 98                 -m length ! --length 0:$CHK_SIZE -j ACCEPT
 99 }
100 
101 check_counter() {
102         local ipt="iptables"
103         local iface=$1
104         local netns=$2
105 
106         [ "$NF" = "6" ] && ipt="ip6tables"
107         test `ip net exec $netns $ipt -t raw -L -v |grep $iface | awk '{print $1}'` != "0"
108 }
109 
110 stop_counter() {
111         local ipt="iptables"
112         local iface=$1
113         local netns=$2
114 
115         [ "$NF" = "6" ] && ipt="ip6tables"
116         ip net exec $netns $ipt -t raw -D PREROUTING -i $iface \
117                 -m length ! --length 0:$CHK_SIZE -j ACCEPT
118 }
119 
120 do_netperf() {
121         local serip=$SERVER_IP4
122         local netns=$1
123 
124         [ "$NF" = "6" ] && serip=$SERVER_IP6
125 
126         # use large write to be sure to generate big tcp packets
127         ip net exec $netns netperf -$NF -t TCP_STREAM -l 1 -H $serip -- -m 262144 2>&1 >/dev/null
128 }
129 
130 do_test() {
131         local cli_tso=$1
132         local gw_gro=$2
133         local gw_tso=$3
134         local ser_gro=$4
135         local ret="PASS"
136 
137         ip net exec $CLIENT_NS ethtool -K link0 tso $cli_tso
138         ip net exec $ROUTER_NS ethtool -K link1 gro $gw_gro
139         ip net exec $ROUTER_NS ethtool -K link2 tso $gw_tso
140         ip net exec $SERVER_NS ethtool -K link3 gro $ser_gro
141 
142         start_counter link1 $ROUTER_NS
143         start_counter link3 $SERVER_NS
144         do_netperf $CLIENT_NS
145 
146         if check_counter link1 $ROUTER_NS; then
147                 check_counter link3 $SERVER_NS || ret="FAIL_on_link3"
148         else
149                 ret="FAIL_on_link1"
150         fi
151 
152         stop_counter link1 $ROUTER_NS
153         stop_counter link3 $SERVER_NS
154         printf "%-9s %-8s %-8s %-8s: [%s]\n" \
155                 $cli_tso $gw_gro $gw_tso $ser_gro $ret
156         test $ret = "PASS"
157 }
158 
159 testup() {
160         echo "CLI GSO | GW GRO | GW GSO | SER GRO" && \
161         do_test "on"  "on"  "on"  "on"  && \
162         do_test "on"  "off" "on"  "off" && \
163         do_test "off" "on"  "on"  "on"  && \
164         do_test "on"  "on"  "off" "on"  && \
165         do_test "off" "on"  "off" "on"
166 }
167 
168 if ! netperf -V &> /dev/null; then
169         echo "SKIP: Could not run test without netperf tool"
170         exit $ksft_skip
171 fi
172 
173 if ! ip link help 2>&1 | grep gso_ipv4_max_size &> /dev/null; then
174         echo "SKIP: Could not run test without gso/gro_ipv4_max_size supported in ip-link"
175         exit $ksft_skip
176 fi
177 
178 trap cleanup EXIT
179 setup && echo "Testing for BIG TCP:" && \
180 NF=4 testup && echo "***v4 Tests Done***" && \
181 NF=6 testup && echo "***v6 Tests Done***"
182 exit $?

~ [ 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