tools/testing/selftests/net/lwt_dst_cache_ref_loop.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/net/lwt_dst_cache_ref_loop.sh
Extension
.sh
Size
6081 bytes
Lines
247
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+
#
# Author: Justin Iurman <justin.iurman@uliege.be>
#
# WARNING
# -------
# This is just a dummy script that triggers encap cases with possible dst cache
# reference loops in affected lwt users (see list below). Some cases are
# pathological configurations for simplicity, others are valid. Overall, we
# don't want this issue to happen, no matter what. In order to catch any
# reference loops, kmemleak MUST be used. The results alone are always blindly
# successful, don't rely on them. Note that the following tests may crash the
# kernel if the fix to prevent lwtunnel_{input|output|xmit}() reentry loops is
# not present.
#
# Affected lwt users so far (please update accordingly if needed):
#  - ila_lwt (output only)
#  - ioam6_iptunnel (output only)
#  - rpl_iptunnel (both input and output)
#  - seg6_iptunnel (both input and output)

source lib.sh

check_compatibility()
{
	setup_ns tmp_node &>/dev/null
	if [ $? != 0 ]; then
		echo "SKIP: Cannot create netns."
		exit $ksft_skip
	fi

	ip link add name veth0 netns $tmp_node type veth \
		peer name veth1 netns $tmp_node &>/dev/null
	local ret=$?

	ip -netns $tmp_node link set veth0 up &>/dev/null
	ret=$((ret + $?))

	ip -netns $tmp_node link set veth1 up &>/dev/null
	ret=$((ret + $?))

	if [ $ret != 0 ]; then
		echo "SKIP: Cannot configure links."
		cleanup_ns $tmp_node
		exit $ksft_skip
	fi

	lsmod 2>/dev/null | grep -q "ila"
	ila_lsmod=$?
	[ $ila_lsmod != 0 ] && modprobe ila &>/dev/null

	ip -netns $tmp_node route add 2001:db8:1::/64 \
		encap ila 1:2:3:4 csum-mode no-action ident-type luid \
			hook-type output \
		dev veth0 &>/dev/null

	ip -netns $tmp_node route add 2001:db8:2::/64 \
		encap ioam6 trace prealloc type 0x800000 ns 0 size 4 \
		dev veth0 &>/dev/null

	ip -netns $tmp_node route add 2001:db8:3::/64 \
		encap rpl segs 2001:db8:3::1 dev veth0 &>/dev/null

	ip -netns $tmp_node route add 2001:db8:4::/64 \
		encap seg6 mode inline segs 2001:db8:4::1 dev veth0 &>/dev/null

	ip -netns $tmp_node -6 route 2>/dev/null | grep -q "encap ila"
	skip_ila=$?

Annotation

Implementation Notes