mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Add a new selftest to verify netconsole module loading with command line arguments. This test exercises the init_netconsole() path and validates proper parsing of the netconsole= parameter format. The test: - Loads netconsole module with cmdline configuration instead of dynamic reconfiguration - Validates message transmission through the configured target - Adds helper functions for cmdline string generation and module validation This complements existing netconsole selftests by covering the module initialization code path that processes boot-time parameters. This test is useful to test issues like the one described in [1]. Link: https://lore.kernel.org/netdev/Z36TlACdNMwFD7wv@dev-ushankar.dev.purestorage.com/ [1] Signed-off-by: Breno Leitao <leitao@debian.org> Link: https://patch.msgid.link/20250613-rework-v3-8-0752bf2e6912@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
52 lines
1.6 KiB
Bash
Executable file
52 lines
1.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
# This is a selftest to test cmdline arguments on netconsole.
|
|
# It exercises loading of netconsole from cmdline instead of the dynamic
|
|
# reconfiguration. This includes parsing the long netconsole= line and all the
|
|
# flow through init_netconsole().
|
|
#
|
|
# Author: Breno Leitao <leitao@debian.org>
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPTDIR=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
|
|
|
|
source "${SCRIPTDIR}"/lib/sh/lib_netcons.sh
|
|
|
|
check_netconsole_module
|
|
|
|
modprobe netdevsim 2> /dev/null || true
|
|
rmmod netconsole 2> /dev/null || true
|
|
|
|
# The content of kmsg will be save to the following file
|
|
OUTPUT_FILE="/tmp/${TARGET}"
|
|
|
|
# Check for basic system dependency and exit if not found
|
|
# check_for_dependencies
|
|
# Set current loglevel to KERN_INFO(6), and default to KERN_NOTICE(5)
|
|
echo "6 5" > /proc/sys/kernel/printk
|
|
# Remove the namespace and network interfaces
|
|
trap do_cleanup EXIT
|
|
# Create one namespace and two interfaces
|
|
set_network
|
|
# Create the command line for netconsole, with the configuration from the
|
|
# function above
|
|
CMDLINE="$(create_cmdline_str)"
|
|
|
|
# Load the module, with the cmdline set
|
|
modprobe netconsole "${CMDLINE}"
|
|
|
|
# Listed for netconsole port inside the namespace and destination interface
|
|
listen_port_and_save_to "${OUTPUT_FILE}" &
|
|
# Wait for socat to start and listen to the port.
|
|
wait_local_port_listen "${NAMESPACE}" "${PORT}" udp
|
|
# Send the message
|
|
echo "${MSG}: ${TARGET}" > /dev/kmsg
|
|
# Wait until socat saves the file to disk
|
|
busywait "${BUSYWAIT_TIMEOUT}" test -s "${OUTPUT_FILE}"
|
|
# Make sure the message was received in the dst part
|
|
# and exit
|
|
validate_msg "${OUTPUT_FILE}"
|
|
|
|
exit "${ksft_pass}"
|