brintos

brintos / linux-shallow public Read only

0
0
Text · 2.1 KiB · c3d82e0 Raw
104 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4# xdping tests5#   Here we setup and teardown configuration required to run6#   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 namespace13#                      |14#      ----------      |     ----------15#      |  veth1  | --------- |  veth0  |16#      ----------    peer    ----------17#18# Device Configuration19# --------------------20# Root namespace with BPF21# Device names and addresses:22#	veth1 IP: 10.1.1.20023#	xdp added to veth1, xdpings originate from here.24#25# Namespace tc_ns0 with BPF26# Device names and addresses:27#       veth0 IPv4: 10.1.1.10028#	For some tests xdping run in server mode here.29#30 31readonly TARGET_IP="10.1.1.100"32readonly TARGET_NS="xdp_ns0"33 34readonly LOCAL_IP="10.1.1.200"35 36setup()37{38	ip netns add $TARGET_NS39	ip link add veth0 type veth peer name veth140	ip link set veth0 netns $TARGET_NS41	ip netns exec $TARGET_NS ip addr add ${TARGET_IP}/24 dev veth042	ip addr add ${LOCAL_IP}/24 dev veth143	ip netns exec $TARGET_NS ip link set veth0 up44	ip link set veth1 up45}46 47cleanup()48{49	set +e50	ip netns delete $TARGET_NS 2>/dev/null51	ip link del veth1 2>/dev/null52	if [[ $server_pid -ne 0 ]]; then53		kill -TERM $server_pid54	fi55}56 57test()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=065	if [[ -n "$server_args" ]]; then66		ip netns exec $TARGET_NS ./xdping $server_args &67		server_pid=$!68		sleep 1069	fi70	./xdping $client_args $TARGET_IP71 72	if [[ $server_pid -ne 0 ]]; then73		kill -TERM $server_pid74		server_pid=075	fi76 77	echo "Test client args '$client_args'; server args '$server_args': PASS"78}79 80set -e81 82server_pid=083 84trap cleanup EXIT85 86setup87 88for server_args in "" "-I veth0 -s -S" ; do89	# client in skb mode90	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"96done97 98# Test drv mode99test "-I veth1 -N" "-I veth0 -s -N"100test "-I veth1 -N -c 10" "-I veth0 -s -N"101 102echo "OK. All tests passed"103exit 0104