netdevsim: set the carrier when the device goes up
Subsystems (3)
PATCH v2 1/1 netdevsim: set the carrier when the device goes up
Bringing a linked netdevsim device down and then up causes communication failure because both interfaces lack carrier. Basically a ifdown/ifup on the interface make the link broken.
Commit 3762ec05a9fbda ("netdevsim: add NAPI support") added supported for NAPI, calling netif_carrier_off() in nsim_stop(). This patch re-enables the carrier symmetrically on nsim_open(), in case the device is linked and the peer is up.
---
Changes in v2:
- Reword the commit message to reference the symmetry between
nsim_open() and nsim_stop() in regarding to carrier. (Andrew Lunn)
- Link to v1: https://lore.kernel.org/r/[email protected]
--- drivers/net/netdevsim/netdev.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/netdevsim/netdev.c +7 -0
@@ -545,6 +545,7 @@ static void nsim_enable_napi(struct netdevsim *ns)static int nsim_open (struct net_device *dev) {struct netdevsim *ns =netdev_priv (dev); +struct netdevsim *peer;int err;netdev_assert_locked (dev);
@@ -555,6 +556,12 @@ static int nsim_open(struct net_device *dev)nsim_enable_napi (ns); + peer =rtnl_dereference (ns->peer); +if (peer &&netif_running (peer->netdev)) { +netif_carrier_on (dev); +netif_carrier_on (peer->netdev); + } +return 0 ; }
---
base-commit: 0b4b77eff5f8cd9be062783a1c1e198d46d0a753
change-id: 20251013-netdevsim_fix-b9a8a5064f8f
Best regards,
Signature · 1 line
Breno Leitao <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 14 Oct 2025 02:17:25 -0700 you wrote:
Bringing a linked netdevsim device down and then up causes communication failure because both interfaces lack carrier. Basically a ifdown/ifup on the interface make the link broken.
Commit
3762ec05a9fbda("netdevsim: add NAPI support") added supported for NAPI, callingnetif_carrier_off()innsim_stop(). This patch re-enables the carrier symmetrically onnsim_open(), in case the device is linked and the peer is up.[...]
Here is the summary with links:
- [net,v2] netdevsim: set the carrier when the device goes up
https://git.kernel.org/netdev/net/c/1a8fed52f7be
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html