From ab224334322cd3553c6d88aa86211bef87adc281 Mon Sep 17 00:00:00 2001 From: Vincent Mailhol Date: Wed, 3 Dec 2025 19:24:31 +0100 Subject: [PATCH] iplink_can: add RESTRICTED operation mode support This is the iproute2 counterpart of Linux kernel's commit 60f511f443e5 ("can: netlink: add CAN_CTRLMODE_RESTRICTED"). ISO 11898-1:2024 adds a new restricted operation mode. This mode is added as a mandatory feature for nodes which support CAN XL and is retrofitted as optional for legacy nodes (i.e. the ones which only support Classical CAN and CAN FD). The restricted operation mode is nearly the same as the listen only mode: the node can not send data frames or remote frames and can not send dominant bits if an error occurs. The only exception is that the node shall still send the acknowledgment bit. Add the "restricted" option to iplink_can which controls the CAN_CTRLMODE_RESTRICTED flag of the netlink interface. Signed-off-by: Vincent Mailhol --- ip/iplink_can.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ip/iplink_can.c b/ip/iplink_can.c index d5abc43a..0ba86550 100644 --- a/ip/iplink_can.c +++ b/ip/iplink_can.c @@ -42,6 +42,7 @@ static void print_usage(FILE *f) "\t[ presume-ack { on | off } ]\n" "\t[ cc-len8-dlc { on | off } ]\n" "\t[ tdc-mode { auto | manual | off } ]\n" + "\t[ restricted { on | off } ]\n" "\n" "\t[ restart-ms TIME-MS ]\n" "\t[ restart ]\n" @@ -116,6 +117,7 @@ static void print_ctrlmode(enum output_type t, __u32 flags, const char *key) print_flag(t, &flags, CAN_CTRLMODE_CC_LEN8_DLC, "CC-LEN8-DLC"); print_flag(t, &flags, CAN_CTRLMODE_TDC_AUTO, "TDC-AUTO"); print_flag(t, &flags, CAN_CTRLMODE_TDC_MANUAL, "TDC-MANUAL"); + print_flag(t, &flags, CAN_CTRLMODE_RESTRICTED, "RESTRICTED"); if (flags) print_hex(t, NULL, "%x", flags); @@ -257,6 +259,9 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv, invarg("\"tdc-mode\" must be either of \"auto\", \"manual\" or \"off\"", *argv); } + } else if (strcmp(*argv, "restricted") == 0) { + NEXT_ARG(); + set_ctrlmode("restricted", *argv, &cm, CAN_CTRLMODE_RESTRICTED); } else if (matches(*argv, "restart") == 0) { __u32 val = 1; -- 2.47.3