mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
selftests: net: add netconsole test for cmdline configuration
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>
This commit is contained in:
committed by
Jakub Kicinski
parent
bed365ca56
commit
69d094ef69
@@ -121,6 +121,17 @@ function create_dynamic_target() {
|
||||
echo 1 > "${NETCONS_PATH}"/enabled
|
||||
}
|
||||
|
||||
# Generate the command line argument for netconsole following:
|
||||
# netconsole=[+][src-port]@[src-ip]/[<dev>],[tgt-port]@<tgt-ip>/[tgt-macaddr]
|
||||
function create_cmdline_str() {
|
||||
DSTMAC=$(ip netns exec "${NAMESPACE}" \
|
||||
ip link show "${DSTIF}" | awk '/ether/ {print $2}')
|
||||
SRCPORT="1514"
|
||||
TGTPORT="6666"
|
||||
|
||||
echo "netconsole=\"+${SRCPORT}@${SRCIP}/${SRCIF},${TGTPORT}@${DSTIP}/${DSTMAC}\""
|
||||
}
|
||||
|
||||
# Do not append the release to the header of the message
|
||||
function disable_release_append() {
|
||||
echo 0 > "${NETCONS_PATH}"/enabled
|
||||
@@ -173,13 +184,9 @@ function listen_port_and_save_to() {
|
||||
socat UDP-LISTEN:"${PORT}",fork "${OUTPUT}"
|
||||
}
|
||||
|
||||
function validate_result() {
|
||||
# Only validate that the message arrived properly
|
||||
function validate_msg() {
|
||||
local TMPFILENAME="$1"
|
||||
local FORMAT=${2:-"extended"}
|
||||
|
||||
# TMPFILENAME will contain something like:
|
||||
# 6.11.1-0_fbk0_rc13_509_g30d75cea12f7,13,1822,115075213798,-;netconsole selftest: netcons_gtJHM
|
||||
# key=value
|
||||
|
||||
# Check if the file exists
|
||||
if [ ! -f "$TMPFILENAME" ]; then
|
||||
@@ -192,6 +199,17 @@ function validate_result() {
|
||||
cat "${TMPFILENAME}" >&2
|
||||
exit "${ksft_fail}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Validate the message and userdata
|
||||
function validate_result() {
|
||||
local TMPFILENAME="$1"
|
||||
|
||||
# TMPFILENAME will contain something like:
|
||||
# 6.11.1-0_fbk0_rc13_509_g30d75cea12f7,13,1822,115075213798,-;netconsole selftest: netcons_gtJHM
|
||||
# key=value
|
||||
|
||||
validate_msg "${TMPFILENAME}"
|
||||
|
||||
# userdata is not supported on basic format target,
|
||||
# thus, do not validate it.
|
||||
@@ -267,3 +285,12 @@ function pkill_socat() {
|
||||
pkill -f "${PROCESS_NAME}"
|
||||
set -e
|
||||
}
|
||||
|
||||
# Check if netconsole was compiled as a module, otherwise exit
|
||||
function check_netconsole_module() {
|
||||
if modinfo netconsole | grep filename: | grep -q builtin
|
||||
then
|
||||
echo "SKIP: netconsole should be compiled as a module" >&2
|
||||
exit "${ksft_skip}"
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user