selftests: drv-net: warn if LOCAL_V6 has DAD or not kept on link down
Subsystems (3)
Jakub Kicinski
maintainerPATCH 1/1 selftests: drv-net: warn if LOCAL_V6 has DAD or not kept on link down
napi_id.py intermittently fails to start its helper on Intel and Google HW runners:
CMD: /srv/netdev/drivers/net/napi_id_helper 3001::1 37569
EXIT: 1
STDERR: bind failed: Cannot assign requested address
Either keep_addr_on_down is not set or more likely the address is configured without nodad. Having to make sure that all tests always wait for DAD after impacting the link would be a whack-a-mole so we expect the env to have nodad and keep_addr_on_down set.
Warn about both while validating the environment, and document this. We could fail completely but most tests don't impact the link so for quick local testing it'd be annoying to have to apply the settings. I hope the warninging stikes the right balance.
---
Adrian, Sheena, please update the setups scripts for your systems. Looks like nodad is missing.
CC: [email protected]
CC: [email protected]
CC: [email protected]
CCL [email protected]
CC: [email protected]
CC: [email protected]
--- .../testing/selftests/drivers/net/README.rst | 9 +++++++++ .../selftests/drivers/net/lib/py/env.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+)
tools/testing/selftests/drivers/net/README.rst +9 -0
@@ -70,6 +70,15 @@ LOCAL_V4, LOCAL_V6, REMOTE_V4, REMOTE_V6 Local and remote endpoint IP addresses. +Tests reconfigure the device freely, including taking the link down, and +expect the addresses to work immediately afterwards. IPv6 needs help:: + + ip -6 address add 2001:db8:1::1/64 dev eth0 nodad + sysctl -w net.ipv6.conf.eth0.keep_addr_on_down=1 + +Without those the address is flushed when the link goes down, or spends +a second unusable while waiting for DAD to finish. + LOCAL_PREFIX_V6 ~~~~~~~~~~~~~~~
tools/testing/selftests/drivers/net/lib/py/env.py +19 -0
@@ -239,6 +239,25 @@ from . import bpftool, RtnlFamily, Netlink if missing: raise Exception("Invalid environment, missing configuration:", missing, "Please see tools/testing/selftests/drivers/net/README.rst") + if "LOCAL_V6" in self.env: + self._check_v6_env() + + def _check_v6_env(self): + """Tests bind() to LOCAL_V6 and bounce the link, it must survive both.""" + ifname, addr = self.env["NETIF"], self.env["LOCAL_V6"] + + def _keep_addr(scope): + with open(f"/proc/sys/net/ipv6/conf/{scope}/keep_addr_on_down", + encoding="utf-8") as fp: + return int(fp.read()) + + # 'all' wins when non-zero, see addrconf_ifdown() + if (_keep_addr("all") or _keep_addr(ifname)) <= 0: + ksft_pr(f"WARN: net.ipv6.conf.{ifname}.keep_addr_on_down not set") + + dev = ip(f"-6 address show dev {ifname} to {addr}", json=True) + if not (dev and dev[0]["addr_info"][0].get("nodad")): + ksft_pr(f"WARN: LOCAL_V6 {addr} not configured with nodad") def resolve_remote_ifc(self): v4 = v6 = None
Signature · 1 line
2.55.0
Quoted 85 lines · Jakub Kicinski
napi_id.pyintermittently fails to start its helper on Intel and Google HW runners:CMD:
/srv/netdev/drivers/net/napi_id_helper3001::1 37569
EXIT: 1
STDERR: bind failed: Cannot assign requested addressEither
keep_addr_on_downis not set or more likely the address is configured without nodad. Having to make sure that all tests always wait for DAD after impacting the link would be a whack-a-mole so we expect the env to have nodad andkeep_addr_on_downset.Warn about both while validating the environment, and document this. We could fail completely but most tests don't impact the link so for quick local testing it'd be annoying to have to apply the settings. I hope the warninging stikes the right balance.
Signed-off-by Jakub Kicinski <[email protected]>---
Adrian, Sheena, please update the setups scripts for your systems. Looks like nodad is missing.CC: [email protected]
CC: [email protected]
CC: [email protected]
CCL [email protected]
CC: [email protected]
CC: [email protected]--- .../testing/selftests/drivers/net/README.rst | 9 +++++++++ .../selftests/drivers/net/lib/py/env.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+)tools/testing/selftests/drivers/net/README.rst +9
-0@@ -70,6 +70,15 @@ LOCAL_V4, LOCAL_V6, REMOTE_V4, REMOTE_V6 Local and remote endpoint IP addresses. +Tests reconfigure the device freely, including taking the link down, and +expect the addresses to work immediately afterwards. IPv6 needs help:: + + ip -6 address add 2001:db8:1::1/64 dev eth0 nodad + sysctl -w net.ipv6.conf.eth0.keep_addr_on_down=1 + +Without those the address is flushed when the link goes down, or spends +a second unusable while waiting for DAD to finish. + LOCAL_PREFIX_V6 ~~~~~~~~~~~~~~~tools/testing/selftests/drivers/net/lib/py/env.py +19
-1@@ -239,6 +239,25 @@ from . import bpftool, RtnlFamily, Netlink if missing: raise Exception("Invalid environment, missing configuration:", missing, "Please see tools/testing/selftests/drivers/net/README.rst") + if "LOCAL_V6" in self.env: + self._check_v6_env() + + def _check_v6_env(self): + """Tests bind() to LOCAL_V6 and bounce the link, it must survive both.""" + ifname, addr = self.env["NETIF"], self.env["LOCAL_V6"] + + def _keep_addr(scope): + with open(f"/proc/sys/net/ipv6/conf/{scope}/keep_addr_on_down", + encoding="utf-8") as fp: + return int(fp.read()) + + # 'all' wins when non-zero, see addrconf_ifdown() + if (_keep_addr("all") or _keep_addr(ifname)) <= 0: + ksft_pr(f"WARN: net.ipv6.conf.{ifname}.keep_addr_on_down not set") + + dev = ip(f"-6 address show dev {ifname} to {addr}", json=True) + if not (dev and dev[0]["addr_info"][0].get("nodad")): + ksft_pr(f"WARN: LOCAL_V6 {addr} not configured with nodad") def resolve_remote_ifc(self): v4 = v6 = None --
Quoted 2 lines
2.55.0
Thanks Jakub. We will update the setup scripts on our end to reflect this configuration.
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Critical: 0 · High: 0 · Medium: 1 · Low: 0
- [Medium] The patch documents a new environment invariant (README.rst:73-80: the local IPv6 address must be added with nodad…
--
selftests: drv-net: warn if LOCAL_V6 has DAD or not kept on link down
This documents that the drv-net environment is expected to configure LOCAL_V6 with nodad and with keep_addr_on_down enabled, and adds a check in NetDrvEpEnv._check_env() that prints warnings when either is missing. The motivation is intermittent bind() failures in napi_id.py on HW runners.
Quoted 25 lines
tools/testing/selftests/drivers/net/README.rst +9
-0@@ -70,6 +70,15 @@ LOCAL_V4, LOCAL_V6, REMOTE_V4, REMOTE_V6 Local and remote endpoint IP addresses. +Tests reconfigure the device freely, including taking the link down, and +expect the addresses to work immediately afterwards. IPv6 needs help:: + + ip -6 address add 2001:db8:1::1/64 dev eth0 nodad + sysctl -w net.ipv6.conf.eth0.keep_addr_on_down=1 + +Without those the address is flushed when the link goes down, or spends +a second unusable while waiting for DAD to finish. + LOCAL_PREFIX_V6 ~~~~~~~~~~~~~~~tools/testing/selftests/drivers/net/lib/py/env.py +0
-0
tools/testing/selftests/drivers/net/lib/py/env.py class NetDrvEpEnv(NetDrvEnvBase): · line 243
Quoted 5 lines
tools/testing/selftests/drivers/net/lib/py/env.py +2
-0@@ -239,6 +239,25 @@ class NetDrvEpEnv(NetDrvEnvBase): if missing: raise Exception("Invalid environment, missing configuration:", missing, "Please see tools/testing/selftests/drivers/net/README.rst") + if "LOCAL_V6" in self.env: + self._check_v6_env()
[Severity: Medium]
Do the in-tree environment providers meet the invariant that is being documented here?
Two cases look like they do not:
1) NetDrvEpEnv.create_local() (the netdevsim path in the same file) adds the addresses with nodad, but never enables keep_addr_on_down on the nsim devices or on 'all':
ip(f" addr add dev {self._ns.nsims[0].ifname} {self.nsim_v4_pfx}1/24")
ip(f"-6 addr add dev {self._ns.nsims[0].ifname} {self.nsim_v6_pfx}1/64 nodad")
ip(f" link set dev {self._ns.nsims[0].ifname} up") Both the devconf_all and per-device defaults are 0, and addrconf_ifdown() drops permanent global addresses when the aggregate is not positive:
net/ipv6/addrconf.c:addrconf_ifdown() {
...
int _keep_addr = READ_ONCE(net->ipv6.devconf_all->keep_addr_on_down);
if (!_keep_addr)
_keep_addr = READ_ONCE(idev->cnf.keep_addr_on_down);
keep_addr = (_keep_addr > 0);
...}
So a test that follows the new documentation and bounces the link would lose the nsim LOCAL_V6 address. Note also that this path never reaches _check_v6_env(), since the call is only made from the branch that requires NETIF, so there is no warning either.
2) tools/testing/selftests/net/lib/ksft_setup_loopback.sh sets up the env that this code validates, and adds LOCAL_V6 without nodad and without touching keep_addr_on_down:
ip -netns "${SERVER_NS}" addr add $LOCAL_V6/64 dev server
...
export NETIF=server Would every run driven by that script now print both new warnings, pointing at in-tree setup code rather than at a user misconfiguration? Should the script and create_local() be updated along with the documentation?
Quoted 3 lines
tools/testing/selftests/drivers/net/lib/py/env.py +0
-0def resolve_remote_ifc(self): v4 = v6 = None
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260908181956.1357684-1-kuba%40kernel.org
Jakub Kicinski
maintainerQuoted 56 lines · On Wed, 09 Sep 2026 20:17:51 +0000 [email protected] wrote:
Quoted 25 lines
tools/testing/selftests/drivers/net/README.rst +9
-0@@ -70,6 +70,15 @@ LOCAL_V4, LOCAL_V6, REMOTE_V4, REMOTE_V6 Local and remote endpoint IP addresses. +Tests reconfigure the device freely, including taking the link down, and +expect the addresses to work immediately afterwards. IPv6 needs help:: + + ip -6 address add 2001:db8:1::1/64 dev eth0 nodad + sysctl -w net.ipv6.conf.eth0.keep_addr_on_down=1 + +Without those the address is flushed when the link goes down, or spends +a second unusable while waiting for DAD to finish. + LOCAL_PREFIX_V6 ~~~~~~~~~~~~~~~tools/testing/selftests/drivers/net/lib/py/env.py +0
-0tools/testing/selftests/drivers/net/lib/py/env.py class NetDrvEpEnv(NetDrvEnvBase): · line 243
Quoted 5 lines
tools/testing/selftests/drivers/net/lib/py/env.py +2
-0@@ -239,6 +239,25 @@ class NetDrvEpEnv(NetDrvEnvBase): if missing: raise Exception("Invalid environment, missing configuration:", missing, "Please see tools/testing/selftests/drivers/net/README.rst") + if "LOCAL_V6" in self.env: + self._check_v6_env()[Severity: Medium]
Do the in-tree environment providers meet the invariant that is being documented here?Two cases look like they do not:
1)
NetDrvEpEnv.create_local()(the netdevsim path in the same file) adds the addresses with nodad, but never enableskeep_addr_on_downon the nsim devices or on 'all':ip(f" addr add dev {self._ns.nsims[0].ifname} {self.nsim_v4_pfx}1/24") ip(f"-6 addr add dev {self._ns.nsims[0].ifname} {self.nsim_v6_pfx}1/64 nodad") ip(f" link set dev {self._ns.nsims[0].ifname} up")Both the devconf_all and per-device defaults are 0, and addrconf_ifdown() drops permanent global addresses when the aggregate is not positive: net/ipv6/addrconf.c:addrconf_ifdown() { ... int _keep_addr = READ_ONCE(net->ipv6.devconf_all->keep_addr_on_down); if (!_keep_addr) _keep_addr = READ_ONCE(idev->cnf.keep_addr_on_down);
Quoted 8 lines
keep_addr = (_keep_addr > 0); ... } So a test that follows the new documentation and bounces the link would lose the nsim LOCAL_V6 address. Note also that this path never reaches _check_v6_env(), since the call is only made from the branch that requires NETIF, so there is no warning either.
This is no different to the HW case, we expect the outside runner to configure the system. As proven by the fact that the WARN print added here does not trigger in NIPA on netdevsim:
https://netdev-ctrl.bots.linux.dev/logs/vmksft/net-drv/results/816282/13-napi-id-py/stdout
Quoted 4 lines
2)
tools/testing/selftests/net/lib/ksft_setup_loopback.shsets up the env that this code validates, and addsLOCAL_V6without nodad and without touchingkeep_addr_on_down:
Quoted 8 lines
ip -netns "${SERVER_NS}" addr add $LOCAL_V6/64 dev server ... export NETIF=serverWould every run driven by that script now print both new warnings, pointing at in-tree setup code rather than at a user misconfiguration? Should the script and
create_local()be updated along with the documentation?
Not sure if and how that script is actually used :S
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 8 Sep 2026 11:19:56 -0700 you wrote:
napi_id.pyintermittently fails to start its helper on Intel and Google HW runners:CMD:
/srv/netdev/drivers/net/napi_id_helper3001::1 37569
EXIT: 1
STDERR: bind failed: Cannot assign requested address[...]
Here is the summary with links:
- [net-next] selftests: drv-net: warn if LOCAL_V6 has DAD or not kept on link down
https://git.kernel.org/netdev/net-next/c/3929f55da21f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Pielech, Adrian
AppliedQuoted 83 lines · Sheena Mohan
Quoted 82 lines · Jakub Kicinski
napi_id.pyintermittently fails to start its helper on Intel and Google HW runners:CMD: /srv/netdev/drivers/net/napi_id_helper 3001::1 37569 EXIT: 1 STDERR: bind failed: Cannot assign requested addressEither
keep_addr_on_downis not set or more likely the address is configured without nodad. Having to make sure that all tests always wait for DAD after impacting the link would be a whack-a-mole so we expect the env to have nodad andkeep_addr_on_downset.Warn about both while validating the environment, and document this. We could fail completely but most tests don't impact the link so for quick local testing it'd be annoying to have to apply the settings. I hope the warninging stikes the right balance.
Signed-off-by Jakub Kicinski <[email protected]>---
Adrian, Sheena, please update the setups scripts for your systems. Looks like nodad is missing.CC: [email protected]
CC: [email protected]
CC: [email protected]
CCL [email protected]
CC: [email protected]
CC: [email protected]--- .../testing/selftests/drivers/net/README.rst | 9 +++++++++ .../selftests/drivers/net/lib/py/env.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+)tools/testing/selftests/drivers/net/README.rst +9
-0@@ -70,6 +70,15 @@ LOCAL_V4, LOCAL_V6, REMOTE_V4, REMOTE_V6 Local and remote endpoint IP addresses. +Tests reconfigure the device freely, including taking the link down, and +expect the addresses to work immediately afterwards. IPv6 needs help:: + + ip -6 address add 2001:db8:1::1/64 dev eth0 nodad + sysctl -w net.ipv6.conf.eth0.keep_addr_on_down=1 + +Without those the address is flushed when the link goes down, or spends +a second unusable while waiting for DAD to finish. + LOCAL_PREFIX_V6 ~~~~~~~~~~~~~~~tools/testing/selftests/drivers/net/lib/py/env.py +19
-0@@ -239,6 +239,25 @@ from . import bpftool, RtnlFamily, Netlink if missing: raise Exception("Invalid environment, missing configuration:", missing, "Please see tools/testing/selftests/drivers/net/README.rst") + if "LOCAL_V6" in self.env: + self._check_v6_env() + + def _check_v6_env(self): + """Tests bind() to LOCAL_V6 and bounce the link, it must survive both.""" + ifname, addr = self.env["NETIF"], self.env["LOCAL_V6"] + + def _keep_addr(scope): + with open(f"/proc/sys/net/ipv6/conf/{scope}/keep_addr_on_down", + encoding="utf-8") as fp: + return int(fp.read()) + + # 'all' wins when non-zero, see addrconf_ifdown() + if (_keep_addr("all") or _keep_addr(ifname)) <= 0: + ksft_pr(f"WARN: net.ipv6.conf.{ifname}.keep_addr_on_down not set") + + dev = ip(f"-6 address show dev {ifname} to {addr}", json=True) + if not (dev and dev[0]["addr_info"][0].get("nodad")): + ksft_pr(f"WARN: LOCAL_V6 {addr} not configured with nodad")
Quoted 7 lines
Quoted 5 lines
tools/testing/selftests/drivers/net/lib/py/env.py +0
-1def resolve_remote_ifc(self): v4 = v6 = None --2.55.0
Thanks Jakub. We will update the setup scripts on our end to reflect this configuration.
Applied to the setups, thanks for noticing about that requirement!
Quoted 93 lines · Adrian
Quoted 83 lines · Sheena Mohan
Quoted 82 lines · Jakub Kicinski
napi_id.pyintermittently fails to start its helper on Intel and Google HW runners:CMD: /srv/netdev/drivers/net/napi_id_helper 3001::1 37569 EXIT: 1 STDERR: bind failed: Cannot assign requested addressEither
keep_addr_on_downis not set or more likely the address is configured without nodad. Having to make sure that all tests always wait for DAD after impacting the link would be a whack-a-mole so we expect the env to have nodad andkeep_addr_on_downset.Warn about both while validating the environment, and document this. We could fail completely but most tests don't impact the link so for quick local testing it'd be annoying to have to apply the settings. I hope the warninging stikes the right balance.
Signed-off-by Jakub Kicinski <[email protected]>---
Adrian, Sheena, please update the setups scripts for your systems. Looks like nodad is missing.CC: [email protected]
CC: [email protected]
CC: [email protected]
CCL [email protected]
CC: [email protected]
CC: [email protected]--- .../testing/selftests/drivers/net/README.rst | 9 +++++++++ .../selftests/drivers/net/lib/py/env.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+)tools/testing/selftests/drivers/net/README.rst +9
-0@@ -70,6 +70,15 @@ LOCAL_V4, LOCAL_V6, REMOTE_V4, REMOTE_V6 Local and remote endpoint IP addresses. +Tests reconfigure the device freely, including taking the link down, and +expect the addresses to work immediately afterwards. IPv6 needs help:: + + ip -6 address add 2001:db8:1::1/64 dev eth0 nodad + sysctl -w net.ipv6.conf.eth0.keep_addr_on_down=1 + +Without those the address is flushed when the link goes down, or spends +a second unusable while waiting for DAD to finish. + LOCAL_PREFIX_V6 ~~~~~~~~~~~~~~~tools/testing/selftests/drivers/net/lib/py/env.py +19
-0@@ -239,6 +239,25 @@ from . import bpftool, RtnlFamily, Netlink if missing: raise Exception("Invalid environment, missing configuration:", missing, "Please see tools/testing/selftests/drivers/net/README.rst") + if "LOCAL_V6" in self.env: + self._check_v6_env() + + def _check_v6_env(self): + """Tests bind() to LOCAL_V6 and bounce the link, it must survive both.""" + ifname, addr = self.env["NETIF"], self.env["LOCAL_V6"] + + def _keep_addr(scope): + with open(f"/proc/sys/net/ipv6/conf/{scope}/keep_addr_on_down", + encoding="utf-8") as fp: + return int(fp.read()) + + # 'all' wins when non-zero, see addrconf_ifdown() + if (_keep_addr("all") or _keep_addr(ifname)) <= 0: + ksft_pr(f"WARN: net.ipv6.conf.{ifname}.keep_addr_on_down not set") + + dev = ip(f"-6 address show dev {ifname} to {addr}", json=True) + if not (dev and dev[0]["addr_info"][0].get("nodad")): + ksft_pr(f"WARN: LOCAL_V6 {addr} not configured with nodad")Quoted 7 lines
Quoted 5 lines
tools/testing/selftests/drivers/net/lib/py/env.py +0
-1def resolve_remote_ifc(self): v4 = v6 = None --2.55.0
Thanks Jakub. We will update the setup scripts on our end to reflect this configuration.
Quoted 1 line
Applied to the setups, thanks for noticing about that requirement!
GVE and IDPF executor test setups are now updated.