Skip to content

Commit 8e93ac5

Browse files
can: netlink: can_changelink(): allow disabling of automatic restart
Since the commit c1f3f97 ("can: netlink: can_changelink(): fix NULL pointer deref of struct can_priv::do_set_mode"), the automatic restart delay can only be set for devices that implement the restart handler struct can_priv::do_set_mode. As it makes no sense to configure a automatic restart for devices that doesn't support it. However, since systemd commit 13ce5d4632e3 ("network/can: properly handle CAN.RestartSec=0") [1], systemd-networkd correctly handles a restart delay of "0" (i.e. the restart is disabled). Which means that a disabled restart is always configured in the kernel. On systems with both changes active this causes that CAN interfaces that don't implement a restart handler cannot be brought up by systemd-networkd. Solve this problem by allowing a delay of "0" to be configured, even if the device does not implement a restart handler. [1] systemd/systemd@13ce5d4 Cc: stable@vger.kernel.org Cc: Andrei Lalaev <andrey.lalaev@gmail.com> Reported-by: Marc Kleine-Budde <mkl@pengutronix.de> Closes: https://lore.kernel.org/all/20251020-certain-arrogant-vole-of-sunshine-141841-mkl@pengutronix.de Fixes: c1f3f97 ("can: netlink: can_changelink(): fix NULL pointer deref of struct can_priv::do_set_mode") Link: https://patch.msgid.link/20251020-netlink-fix-restart-v1-1-3f53c7f8520b@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 942b3c6 commit 8e93ac5

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/net/can/dev/netlink.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
452452
}
453453

454454
if (data[IFLA_CAN_RESTART_MS]) {
455-
if (!priv->do_set_mode) {
455+
unsigned int restart_ms = nla_get_u32(data[IFLA_CAN_RESTART_MS]);
456+
457+
if (restart_ms != 0 && !priv->do_set_mode) {
456458
NL_SET_ERR_MSG(extack,
457459
"Device doesn't support restart from Bus Off");
458460
return -EOPNOTSUPP;
@@ -461,7 +463,7 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
461463
/* Do not allow changing restart delay while running */
462464
if (dev->flags & IFF_UP)
463465
return -EBUSY;
464-
priv->restart_ms = nla_get_u32(data[IFLA_CAN_RESTART_MS]);
466+
priv->restart_ms = restart_ms;
465467
}
466468

467469
if (data[IFLA_CAN_RESTART]) {

0 commit comments

Comments
 (0)