1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3# 4# Run a series of udpgso benchmarks 5 6wake_children() { 7 local -r jobs="$(jobs -p)" 8 9 if [[ "${jobs}" != "" ]]; then 10 kill -1 ${jobs} 2>/dev/null 11 fi 12} 13trap wake_children EXIT 14 15run_one() { 16 local -r args=$@ 17 18 ./udpgso_bench_rx & 19 ./udpgso_bench_rx -t & 20 21 ./udpgso_bench_tx ${args} 22} 23 24run_in_netns() { 25 local -r args=$@ 26 27 ./in_netns.sh $0 __subprocess ${args} 28} 29 30run_udp() { 31 local -r args=$@ 32 33 echo "udp" 34 run_in_netns ${args} 35 36 echo "udp gso" 37 run_in_netns ${args} -S 0 38 39 echo "udp gso zerocopy" 40 run_in_netns ${args} -S 0 -z 41} 42 43run_tcp() { 44 local -r args=$@ 45 46 echo "tcp" 47 run_in_netns ${args} -t 48 49 echo "tcp zerocopy" 50 run_in_netns ${args} -t -z 51} 52 53run_all() { 54 local -r core_args="-l 4" 55 local -r ipv4_args="${core_args} -4 -D 127.0.0.1" 56 local -r ipv6_args="${core_args} -6 -D ::1" 57 58 echo "ipv4" 59 run_tcp "${ipv4_args}" 60 run_udp "${ipv4_args}" 61 62 echo "ipv6" 63 run_tcp "${ipv4_args}" 64 run_udp "${ipv6_args}" 65} 66 67if [[ $# -eq 0 ]]; then 68 run_all 69elif [[ $1 == "__subprocess" ]]; then 70 shift 71 run_one $@ 72else 73 run_in_netns $@ 74fi 75