WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / test_xdping.sh
blobc2f0ddb455317a37fa077954de8c64f676eb719e
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # xdping tests
5 # Here we setup and teardown configuration required to run
6 # xdping, exercising its options.
8 # Setup is similar to test_tunnel tests but without the tunnel.
10 # Topology:
11 # ---------
12 # root namespace | tc_ns0 namespace
13 # |
14 # ---------- | ----------
15 # | veth1 | --------- | veth0 |
16 # ---------- peer ----------
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.
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.
31 readonly TARGET_IP="10.1.1.100"
32 readonly TARGET_NS="xdp_ns0"
34 readonly LOCAL_IP="10.1.1.200"
36 setup()
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
47 cleanup()
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
57 test()
59 client_args="$1"
60 server_args="$2"
62 echo "Test client args '$client_args'; server args '$server_args'"
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
70 ./xdping $client_args $TARGET_IP
72 if [[ $server_pid -ne 0 ]]; then
73 kill -TERM $server_pid
74 server_pid=0
77 echo "Test client args '$client_args'; server args '$server_args': PASS"
80 set -e
82 server_pid=0
84 trap cleanup EXIT
86 setup
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"
93 # client with count of 10 RTT measurements.
94 client_args="-I veth1 -S -c 10"
95 test "$client_args" "$server_args"
96 done
98 echo "OK. All tests passed"
99 exit 0