Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Breno Leitao <leitao@debian.org>
Fixes: 3762ec05a9fbda ("netdevsim: add NAPI support")
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20251014-netdevsim_fix-v2-1-53b40590dae1@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Breno Leitao and committed by
Jakub Kicinski
1a8fed52 cf51d617

+7
+7
drivers/net/netdevsim/netdev.c
··· 545 545 static int nsim_open(struct net_device *dev) 546 546 { 547 547 struct netdevsim *ns = netdev_priv(dev); 548 + struct netdevsim *peer; 548 549 int err; 549 550 550 551 netdev_assert_locked(dev); ··· 555 554 return err; 556 555 557 556 nsim_enable_napi(ns); 557 + 558 + peer = rtnl_dereference(ns->peer); 559 + if (peer && netif_running(peer->netdev)) { 560 + netif_carrier_on(dev); 561 + netif_carrier_on(peer->netdev); 562 + } 558 563 559 564 return 0; 560 565 }