tools/testing/selftests/net/drop_monitor_tests.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/drop_monitor_tests.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/drop_monitor_tests.sh
Extension
.sh
Size
4449 bytes
Lines
217
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

# This test is for checking drop monitor functionality.
source lib.sh
ret=0

# all tests in this script. Can be overridden with -t option
TESTS="
	sw_drops
	hw_drops
"

NETDEVSIM_PATH=/sys/bus/netdevsim/
DEV_ADDR=1337
DEV=netdevsim${DEV_ADDR}
DEVLINK_DEV=netdevsim/${DEV}

log_test()
{
	local rc=$1
	local expected=$2
	local msg="$3"

	if [ ${rc} -eq ${expected} ]; then
		printf "    TEST: %-60s  [ OK ]\n" "${msg}"
		nsuccess=$((nsuccess+1))
	else
		ret=1
		nfail=$((nfail+1))
		printf "    TEST: %-60s  [FAIL]\n" "${msg}"
	fi
}

setup()
{
	modprobe netdevsim &> /dev/null

	set -e
	setup_ns NS1
	$IP link add dummy10 up type dummy

	$NS_EXEC echo "$DEV_ADDR 1" > ${NETDEVSIM_PATH}/new_device
	udevadm settle
	local netdev=$($NS_EXEC ls ${NETDEVSIM_PATH}/devices/${DEV}/net/)
	$IP link set dev $netdev up

	set +e
}

cleanup()
{
	$NS_EXEC echo "$DEV_ADDR" > ${NETDEVSIM_PATH}/del_device
	cleanup_ns ${NS1}
}

sw_drops_test()
{
	echo
	echo "Software drops test"

	setup

	local dir=$(mktemp -d)

	$TC qdisc add dev dummy10 clsact
	$TC filter add dev dummy10 egress pref 1 handle 101 proto ip \
		flower dst_ip 192.0.2.10 action drop

	$NS_EXEC mausezahn dummy10 -a 00:11:22:33:44:55 -b 00:aa:bb:cc:dd:ee \

Annotation

Implementation Notes