brintos

brintos / linux-shallow public Read only

0
0
Text · 2.5 KiB · 0aa71c4 Raw
108 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4readonly NS="ns1-$(mktemp -u XXXXXX)"5readonly V0_IP4=10.10.0.116readonly V1_IP4=10.10.0.17readonly V0_IP6=2001:db8::118readonly V1_IP6=2001:db8::19 10ret=111 12setup() {13	{14		ip netns add ${NS}15 16		ip link add v1 type veth peer name v0 netns ${NS}17 18		ip link set v1 up19		ip addr add $V1_IP4/24 dev v120		ip addr add $V1_IP6/64 nodad dev v121		ip -n ${NS} link set dev v0 up22		ip -n ${NS} addr add $V0_IP4/24 dev v023		ip -n ${NS} addr add $V0_IP6/64 nodad dev v024 25		# Enable XDP mode and disable checksum offload26		ethtool -K v1 gro on27		ethtool -K v1 tx-checksumming off28		ip netns exec ${NS} ethtool -K v0 gro on29		ip netns exec ${NS} ethtool -K v0 tx-checksumming off30	} > /dev/null 2>&131}32 33cleanup() {34	ip link del v1 2> /dev/null35	ip netns del ${NS} 2> /dev/null36	[ "$(pidof xdp_features)" = "" ] || kill $(pidof xdp_features) 2> /dev/null37}38 39wait_for_dut_server() {40	while sleep 1; do41		ss -tlp | grep -q xdp_features42		[ $? -eq 0 ] && break43	done44}45 46test_xdp_features() {47	setup48 49	## XDP_PASS50	./xdp_features -f XDP_PASS -D $V1_IP6 -T $V0_IP6 v1 &51	wait_for_dut_server52	ip netns exec ${NS} ./xdp_features -t -f XDP_PASS \53					   -D $V1_IP6 -C $V1_IP6 \54					   -T $V0_IP6 v055	[ $? -ne 0 ] && exit56 57	## XDP_DROP58	./xdp_features -f XDP_DROP -D ::ffff:$V1_IP4 -T ::ffff:$V0_IP4 v1 &59	wait_for_dut_server60	ip netns exec ${NS} ./xdp_features -t -f XDP_DROP \61					   -D ::ffff:$V1_IP4 \62					   -C ::ffff:$V1_IP4 \63					   -T ::ffff:$V0_IP4 v064	[ $? -ne 0 ] && exit65 66	## XDP_ABORTED67	./xdp_features -f XDP_ABORTED -D $V1_IP6 -T $V0_IP6 v1 &68	wait_for_dut_server69	ip netns exec ${NS} ./xdp_features -t -f XDP_ABORTED \70					   -D $V1_IP6 -C $V1_IP6 \71					   -T $V0_IP6 v072	[ $? -ne 0 ] && exit73 74	## XDP_TX75	./xdp_features -f XDP_TX -D ::ffff:$V1_IP4 -T ::ffff:$V0_IP4 v1 &76	wait_for_dut_server77	ip netns exec ${NS} ./xdp_features -t -f XDP_TX \78					   -D ::ffff:$V1_IP4 \79					   -C ::ffff:$V1_IP4 \80					   -T ::ffff:$V0_IP4 v081	[ $? -ne 0 ] && exit82 83	## XDP_REDIRECT84	./xdp_features -f XDP_REDIRECT -D $V1_IP6 -T $V0_IP6 v1 &85	wait_for_dut_server86	ip netns exec ${NS} ./xdp_features -t -f XDP_REDIRECT \87					   -D $V1_IP6 -C $V1_IP6 \88					   -T $V0_IP6 v089	[ $? -ne 0 ] && exit90 91	## XDP_NDO_XMIT92	./xdp_features -f XDP_NDO_XMIT -D ::ffff:$V1_IP4 -T ::ffff:$V0_IP4 v1 &93	wait_for_dut_server94	ip netns exec ${NS} ./xdp_features -t -f XDP_NDO_XMIT \95					   -D ::ffff:$V1_IP4 \96					   -C ::ffff:$V1_IP4 \97					   -T ::ffff:$V0_IP4 v098	ret=$?99	cleanup100}101 102set -e103trap cleanup 2 3 6 9104 105test_xdp_features106 107exit $ret108