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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/test_xdping.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 # xdping tests
  5 #   Here we setup and teardown configuration required to run
  6 #   xdping, exercising its options.
  7 #
  8 #   Setup is similar to test_tunnel tests but without the tunnel.
  9 #
 10 # Topology:
 11 # ---------
 12 #     root namespace   |     tc_ns0 namespace
 13 #                      |
 14 #      ----------      |     ----------
 15 #      |  veth1  | --------- |  veth0  |
 16 #      ----------    peer    ----------
 17 #
 18 # Device Configuration
 19 # --------------------
 20 # Root namespace with BPF
 21 # Device names and addresses:
 22 #       veth1 IP: 10.1.1.200
 23 #       xdp added to veth1, xdpings originate from here.
 24 #
 25 # Namespace tc_ns0 with BPF
 26 # Device names and addresses:
 27 #       veth0 IPv4: 10.1.1.100
 28 #       For some tests xdping run in server mode here.
 29 #
 30 
 31 readonly TARGET_IP="10.1.1.100"
 32 readonly TARGET_NS="xdp_ns0"
 33 
 34 readonly LOCAL_IP="10.1.1.200"
 35 
 36 setup()
 37 {
 38         ip netns add $TARGET_NS
 39         ip link add veth0 type veth peer name veth1
 40         ip link set veth0 netns $TARGET_NS
 41         ip netns exec $TARGET_NS ip addr add ${TARGET_IP}/24 dev veth0
 42         ip addr add ${LOCAL_IP}/24 dev veth1
 43         ip netns exec $TARGET_NS ip link set veth0 up
 44         ip link set veth1 up
 45 }
 46 
 47 cleanup()
 48 {
 49         set +e
 50         ip netns delete $TARGET_NS 2>/dev/null
 51         ip link del veth1 2>/dev/null
 52         if [[ $server_pid -ne 0 ]]; then
 53                 kill -TERM $server_pid
 54         fi
 55 }
 56 
 57 test()
 58 {
 59         client_args="$1"
 60         server_args="$2"
 61 
 62         echo "Test client args '$client_args'; server args '$server_args'"
 63 
 64         server_pid=0
 65         if [[ -n "$server_args" ]]; then
 66                 ip netns exec $TARGET_NS ./xdping $server_args &
 67                 server_pid=$!
 68                 sleep 10
 69         fi
 70         ./xdping $client_args $TARGET_IP
 71 
 72         if [[ $server_pid -ne 0 ]]; then
 73                 kill -TERM $server_pid
 74                 server_pid=0
 75         fi
 76 
 77         echo "Test client args '$client_args'; server args '$server_args': PASS"
 78 }
 79 
 80 set -e
 81 
 82 server_pid=0
 83 
 84 trap cleanup EXIT
 85 
 86 setup
 87 
 88 for server_args in "" "-I veth0 -s -S" ; do
 89         # client in skb mode
 90         client_args="-I veth1 -S"
 91         test "$client_args" "$server_args"
 92 
 93         # client with count of 10 RTT measurements.
 94         client_args="-I veth1 -S -c 10"
 95         test "$client_args" "$server_args"
 96 done
 97 
 98 # Test drv mode
 99 test "-I veth1 -N" "-I veth0 -s -N"
100 test "-I veth1 -N -c 10" "-I veth0 -s -N"
101 
102 echo "OK. All tests passed"
103 exit 0

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