public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Andre Carvalho <asantostc@gmail.com>
Cc: Breno Leitao <leitao@debian.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Shuah Khan <shuah@kernel.org>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v10 7/7] selftests: netconsole: validate target resume
Date: Sat, 17 Jan 2026 09:22:27 -0800	[thread overview]
Message-ID: <20260117092227.741cba3b@kernel.org> (raw)
In-Reply-To: <aWqkhT_-4UoNHX6F@archlinux>

On Fri, 16 Jan 2026 21:01:22 +0000 Andre Carvalho wrote:
> On Mon, Jan 12, 2026 at 06:16:42AM -0800, Jakub Kicinski wrote:
> > On Mon, 12 Jan 2026 09:40:58 +0000 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.  
> > 
> > The new test seems to be failing in netdev CI:
> > 
> > TAP version 13
> > 1..1
> > # timeout set to 180
> > # selftests: drivers/net: netcons_resume.sh
> > # Running with bind mode: ifname
> > not ok 1 selftests: drivers/net: netcons_resume.sh # exit=1
> > -- 
> > pw-bot: cr  
> 
> I've finally been able to reproduce this locally. The issue is caused by the
> fact that the test currently expects that mac addresses for netdevsim devices are
> deterministic. This is the case on my setup as systemd enforces it (MACAddressPolicy=persistent).

Argh, systemd strikes again :(

> I was able to disable this behaviour by setting up /etc/systemd/network/50-netdevsim.link, with:
> 
> [Match]
> Driver=netdevsim
> 
> [Link]
> MACAddressPolicy=none
> 
> I'm assuming this is also the behaviour on CI hosts. 

Yes, systemd changing the MAC address is racy - it does it too slowly
and some tests start doing their thing, then systemd comes in and flips
the address. So indeed:

# cat /etc/systemd/network/99-default.link
[Match]
OriginalName=*

[Link]
NamePolicy=keep kernel database onboard slot path
AlternativeNamesPolicy=database onboard slot path mac
MACAddressPolicy=none

> I have started working on a fix
> for this test and will submit v11 once that is ready. The approach I'm taking is saving and
> restoring the mac addresses once I reload netdevsim module. Example code below (needs more testing):
> 
> function deactivate() {
> 	# 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
> }
> 
> function reactivate() {
> 	# 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 didnt have correct mac address.
> 		ip link set dev "${SRCIF}" name "${TARGET}"
> 	fi
> }
> 
> The main annoyance is that to test resuming when a device was bound by mac I actually need
> to change the name of the device after restoring the mac address (since when the device 
> is registered after deactivation the mac won't match).

Workaround sounds reasonable, FWIW.

      reply	other threads:[~2026-01-17 17:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-12  9:40 [PATCH net-next v10 0/7] netconsole: support automatic target recovery Andre Carvalho
2026-01-12  9:40 ` [PATCH net-next v10 1/7] netconsole: add target_state enum Andre Carvalho
2026-01-12  9:40 ` [PATCH net-next v10 2/7] netconsole: convert 'enabled' flag to enum for clearer state management Andre Carvalho
2026-01-12  9:40 ` [PATCH net-next v10 3/7] netconsole: add STATE_DEACTIVATED to track targets disabled by low level Andre Carvalho
2026-01-12  9:40 ` [PATCH net-next v10 4/7] netconsole: clear dev_name for devices bound by mac Andre Carvalho
2026-01-12  9:40 ` [PATCH net-next v10 5/7] netconsole: introduce helpers for dynamic_netconsole_mutex lock/unlock Andre Carvalho
2026-01-12  9:40 ` [PATCH net-next v10 6/7] netconsole: resume previously deactivated target Andre Carvalho
2026-01-12  9:40 ` [PATCH net-next v10 7/7] selftests: netconsole: validate target resume Andre Carvalho
2026-01-12 14:16   ` Jakub Kicinski
2026-01-12 15:16     ` Breno Leitao
2026-01-12 20:49       ` Andre Carvalho
2026-01-12 21:53         ` Jakub Kicinski
2026-01-16 21:01     ` Andre Carvalho
2026-01-17 17:22       ` Jakub Kicinski [this message]

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=20260117092227.741cba3b@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=asantostc@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@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