The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Matthieu Baerts <matttbe@kernel.org>
To: Andre Carvalho <asantostc@gmail.com>, Breno Leitao <leitao@debian.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Shuah Khan <shuah@kernel.org>, Simon Horman <horms@kernel.org>
Subject: Re: [PATCH net-next v11 7/7] selftests: netconsole: validate target resume
Date: Wed, 8 Jul 2026 17:50:53 +0200	[thread overview]
Message-ID: <f398373e-2cb4-4649-a491-9763df94d98b@kernel.org> (raw)
In-Reply-To: <20260118-netcons-retrigger-v11-7-4de36aebcf48@gmail.com>

Hi Andre, Breno,

On 18/01/2026 12:00, Andre Carvalho wrote:
> Introduce a new netconsole selftest to validate that netconsole is able
> to resume a deactivated target when the low level interface comes back.
> 
> The test setups the network using netdevsim, creates a netconsole target
> and then remove/add netdevsim in order to bring the same interfaces
> back. Afterwards, the test validates that the target works as expected.
> 
> Targets are created via cmdline parameters to the module to ensure that
> we are able to resume targets that were bound by mac and interface name.

I'm sorry to react on this "old" patch, but I have some troubles running
this netcons_resume.sh test in a new environment with containers.

> diff --git a/tools/testing/selftests/drivers/net/netcons_resume.sh b/tools/testing/selftests/drivers/net/netcons_resume.sh
> new file mode 100755
> index 000000000000..fc5e5e3ad3d4
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/net/netcons_resume.sh

(...)

> +function trigger_reactivation() {
> +	# Add back low level module
> +	modprobe netdevsim
> +	# Recreate namespace and two interfaces
> +	set_network
> +	# Restore MACs
> +	ip netns exec "${NAMESPACE}" ip link set "${DSTIF}" \
> +		address "${SAVED_DSTMAC}"
> +	if [ "${BINDMODE}" == "mac" ]; then
> +		ip link set dev "${SRCIF}" down
> +		ip link set dev "${SRCIF}" address "${SAVED_SRCMAC}"
> +		# Rename device in order to trigger target resume, as initial
> +		# when device was recreated it didn't have correct mac address.
> +		ip link set dev "${SRCIF}" name "${TARGET}"

When I execute the test, the "ifname" bind mode works without issues,
but the "mac" one not. From what I see, the socat process doesn't get
any UDP packet when expected. I wonder if the problem might not come
from here: the interface is disabled before changing the MAC address and
renaming the interface, but not re-enabled at the end. Is it normal?

If I add 'up' at the end of this last line here, or if I remove the
whole if-statement block, the test passes.

In the console, I can see these messages, with or without re-enabling
the interface:

  netdevsim netdevsim642 eni642np1: renamed from eth0
  netdevsim netdevsim387 eni387np1: renamed from eth1
  netconsole: netconsole: local port 1514
  netconsole: netconsole: local IPv4 address 192.0.2.1
  netconsole: netconsole: interface name ''
  netconsole: netconsole: local ethernet address '1e:95:b7:ae:ab:dc'
  netconsole: netconsole: remote port 6666
  netconsole: netconsole: remote IPv4 address 192.0.2.2
  netconsole: netconsole: remote ethernet address e6:12:42:f8:4c:b2
  printk: console [netcon_ext0] enabled
  netconsole: network logging started
  netconsole: network logging stopped on interface eni387np1 as it
unregistered
  netdevsim netdevsim642 eni642np1: renamed from eth0
  netdevsim netdevsim387 eni387np1: renamed from eth1
  netconsole: Process resuming  (mac: 1e:95:b7:ae:ab:dc), s:2, r:-1
  netpoll: netconsole: device 1e:95:b7:ae:ab:dc not up yet, forcing it
  netconsole: network logging resumed on interface eni387np1
  netdevsim netdevsim387 netcons_LFLQP: renamed from eni387np1
  netconsole selftest: netcons_LFLQP

The "network logging resumed on interface" seems to suggest that the
previous patch of this series here, commit 220dbe3c76ed ("netconsole:
resume previously deactivated target"), managed to resume the previously
activated target, but not in my case.

What I don't understand is why is it working on the Netdev CI, and not
on my side. The main difference is that I might be missing some
userspace packages -- but I don't see what can be missing here, all
other netconsole tests pass -- a specific kernel config, or not applied
patch. Or something different on the host -- in a container on my side
-- but there shouldn't be any interactions with the host here,
everything is happening in the VM. Any ideas? :)

> +	fi
> +}
> +
> +function trigger_deactivation() {
> +	# Start by storing mac addresses so we can be restored in reactivate
> +	SAVED_DSTMAC=$(ip netns exec "${NAMESPACE}" \
> +		cat /sys/class/net/"$DSTIF"/address)
> +	SAVED_SRCMAC=$(mac_get "${SRCIF}")
> +	# Remove low level module
> +	rmmod netdevsim
> +}
> +
> +trap cleanup EXIT
> +
> +# Run the test twice, with different cmdline parameters
> +for BINDMODE in "ifname" "mac"
> +do
> +	echo "Running with bind mode: ${BINDMODE}" >&2
> +	# Set current loglevel to KERN_INFO(6), and default to KERN_NOTICE(5)
> +	echo "6 5" > /proc/sys/kernel/printk

Can we remove this? Without that, it is hard to understand what went
wrong in case of issues.

> +
> +	# 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 "${BINDMODE}")
> +
> +	# The content of kmsg will be save to the following file
> +	OUTPUT_FILE="/tmp/${TARGET}-${BINDMODE}"
> +
> +	# Load the module, with the cmdline set
> +	modprobe netconsole "${CMDLINE}"
> +	# Expose cmdline target in configfs
> +	mkdir "${NETCONS_CONFIGFS}/cmdline0"
> +
> +	# Target should be enabled
> +	wait_target_state "cmdline0" "enabled"
> +
> +	# Trigger deactivation by unloading netdevsim module. Target should be
> +	# disabled.
> +	trigger_deactivation
> +	wait_target_state "cmdline0" "disabled"
> +
> +	# Trigger reactivation by loading netdevsim, recreating the network and
> +	# restoring mac addresses. Target should be re-enabled.
> +	trigger_reactivation
> +	wait_target_state "cmdline0" "enabled"
> +
> +	# Listen 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}"

In my case, the script was stopping here, without any message. I can
send a patch adding "|| true" to go to the next instruction, and display
"FAIL: File was not generated.".

> +	# 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
> +	# Cleanup & unload the module
> +	cleanup
> +
> +	echo "${BINDMODE} : Test passed" >&2
> +done
> +
> +trap - EXIT
> +exit "${EXIT_STATUS}"
> 

Cheers,
Matt

  parent reply	other threads:[~2026-07-08 15:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-18 11:00 [PATCH net-next v11 0/7] netconsole: support automatic target recovery Andre Carvalho
2026-01-18 11:00 ` [PATCH net-next v11 1/7] netconsole: add target_state enum Andre Carvalho
2026-01-18 11:00 ` [PATCH net-next v11 2/7] netconsole: convert 'enabled' flag to enum for clearer state management Andre Carvalho
2026-01-18 11:00 ` [PATCH net-next v11 3/7] netconsole: add STATE_DEACTIVATED to track targets disabled by low level Andre Carvalho
2026-01-18 11:00 ` [PATCH net-next v11 4/7] netconsole: clear dev_name for devices bound by mac Andre Carvalho
2026-01-19 13:06   ` Breno Leitao
2026-01-18 11:00 ` [PATCH net-next v11 5/7] netconsole: introduce helpers for dynamic_netconsole_mutex lock/unlock Andre Carvalho
2026-01-19 13:10   ` Breno Leitao
2026-01-18 11:00 ` [PATCH net-next v11 6/7] netconsole: resume previously deactivated target Andre Carvalho
2026-01-20 11:37   ` Breno Leitao
2026-01-18 11:00 ` [PATCH net-next v11 7/7] selftests: netconsole: validate target resume Andre Carvalho
2026-01-21  1:20   ` Jakub Kicinski
2026-01-21 22:04     ` Andre Carvalho
2026-01-22  1:45       ` Jakub Kicinski
2026-01-22 17:51         ` Andre Carvalho
2026-07-08 15:50   ` Matthieu Baerts [this message]
2026-07-08 20:24     ` Andre Carvalho
2026-07-09 10:21       ` Matthieu Baerts
2026-07-09 20:13         ` Andre Carvalho
2026-01-20 11:39 ` [PATCH net-next v11 0/7] netconsole: support automatic target recovery Breno Leitao
2026-01-22  3:20 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f398373e-2cb4-4649-a491-9763df94d98b@kernel.org \
    --to=matttbe@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=asantostc@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox