* [PATCH net-next] selftests: netconsole: Validate interface selection by MAC address
@ 2025-08-11 18:32 Andre Carvalho
2025-08-12 14:01 ` Breno Leitao
0 siblings, 1 reply; 2+ messages in thread
From: Andre Carvalho @ 2025-08-11 18:32 UTC (permalink / raw)
To: Breno Leitao, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Shuah Khan
Cc: netdev, linux-kselftest, linux-kernel, Andre Carvalho
Extend the existing netconsole cmdline selftest to also validate that
interface selection can be performed via MAC address.
The test now validates that netconsole works with both interface name
and MAC address, improving test coverage.
Suggested-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Andre Carvalho <asantostc@gmail.com>
---
.../selftests/drivers/net/lib/sh/lib_netcons.sh | 10 +++-
.../selftests/drivers/net/netcons_cmdline.sh | 55 +++++++++++++---------
2 files changed, 42 insertions(+), 23 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh b/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh
index b6071e80ebbb6a33283ab6cd6bcb7b925aefdb43..8e1085e896472d5c87ec8b236240878a5b2d00d2 100644
--- a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh
+++ b/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh
@@ -148,12 +148,20 @@ function create_dynamic_target() {
# Generate the command line argument for netconsole following:
# netconsole=[+][src-port]@[src-ip]/[<dev>],[tgt-port]@<tgt-ip>/[tgt-macaddr]
function create_cmdline_str() {
+ local BINDMODE=${1:-"ifname"}
+ if [ "${BINDMODE}" == "ifname" ]
+ then
+ SRCDEV=${SRCIF}
+ else
+ SRCDEV=$(mac_get "${SRCIF}")
+ fi
+
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}\""
+ echo "netconsole=\"+${SRCPORT}@${SRCIP}/${SRCDEV},${TGTPORT}@${DSTIP}/${DSTMAC}\""
}
# Do not append the release to the header of the message
diff --git a/tools/testing/selftests/drivers/net/netcons_cmdline.sh b/tools/testing/selftests/drivers/net/netcons_cmdline.sh
index ad2fb8b1c46326c69af20f2c9d68e80fa8eb894f..a15149f3a905d7287258cd17f0e806fb50604cf4 100755
--- a/tools/testing/selftests/drivers/net/netcons_cmdline.sh
+++ b/tools/testing/selftests/drivers/net/netcons_cmdline.sh
@@ -17,10 +17,6 @@ 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
@@ -30,23 +26,38 @@ echo "6 5" > /proc/sys/kernel/printk
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}"
+
+# Run the test twice, with different cmdline parameters
+for BINDMODE in "ifname" "mac"
+do
+ echo "Running with bind mode: ${BINDMODE}"
+ # Create the command line for netconsole, with the configuration from the
+ # function above
+ CMDLINE="$(create_cmdline_str "${BINDMODE}")"
+
+ # The content of kmsg will be save to the following file
+ OUTPUT_FILE="/tmp/${TARGET}-${BINDMODE}"
+
+ # Unload the module, if present
+ rmmod netconsole 2> /dev/null || true
+ # 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}"
+
+ # kill socat in case it is still running
+ pkill_socat
+ echo "${BINDMODE} : Test passed" >&2
+done
exit "${ksft_pass}"
---
base-commit: 37816488247ddddbc3de113c78c83572274b1e2e
change-id: 20250807-netcons-cmdline-selftest-b32e27a4bd16
Best regards,
--
Andre Carvalho <asantostc@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] selftests: netconsole: Validate interface selection by MAC address
2025-08-11 18:32 [PATCH net-next] selftests: netconsole: Validate interface selection by MAC address Andre Carvalho
@ 2025-08-12 14:01 ` Breno Leitao
0 siblings, 0 replies; 2+ messages in thread
From: Breno Leitao @ 2025-08-12 14:01 UTC (permalink / raw)
To: Andre Carvalho
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Shuah Khan, netdev, linux-kselftest, linux-kernel
Hello Andre,
On Mon, Aug 11, 2025 at 07:32:09PM +0100, Andre Carvalho wrote:
> Extend the existing netconsole cmdline selftest to also validate that
> interface selection can be performed via MAC address.
>
> The test now validates that netconsole works with both interface name
> and MAC address, improving test coverage.
Thanks for adding this test!
> --- a/tools/testing/selftests/drivers/net/netcons_cmdline.sh
> +++ b/tools/testing/selftests/drivers/net/netcons_cmdline.sh
> @@ -17,10 +17,6 @@ source "${SCRIPTDIR}"/lib/sh/lib_netcons.sh
> +# Run the test twice, with different cmdline parameters
> +for BINDMODE in "ifname" "mac"
> +do
> + echo "Running with bind mode: ${BINDMODE}"
Please echo this message to stderr.
> + # Create the command line for netconsole, with the configuration from the
This is over 80 chars, move the 'the' word in to live below.
> + # function above
> + CMDLINE="$(create_cmdline_str "${BINDMODE}")"
I don't think these nested double quotes would work as expected. Maybe
something as:
CMDLINE=$(create_cmdline_str "${BINDMODE}")
> + # The content of kmsg will be save to the following file
> + OUTPUT_FILE="/tmp/${TARGET}-${BINDMODE}"
> +
> + # Unload the module, if present
> + rmmod netconsole 2> /dev/null || true
In this case, you do not want netconsole to fail to unload, otherwise
your test will fail, right?
You might want to remove '|| true' completely.
Other than that, the rest looks fine, and with the changes above, please
add:
Reviewed-by: Breno Leitao <leitao@debian.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-12 14:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11 18:32 [PATCH net-next] selftests: netconsole: Validate interface selection by MAC address Andre Carvalho
2025-08-12 14:01 ` Breno Leitao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).