]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iplink_can: add RESTRICTED operation mode support
authorVincent Mailhol <mailhol@kernel.org>
Wed, 3 Dec 2025 18:24:31 +0000 (19:24 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Sun, 7 Dec 2025 17:38:56 +0000 (09:38 -0800)
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 <mailhol@kernel.org>
ip/iplink_can.c

index d5abc43a2d0969de80f8f69a2d1ccdcbaaa0ba9d..0ba86550d7a3a88cc01af60cd1e356825f5b5471 100644 (file)
@@ -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;