Skip to content

Commit 7637d01

Browse files
marckleinebuddegregkh
authored andcommitted
can: netlink: can_changelink(): allow disabling of automatic restart
commit 8e93ac5 upstream. 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: [email protected] Cc: Andrei Lalaev <[email protected]> Reported-by: Marc Kleine-Budde <[email protected]> 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/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0bbf3fc commit 7637d01

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/can/dev/netlink.c

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

287287
if (data[IFLA_CAN_RESTART_MS]) {
288-
if (!priv->do_set_mode) {
288+
unsigned int restart_ms = nla_get_u32(data[IFLA_CAN_RESTART_MS]);
289+
290+
if (restart_ms != 0 && !priv->do_set_mode) {
289291
NL_SET_ERR_MSG(extack,
290292
"Device doesn't support restart from Bus Off");
291293
return -EOPNOTSUPP;
@@ -294,7 +296,7 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
294296
/* Do not allow changing restart delay while running */
295297
if (dev->flags & IFF_UP)
296298
return -EBUSY;
297-
priv->restart_ms = nla_get_u32(data[IFLA_CAN_RESTART_MS]);
299+
priv->restart_ms = restart_ms;
298300
}
299301

300302
if (data[IFLA_CAN_RESTART]) {

0 commit comments

Comments
 (0)