tools/testing/selftests/drivers/net/netdevsim/hw_stats_l3.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/netdevsim/hw_stats_l3.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/netdevsim/hw_stats_l3.sh
Extension
.sh
Size
9377 bytes
Lines
422
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

lib_dir=$(dirname $0)/../../../net/forwarding

ALL_TESTS="
	l3_reporting_test
	l3_fail_next_test
	l3_counter_test
	l3_rollback_test
	l3_monitor_test
"

NETDEVSIM_PATH=/sys/bus/netdevsim/
DEV_ADDR_1=1337
DEV_ADDR_2=1057
DEV_ADDR_3=5417
NUM_NETIFS=0
source $lib_dir/lib.sh

DUMMY_IFINDEX=

DEV_ADDR()
{
	local n=$1; shift
	local var=DEV_ADDR_$n

	echo ${!var}
}

DEV()
{
	echo netdevsim$(DEV_ADDR $1)
}

DEVLINK_DEV()
{
	echo netdevsim/$(DEV $1)
}

SYSFS_NET_DIR()
{
	echo /sys/bus/netdevsim/devices/$(DEV $1)/net/
}

DEBUGFS_DIR()
{
	echo /sys/kernel/debug/netdevsim/$(DEV $1)/
}

nsim_add()
{
	local n=$1; shift

	echo "$(DEV_ADDR $n) 1" > ${NETDEVSIM_PATH}/new_device
	while [ ! -d $(SYSFS_NET_DIR $n) ] ; do :; done
}

nsim_reload()
{
	local n=$1; shift
	local ns=$1; shift

	devlink dev reload $(DEVLINK_DEV $n) netns $ns

	if [ $? -ne 0 ]; then
		echo "Failed to reload $(DEV $n) into netns \"testns1\""
		exit 1
	fi

Annotation

Implementation Notes