ip link set dev up 返回 RTNETLINK 答案:无效参数

ip link set dev up 返回 RTNETLINK 答案:无效参数

我有一个创建网络接口的 USB CAN 设备:

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:30:18:05:ed:0d brd ff:ff:ff:ff:ff:ff
    inet 192.168.8.156/24 brd 192.168.8.255 scope global dynamic noprefixroute enp2s0
       valid_lft 85716sec preferred_lft 85716sec
    inet6 fd4c:5077:bd05:c700:7917:7860:6e2b:7d47/64 scope global temporary dynamic 
       valid_lft 6854sec preferred_lft 3254sec
    inet6 fd4c:5077:bd05:c700:230:18ff:fe05:ed0d/64 scope global dynamic mngtmpaddr 
       valid_lft 6854sec preferred_lft 3254sec
    inet6 fe80::230:18ff:fe05:ed0d/64 scope link 
       valid_lft forever preferred_lft forever
3: enp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:30:18:05:ed:0e brd ff:ff:ff:ff:ff:ff
4: wlp1s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether e8:84:a5:c1:f1:10 brd ff:ff:ff:ff:ff:ff
7: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10
    link/can 

在 Ubuntu 21.10 中,我can0使用以下命令启动了我的界面:

sudo ip link set up can0

升级到 22.04 后,相同的命令返回:

$ sudo ip link set up can0
RTNETLINK answers: Invalid argument

查看手册的ip link正确语法略有不同:

ip link set { DEVICE | dev DEVICE | group DEVGROUP }
        [ { up | down } ]
        [ type TYPE ARGS ]

所以我尝试了:

$ sudo ip link set dev can0 up type can    
RTNETLINK answers: Invalid argument

但错误是一样的。我不明白为什么程序员不添加无效参数的详细信息...如果我做这样的事情,我会被解雇的。

无论如何,我的语法有什么问题?如何检索有问题的无效参数?

答案1

尝试添加类型和/或比特率:

sudo ip link set can0 up type can bitrate 500000

相关内容