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

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/netdevsim/fib_notifications.sh
Extension
.sh
Size
10376 bytes
Lines
431
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="
	ipv4_route_addition_test
	ipv4_route_deletion_test
	ipv4_route_replacement_test
	ipv4_route_offload_failed_test
	ipv6_route_addition_test
	ipv6_route_deletion_test
	ipv6_route_replacement_test
	ipv6_route_offload_failed_test
"

NETDEVSIM_PATH=/sys/bus/netdevsim/
DEV_ADDR=1337
DEV=netdevsim${DEV_ADDR}
DEVLINK_DEV=netdevsim/${DEV}
SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV/net/
DEBUGFS_DIR=/sys/kernel/debug/netdevsim/$DEV/
NUM_NETIFS=0
source $lib_dir/lib.sh

check_rt_offload_failed()
{
	local outfile=$1; shift
	local line

	# Make sure that the first notification was emitted without
	# RTM_F_OFFLOAD_FAILED flag and the second with RTM_F_OFFLOAD_FAILED
	# flag
	head -n 1 $outfile | grep -q "rt_offload_failed"
	if [[ $? -eq 0 ]]; then
		return 1
	fi

	head -n 2 $outfile | tail -n 1 | grep -q "rt_offload_failed"
}

check_rt_trap()
{
	local outfile=$1; shift
	local line

	# Make sure that the first notification was emitted without RTM_F_TRAP
	# flag and the second with RTM_F_TRAP flag
	head -n 1 $outfile | grep -q "rt_trap"
	if [[ $? -eq 0 ]]; then
		return 1
	fi

	head -n 2 $outfile | tail -n 1 | grep -q "rt_trap"
}

route_notify_check()
{
	local outfile=$1; shift
	local expected_num_lines=$1; shift
	local offload_failed=${1:-0}; shift

	# check the monitor results
	lines=`wc -l $outfile | cut "-d " -f1`
	test $lines -eq $expected_num_lines
	check_err $? "$expected_num_lines notifications were expected but $lines were received"

	if [[ $expected_num_lines -eq 1 ]]; then
		return
	fi

Annotation

Implementation Notes