cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

udpgro_bench.sh (2115B)


      1#!/bin/bash
      2# SPDX-License-Identifier: GPL-2.0
      3#
      4# Run a series of udpgro benchmarks
      5
      6readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
      7
      8cleanup() {
      9	local -r jobs="$(jobs -p)"
     10	local -r ns="$(ip netns list|grep $PEER_NS)"
     11
     12	[ -n "${jobs}" ] && kill -INT ${jobs} 2>/dev/null
     13	[ -n "$ns" ] && ip netns del $ns 2>/dev/null
     14}
     15trap cleanup EXIT
     16
     17run_one() {
     18	# use 'rx' as separator between sender args and receiver args
     19	local -r all="$@"
     20	local -r tx_args=${all%rx*}
     21	local rx_args=${all#*rx}
     22
     23	[[ "${tx_args}" == *"-4"* ]] && rx_args="${rx_args} -4"
     24
     25	ip netns add "${PEER_NS}"
     26	ip -netns "${PEER_NS}" link set lo up
     27	ip link add type veth
     28	ip link set dev veth0 up
     29	ip addr add dev veth0 192.168.1.2/24
     30	ip addr add dev veth0 2001:db8::2/64 nodad
     31
     32	ip link set dev veth1 netns "${PEER_NS}"
     33	ip -netns "${PEER_NS}" addr add dev veth1 192.168.1.1/24
     34	ip -netns "${PEER_NS}" addr add dev veth1 2001:db8::1/64 nodad
     35	ip -netns "${PEER_NS}" link set dev veth1 up
     36
     37	ip -n "${PEER_NS}" link set veth1 xdp object ../bpf/xdp_dummy.o section xdp
     38	ip netns exec "${PEER_NS}" ./udpgso_bench_rx ${rx_args} -r &
     39	ip netns exec "${PEER_NS}" ./udpgso_bench_rx -t ${rx_args} -r &
     40
     41	# Hack: let bg programs complete the startup
     42	sleep 0.1
     43	./udpgso_bench_tx ${tx_args}
     44}
     45
     46run_in_netns() {
     47	local -r args=$@
     48
     49	./in_netns.sh $0 __subprocess ${args}
     50}
     51
     52run_udp() {
     53	local -r args=$@
     54
     55	echo "udp gso - over veth touching data"
     56	run_in_netns ${args} -S 0 rx
     57
     58	echo "udp gso and gro - over veth touching data"
     59	run_in_netns ${args} -S 0 rx -G
     60}
     61
     62run_tcp() {
     63	local -r args=$@
     64
     65	echo "tcp - over veth touching data"
     66	run_in_netns ${args} -t rx
     67}
     68
     69run_all() {
     70	local -r core_args="-l 4"
     71	local -r ipv4_args="${core_args} -4 -D 192.168.1.1"
     72	local -r ipv6_args="${core_args} -6 -D 2001:db8::1"
     73
     74	echo "ipv4"
     75	run_tcp "${ipv4_args}"
     76	run_udp "${ipv4_args}"
     77
     78	echo "ipv6"
     79	run_tcp "${ipv4_args}"
     80	run_udp "${ipv6_args}"
     81}
     82
     83if [ ! -f ../bpf/xdp_dummy.o ]; then
     84	echo "Missing xdp_dummy helper. Build bpf selftest first"
     85	exit -1
     86fi
     87
     88if [[ $# -eq 0 ]]; then
     89	run_all
     90elif [[ $1 == "__subprocess" ]]; then
     91	shift
     92	run_one $@
     93else
     94	run_in_netns $@
     95fi