0001
0002
0003
0004
0005
0006 readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
0007
0008 cleanup() {
0009 local -r jobs="$(jobs -p)"
0010 local -r ns="$(ip netns list|grep $PEER_NS)"
0011
0012 [ -n "${jobs}" ] && kill -INT ${jobs} 2>/dev/null
0013 [ -n "$ns" ] && ip netns del $ns 2>/dev/null
0014 }
0015 trap cleanup EXIT
0016
0017 run_one() {
0018
0019 local -r all="$@"
0020 local -r tx_args=${all%rx*}
0021 local rx_args=${all
0022
0023 [[ "${tx_args}" == *"-4"* ]] && rx_args="${rx_args} -4"
0024
0025 ip netns add "${PEER_NS}"
0026 ip -netns "${PEER_NS}" link set lo up
0027 ip link add type veth
0028 ip link set dev veth0 up
0029 ip addr add dev veth0 192.168.1.2/24
0030 ip addr add dev veth0 2001:db8::2/64 nodad
0031
0032 ip link set dev veth1 netns "${PEER_NS}"
0033 ip -netns "${PEER_NS}" addr add dev veth1 192.168.1.1/24
0034 ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad
0035 ip -netns "${PEER_NS}" link set dev veth1 up
0036
0037 ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section xdp
0038 ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
0039 ip netns exec "${PEER_NS}" ./udpgso_bench_rx -t ${rx_args} -r &
0040
0041
0042 sleep 0.1
0043 ./udpgso_bench_tx ${tx_args}
0044 }
0045
0046 run_in_netns() {
0047 local -r args=$@
0048
0049 ./in_netns.sh $0 __subprocess ${args}
0050 }
0051
0052 run_udp() {
0053 local -r args=$@
0054
0055 echo "udp gso - over veth touching data"
0056 run_in_netns ${args} -S 0 rx
0057
0058 echo "udp gso and gro - over veth touching data"
0059 run_in_netns ${args} -S 0 rx -G
0060 }
0061
0062 run_tcp() {
0063 local -r args=$@
0064
0065 echo "tcp - over veth touching data"
0066 run_in_netns ${args} -t rx
0067 }
0068
0069 run_all() {
0070 local -r core_args="-l 4"
0071 local -r ipv4_args="${core_args} -4 -D 192.168.1.1"
0072 local -r ipv6_args="${core_args} -6 -D 2001:db8::1"
0073
0074 echo "ipv4"
0075 run_tcp "${ipv4_args}"
0076 run_udp "${ipv4_args}"
0077
0078 echo "ipv6"
0079 run_tcp "${ipv4_args}"
0080 run_udp "${ipv6_args}"
0081 }
0082
0083 if [ ! -f ../bpf/xdp_dummy.o ]; then
0084 echo "Missing xdp_dummy helper. Build bpf selftest first"
0085 exit -1
0086 fi
0087
0088 if [[ $
0089 run_all
0090 elif [[ $1 == "__subprocess" ]]; then
0091 shift
0092 run_one $@
0093 else
0094 run_in_netns $@
0095 fi