Re: [PATCH net-next v5] net: netconsole: selftests: Create a new netconsole selftest

Jakub Kicinski
2024-08-20T23:06:38Z

On Mon, 19 Aug 2024 02:03:53 -0700 Breno Leitao wrote:
> +function check_for_dependencies() {
> + if [ "$(id -u)" -ne 0 ]; then
> + echo "This test must be run as root" >&2
> + exit "${ksft_skip}"
> + fi
> +
> + if ! which socat > /dev/null ; then
> + echo "SKIP: socat(1) is not available" >&2
> + exit "${ksft_skip}"
> + fi
> +
> + if ! which ip > /dev/null ; then
> + echo "SKIP: ip(1) is not available" >&2
> + exit "${ksft_skip}"
> + fi
> +
> + if ! which udevadm > /dev/null ; then
> + echo "SKIP: udevadm(1) is not available" >&2
> + exit "${ksft_skip}"
> + fi
> +
> + if [ ! -d "${NETCONS_CONFIGFS}" ]; then
> + echo "SKIP: directory ${NETCONS_CONFIGFS} does not exist. Check if NETCONSOLE_DYNAMIC is enabled" >&2
> + exit "${ksft_skip}"
> + fi
> +
> + if ip link show "${DSTIF}" 2> /dev/null; then
> + echo "SKIP: interface ${DSTIF} exists in the system. Not overwriting it." >&2
> + exit "${ksft_skip}"
> + fi

nit: maybe ip addr list to see if the 192.168.1.x network is already in
use?

> +}
> +
> +# ========== #
> +# Start here #
> +# ========== #
> +modprobe netdevsim 2> /dev/null || true
> +modprobe 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

nit: should we not undo this in clenaup?

> +# Remove the namespace, interfaces and netconsole target on exit
> +trap cleanup EXIT
> +# Create one namespace and two interfaces
> +set_network
> +# Create a dynamic target for netconsole
> +create_dynamic_target
> +# 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_result "${OUTPUT_FILE}"

Main reason Im complaining, I see:

[ 6.686720] netconsole: unknown parameter '2' ignored

in the kernel logs when the test runs.

Is it expected?
--
pw-bot: cr