2 # SPDX-License-Identifier: GPL-2.0
4 # This test is for checking GRE GSO.
7 # Kselftest framework requirement - SKIP code is 4.
10 # all tests in this script. Can be overridden with -t option
17 NS_EXEC="ip netns exec ns1"
27 if [ ${rc} -eq ${expected} ]; then
28 printf " TEST: %-60s [ OK ]\n" "${msg}"
29 nsuccess=$((nsuccess+1))
33 printf " TEST: %-60s [FAIL]\n" "${msg}"
34 if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
36 echo "hit enter to continue, 'q' to quit"
38 [ "$a" = "q" ] && exit 1
42 if [ "${PAUSE}" = "yes" ]; then
44 echo "hit enter to continue, 'q' to quit"
46 [ "$a" = "q" ] && exit 1
55 $IP link set dev lo up
57 ip link add veth0 type veth peer name veth1
59 ip link set veth1 netns ns1
60 $IP link set veth1 name veth0
63 dd if=/dev/urandom of=$TMPFILE bs=1024 count=2048 &>/dev/null
70 [ -n "$PID" ] && kill $PID
71 ip link del dev gre1 &> /dev/null
72 ip link del dev veth0 &> /dev/null
82 [ -n "$ns" ] && ns="-netns $ns"
84 addr=$(ip -6 -br $ns addr show dev ${dev} | \
86 for (i = 3; i <= NF; ++i) {
94 [ -z "$addr" ] && return 1
107 [[ $a1 =~ ^[0-9.]*$ ]] && mode=gre || mode=ip6gre
109 ip tunnel add gre1 mode $mode local $a1 remote $a2 dev veth0
111 $IP tunnel add gre1 mode $mode local $a2 remote $a1 dev veth0
115 gre_gst_test_checks()
120 $NS_EXEC nc -kl $port >/dev/null &
122 while ! $NS_EXEC ss -ltn | grep -q $port; do ((i++)); sleep 0.01; done
124 cat $TMPFILE | timeout 1 nc $addr $port
125 log_test $? 0 "$name - copy file w/ TSO"
127 ethtool -K veth0 tso off
129 cat $TMPFILE | timeout 1 nc $addr $port
130 log_test $? 0 "$name - copy file w/ GSO"
132 ethtool -K veth0 tso on
144 a1=$(get_linklocal veth0)
145 a2=$(get_linklocal veth0 ns1)
147 gre_create_tun $a1 $a2
149 ip addr add 172.16.2.1/24 dev gre1
150 $IP addr add 172.16.2.2/24 dev gre1
152 ip -6 addr add 2001:db8:1::1/64 dev gre1 nodad
153 $IP -6 addr add 2001:db8:1::2/64 dev gre1 nodad
157 gre_gst_test_checks GREv6/v4 172.16.2.2
158 gre_gst_test_checks GREv6/v6 2001:db8:1::2
168 ################################################################################
176 -t <test> Test(s) to run (default: all)
179 -P Pause after each test before cleanup
180 -v verbose mode (show commands and output)
184 ################################################################################
187 while getopts :t:pPhv o
191 p) PAUSE_ON_FAIL=yes;;
193 v) VERBOSE=$(($VERBOSE + 1));;
199 PEER_CMD="ip netns exec ${PEER_NS}"
201 # make sure we don't pause twice
202 [ "${PAUSE}" = "yes" ] && PAUSE_ON_FAIL=no
204 if [ "$(id -u)" -ne 0 ];then
205 echo "SKIP: Need root privileges"
209 if [ ! -x "$(command -v ip)" ]; then
210 echo "SKIP: Could not run test without ip tool"
214 if [ ! -x "$(command -v nc)" ]; then
215 echo "SKIP: Could not run test without nc tool"
225 gre_gso) gre_gso_test;;
227 help) echo "Test names: $TESTS"; exit 0;;
231 if [ "$TESTS" != "none" ]; then
232 printf "\nTests passed: %3d\n" ${nsuccess}
233 printf "Tests failed: %3d\n" ${nfail}