Skip to contentSkip to conversation

net: selftest: Introduce netconsole torture test

PATCH Superseded Breno Leitao 3 participants 6 messages Sep 4, 2025 – Sep 5, 2025

Subsystems (4)

v2 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Breno Leitao

author maintainer
#0 lore raw

v2 cover net: selftest: Introduce netconsole torture test

Create a netconsole test that puts a lot of pressure on the netconsole list manipulation. Do it by creating dynamic targets and deleting targets while messages are being sent. Also put interface down while the

In order to do it, refactor create_dynamic_target(), so it can be used to create random targets in the torture test.

---
Changes in v2:
- Reuse the netconsole creation from lib_netcons.sh. Thus, refactoring
the create_dynamic_target() (Jakub)
- Move the "wait" to after all the messages has been sent.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Breno Leitao (2):
selftest: netcons: refactor target creation
selftest: netcons: create a torture test

 tools/testing/selftests/drivers/net/Makefile       |   1 +
 .../selftests/drivers/net/lib/sh/lib_netcons.sh    |  30 +++--
 .../selftests/drivers/net/netcons_torture.sh       | 127 +++++++++++++++++++++
 3 files changed, 147 insertions(+), 11 deletions(-)

---
base-commit: 2fd4161d0d2547650d9559d57fc67b4e0a26a9e3
change-id: 20250902-netconsole_torture-8fc23f0aca99

Best regards,

Signature · 1 line
Breno Leitao <[email protected]>
author maintainer
#1 lore raw

PATCH v2 1/2 selftest: netcons: refactor target creation

Extract the netconsole target creation from create_dynamic_target(), by moving it from create_dynamic_target() into a new helper function. This enables other tests to use the creation of netconsole targets with arbitrary parameters and no sleep.

The new helper will be utilized by forthcoming torture-type selftests that require dynamic target management.

---
 .../selftests/drivers/net/lib/sh/lib_netcons.sh    | 30 ++++++++++++++--------
 1 file changed, 19 insertions(+), 11 deletions(-)
tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh +19 -11
index 8e1085e896472..9b5ef8074440c 100644
@@ -113,31 +113,39 @@ function set_network() {
 	configure_ip
 }
 
-function create_dynamic_target() {
-	local FORMAT=${1:-"extended"}
+function _create_dynamic_target() {
+	local FORMAT="${1:?FORMAT parameter required}"
+	local NCPATH="${2:?NCPATH parameter required}"
 
 	DSTMAC=$(ip netns exec "${NAMESPACE}" \
 		 ip link show "${DSTIF}" | awk '/ether/ {print $2}')
 
 	# Create a dynamic target
-	mkdir "${NETCONS_PATH}"
+	mkdir "${NCPATH}"
 
-	echo "${DSTIP}" > "${NETCONS_PATH}"/remote_ip
-	echo "${SRCIP}" > "${NETCONS_PATH}"/local_ip
-	echo "${DSTMAC}" > "${NETCONS_PATH}"/remote_mac
-	echo "${SRCIF}" > "${NETCONS_PATH}"/dev_name
+	echo "${DSTIP}" > "${NCPATH}"/remote_ip
+	echo "${SRCIP}" > "${NCPATH}"/local_ip
+	echo "${DSTMAC}" > "${NCPATH}"/remote_mac
+	echo "${SRCIF}" > "${NCPATH}"/dev_name
 
 	if [ "${FORMAT}" == "basic" ]
 	then
 		# Basic target does not support release
-		echo 0 > "${NETCONS_PATH}"/release
-		echo 0 > "${NETCONS_PATH}"/extended
+		echo 0 > "${NCPATH}"/release
+		echo 0 > "${NCPATH}"/extended
 	elif [ "${FORMAT}" == "extended" ]
 	then
-		echo 1 > "${NETCONS_PATH}"/extended
+		echo 1 > "${NCPATH}"/extended
 	fi
 
-	echo 1 > "${NETCONS_PATH}"/enabled
+	echo 1 > "${NCPATH}"/enabled
+
+}
+
+function create_dynamic_target() {
+	local FORMAT=${1:-"extended"}
+	local NCPATH=${2:-"$NETCONS_PATH"}
+	_create_dynamic_target "${FORMAT}" "${NCPATH}"
 
 	# This will make sure that the kernel was able to
 	# load the netconsole driver configuration. The console message
Signature · 1 line
2.47.3
author maintainer
#2 lore raw

PATCH v2 2/2 selftest: netcons: create a torture test

In reply to Breno Leitao

Create a netconsole test that puts a lot of pressure on the netconsole list manipulation. Do it by creating dynamic targets and deleting targets while messages are being sent. Also put interface down while the messages are being sent, as creating parallel targets.

The code launches three background jobs on distinct schedules:

* Toggle netcons target every 30 iterations
* create and delete random_target every 50 iterations
* toggle iface every 70 iterations

This creates multiple concurrency sources that interact with netconsole states. This is good practice to simulate stress, and exercise netpoll and netconsole locks.

This test already found an issue as reported in [1]

---
 tools/testing/selftests/drivers/net/Makefile       |   1 +
 .../selftests/drivers/net/netcons_torture.sh       | 127 +++++++++++++++++++++
 2 files changed, 128 insertions(+)
tools/testing/selftests/drivers/net/Makefile +1 -0
index 984ece05f7f92..2b253b1ff4f38 100644
@@ -17,6 +17,7 @@ TEST_PROGS := \
 	netcons_fragmented_msg.sh \
 	netcons_overflow.sh \
 	netcons_sysdata.sh \
+	netcons_torture.sh \
 	netpoll_basic.py \
 	ping.py \
 	queues.py \
tools/testing/selftests/drivers/net/netcons_torture.sh new file +127 -0

127 lines not on this page · raw message

Signature · 1 line
2.47.3
Reviewed-by on v2 2/2
#3 lore raw

Re: [PATCH net-next v2 2/2] selftest: netcons: create a torture test

tools/testing/selftests/drivers/net/netcons_torture.sh line 9

Quoted 2 lines · Breno Leitao
tools/testing/selftests/drivers/net/netcons_torture.sh new file +2 -0
+# This test aims verify the robustness of netconsole under dynamic
+# configurations and concurrent operations.

Just a small nit: "aims to verify" or simply "verifies".

maintainer
#4 lore raw
In reply to Breno Leitao
Quoted 6 lines · On Thu, 04 Sep 2025 11:00:39 -0700 Breno Leitao wrote:

Create a netconsole test that puts a lot of pressure on the netconsole list manipulation. Do it by creating dynamic targets and deleting targets while messages are being sent. Also put interface down while the

In order to do it, refactor create_dynamic_target(), so it can be used to create random targets in the torture test.

You either have to post it in the same series as the fix, or wait for the fix to be present in net-next. Without your pending fix this will obviously not pass thru the CI :/

author maintainer
#5 lore raw
Quoted 11 lines · Jakub Kicinski
Quoted 6 lines · On Thu, 04 Sep 2025 11:00:39 -0700 Breno Leitao wrote:

Create a netconsole test that puts a lot of pressure on the netconsole list manipulation. Do it by creating dynamic targets and deleting targets while messages are being sent. Also put interface down while the

In order to do it, refactor create_dynamic_target(), so it can be used to create random targets in the torture test.

You either have to post it in the same series as the fix, or wait for the fix to be present in net-next. Without your pending fix this will obviously not pass thru the CI :/

Ack! I've sent the netpoll fix and the selftest in the same patchset, as you suggested.

https://lore.kernel.org/all/[email protected]/

--breno