* [PATCH net] netdevsim: set the carrier when the device goes up
@ 2025-10-13 17:09 Breno Leitao
2025-10-13 17:25 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: Breno Leitao @ 2025-10-13 17:09 UTC (permalink / raw)
To: Jakub Kicinski, Andrew Lunn, David S. Miller, Eric Dumazet,
Paolo Abeni, David Wei
Cc: netdev, linux-kernel, kernel-team, Breno Leitao
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.
When a device is brought up, if it has a peer and this peer device is
UP, set both carriers to on.
Signed-off-by: Breno Leitao <leitao@debian.org>
Fixes: 3762ec05a9fbda ("netdevsim: add NAPI support")
---
drivers/net/netdevsim/netdev.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index ebc3833e95b44..fa1d97885caaf 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -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,
--
Breno Leitao <leitao@debian.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] netdevsim: set the carrier when the device goes up
2025-10-13 17:09 [PATCH net] netdevsim: set the carrier when the device goes up Breno Leitao
@ 2025-10-13 17:25 ` Andrew Lunn
2025-10-14 9:18 ` Breno Leitao
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2025-10-13 17:25 UTC (permalink / raw)
To: Breno Leitao
Cc: Jakub Kicinski, Andrew Lunn, David S. Miller, Eric Dumazet,
Paolo Abeni, David Wei, netdev, linux-kernel, kernel-team
On Mon, Oct 13, 2025 at 10:09:22AM -0700, Breno Leitao 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.
>
> When a device is brought up, if it has a peer and this peer device is
> UP, set both carriers to on.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> Fixes: 3762ec05a9fbda ("netdevsim: add NAPI support")
It was not obvious what adding NAPI has to do with carrier status. I
had to go look at 3762ec05a9fbda to see that that was when nsim_stop()
started to change the carrier on stop. This patch makes nsim_open()
somewhat symmetrical. If you need a respin, maybe expand the commit
message to explain this.
Otherwise this looks O.K. to me.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] netdevsim: set the carrier when the device goes up
2025-10-13 17:25 ` Andrew Lunn
@ 2025-10-14 9:18 ` Breno Leitao
0 siblings, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2025-10-14 9:18 UTC (permalink / raw)
To: Andrew Lunn
Cc: Jakub Kicinski, Andrew Lunn, David S. Miller, Eric Dumazet,
Paolo Abeni, David Wei, netdev, linux-kernel, kernel-team
Hello Andrew,
On Mon, Oct 13, 2025 at 07:25:27PM +0200, Andrew Lunn wrote:
> On Mon, Oct 13, 2025 at 10:09:22AM -0700, Breno Leitao 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.
> >
> > When a device is brought up, if it has a peer and this peer device is
> > UP, set both carriers to on.
> >
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> > Fixes: 3762ec05a9fbda ("netdevsim: add NAPI support")
>
> It was not obvious what adding NAPI has to do with carrier status. I
> had to go look at 3762ec05a9fbda to see that that was when nsim_stop()
> started to change the carrier on stop. This patch makes nsim_open()
> somewhat symmetrical. If you need a respin, maybe expand the commit
> message to explain this.
Thanks for the review. I've sent a v2 with the updated message, given it
adds clarity to the change.
--breno
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-14 9:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-13 17:09 [PATCH net] netdevsim: set the carrier when the device goes up Breno Leitao
2025-10-13 17:25 ` Andrew Lunn
2025-10-14 9:18 ` Breno Leitao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).