2 # SPDX-License-Identifier: GPL-2.0
4 # This test is for checking GRE GSO.
8 # all tests in this script. Can be overridden with -t option
23 if [ ${rc} -eq ${expected} ]; then
24 printf " TEST: %-60s [ OK ]\n" "${msg}"
25 nsuccess
=$
((nsuccess
+1))
29 printf " TEST: %-60s [FAIL]\n" "${msg}"
30 if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
32 echo "hit enter to continue, 'q' to quit"
34 [ "$a" = "q" ] && exit 1
38 if [ "${PAUSE}" = "yes" ]; then
40 echo "hit enter to continue, 'q' to quit"
42 [ "$a" = "q" ] && exit 1
51 NS_EXEC
="ip netns exec $ns1"
53 ip link add veth0
type veth peer name veth1
55 ip link
set veth1 netns
$ns1
56 $IP link
set veth1 name veth0
59 dd if=/dev
/urandom of
=$TMPFILE bs
=1024 count
=2048 &>/dev
/null
66 [ -n "$PID" ] && kill $PID
67 ip link del dev gre1
&> /dev
/null
68 ip link del dev veth0
&> /dev
/null
78 [ -n "$ns" ] && ns
="-netns $ns"
80 addr
=$
(ip
-6 -br $ns addr show dev
${dev} | \
82 for (i = 3; i <= NF; ++i) {
90 [ -z "$addr" ] && return 1
103 [[ $a1 =~ ^
[0-9.
]*$
]] && mode
=gre || mode
=ip6gre
105 ip tunnel add gre1 mode
$mode local $a1 remote
$a2 dev veth0
107 $IP tunnel add gre1 mode
$mode local $a2 remote
$a1 dev veth0
111 gre_gst_test_checks
()
117 [ "$proto" == 6 ] && addr
="[$addr]"
119 $NS_EXEC socat
- tcp
${proto}-listen:$port,reuseaddr
,fork
>/dev
/null
&
121 while ! $NS_EXEC ss
-ltn |
grep -q $port; do ((i
++)); sleep 0.01; done
123 cat $TMPFILE | timeout
1 socat
-u STDIN TCP
:$addr:$port
124 log_test $?
0 "$name - copy file w/ TSO"
126 ethtool
-K veth0 tso off
128 cat $TMPFILE | timeout
1 socat
-u STDIN TCP
:$addr:$port
129 log_test $?
0 "$name - copy file w/ GSO"
131 ethtool
-K veth0 tso on
143 a1
=$
(get_linklocal veth0
)
144 a2
=$
(get_linklocal veth0
$ns1)
146 gre_create_tun
$a1 $a2
148 ip addr add
172.16.2.1/24 dev gre1
149 $IP addr add
172.16.2.2/24 dev gre1
151 ip
-6 addr add
2001:db8
:1::1/64 dev gre1 nodad
152 $IP -6 addr add
2001:db8
:1::2/64 dev gre1 nodad
156 gre_gst_test_checks GREv
6/v4
172.16.2.2 4
157 gre_gst_test_checks GREv
6/v6
2001:db8
:1::2 6
167 ################################################################################
175 -t <test> Test(s) to run (default: all)
178 -P Pause after each test before cleanup
179 -v verbose mode (show commands and output)
183 ################################################################################
186 while getopts :t
:pPhv o
190 p
) PAUSE_ON_FAIL
=yes;;
192 v
) VERBOSE
=$
(($VERBOSE + 1));;
198 PEER_CMD
="ip netns exec ${PEER_NS}"
200 # make sure we don't pause twice
201 [ "${PAUSE}" = "yes" ] && PAUSE_ON_FAIL
=no
203 if [ "$(id -u)" -ne 0 ];then
204 echo "SKIP: Need root privileges"
208 if [ ! -x "$(command -v ip)" ]; then
209 echo "SKIP: Could not run test without ip tool"
213 if [ ! -x "$(command -v socat)" ]; then
214 echo "SKIP: Could not run test without socat tool"
224 gre_gso
) gre_gso_test
;;
226 help) echo "Test names: $TESTS"; exit 0;;
230 if [ "$TESTS" != "none" ]; then
231 printf "\nTests passed: %3d\n" ${nsuccess}
232 printf "Tests failed: %3d\n" ${nfail}