首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Ubuntu核上的SocketCAN器件

Ubuntu核上的SocketCAN器件
EN

Ask Ubuntu用户
提问于 2018-10-09 12:37:19
回答 1查看 2K关注 0票数 1

我目前正在尝试在运行Kvaser USBcan Light2xHS 16的戴尔边缘网关3002上使用支持SocketCAN的设备( Ubuntu )。

这个CAN接口已经成功地在Ubuntu桌面上进行了测试。

默认情况下,不能在Ubuntu 16上加载CAN内核模块,所以我的第一步是加载它们:

代码语言:javascript
运行
复制
$ lsmod | grep can
can_gw                 20480  0
can_raw                20480  0
can_dev                24576  1 kvaser_usb
can                    45056  2 can_gw,can_raw

此时连接CAN接口将导致创建两个新的can接口(默认情况下是can0can1 )。问题是,这些接口无处可寻:

代码语言:javascript
运行
复制
$ ip link show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether d8:9e:f3:9c:5f:9f brd ff:ff:ff:ff:ff:ff
3: eth1:  mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
link/ether d8:9e:f3:9c:5f:a1 brd ff:ff:ff:ff:ff:ff
4: wwan0:  mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether aa:c6:53:a2:73:a0 brd ff:ff:ff:ff:ff:ff
5: wlan0:  mtu 1500 qdisc mq state DOWN mode DORMANT group default qlen 1000
link/ether 00:23:a7:fa:99:68 brd ff:ff:ff:ff:ff:ff
6: docker0:  mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default
link/ether 02:42:57:84:86:f6 brd ff:ff:ff:ff:ff:ff

dmesg的输出表明存在某种安全问题。我不太熟悉AppArmor,所以我不确定这是否有任何关联:

代码语言:javascript
运行
复制
$ dmesg | tail -n15
[  515.224025] usb 1-1: new high-speed USB device number 6 using xhci_hcd
[  515.353111] usb 1-1: New USB device found, idVendor=0bfd, idProduct=0123
[  515.353122] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  515.353129] usb 1-1: Product: Kvaser USBcan Light
[  515.353134] usb 1-1: Manufacturer: Kvaser AB
[  515.368908] audit: type=1400 audit(1539088148.830:340): apparmor="DENIED" operation="open" profile="snap.uefi-fw-tools.fwupd" name="/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/busnum" pid=2327 comm="fwupd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0 

有谁曾经在Ubuntu上使用过SocketCAN设备吗?有关于如何调试这个的说明吗?

谢谢!

<#>EDIT 01

我们已经试着停止了仪仗队的服务:

代码语言:javascript
运行
复制
# systemctl stop apparmor.service
# systemctl status apparmor.service
● apparmor.service - LSB: AppArmor initialization
   Loaded: loaded (/etc/init.d/apparmor; bad; vendor preset: enabled)
   Active: inactive (dead) since Tue 2018-10-09 15:40:17 UTC; 1s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4442 ExecStop=/etc/init.d/apparmor stop (code=exited, status=0/SUCCESS)
  Process: 2345 ExecStart=/etc/init.d/apparmor start (code=exited, status=0/SUCCESS)

Oct 09 15:40:17 ******* systemd[1]: Stopping LSB: AppArmor initialization...
Oct 09 15:40:17 ******* apparmor[4442]:  * Clearing AppArmor profiles cache
Oct 09 15:40:17 ******* apparmor[4442]:    ...done.
Oct 09 15:40:17 ******* apparmor[4442]: All profile caches have been cleared, but no profiles have been unloaded.
Oct 09 15:40:17 ******* apparmor[4442]: Unloading profiles will leave already running processes permanently
Oct 09 15:40:17 ******* apparmor[4442]: unconfined, which can lead to unexpected situations.
Oct 09 15:40:17 ******* apparmor[4442]: To set a process to complain mode, use the command line tool
Oct 09 15:40:17 ******* apparmor[4442]: 'aa-complain'. To really tear down all profiles, run the init script
Oct 09 15:40:17 ******* apparmor[4442]: with the 'teardown' option."
Oct 09 15:40:17 ******* systemd[1]: Stopped LSB: AppArmor initialization.

奇怪的是,在连接USBcan设备之后,设备拒绝消息仍然出现:

代码语言:javascript
运行
复制
# dmesg | tail -n6
[ 1704.616028] usb 1-1: new high-speed USB device number 8 using xhci_hcd
[ 1704.744895] usb 1-1: New USB device found, idVendor=0bfd, idProduct=0123
[ 1704.744907] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1704.744913] usb 1-1: Product: Kvaser USBcan Light
[ 1704.744919] usb 1-1: Manufacturer: Kvaser AB
[ 1704.770397] audit: type=1400 audit(1539099996.288:134): apparmor="DENIED" operation="open" profile="snap.uefi-fw-tools.fwupd" name="/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/busnum" pid=4013 comm="fwupd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0

我想这与Ubuntu的固有限制有关。

EDIT 02

恐怕我不能在Ubuntu上使用apt,而且还有没有截图 for apparmor-utils。无法识别aa-enforceaa-complain命令。

我确实尝试过运行systemctl disable apparmor.service并重新启动。在此之后,SSH对网关的访问被丢失(这是一台没有GPU的无头机器),我不得不再次闪现OS映像。我想知道这是否与Ubuntu需要apparmor服务才能正常工作有关。

默认情况下,uefi-fw-tools快照安装在网关附带的Ubuntu映像上。

我将尝试在devmode中安装uefi-fw-tools快照,以避免出现任何设备问题并发布结果。

EDIT 03

在devmode中安装uefi-fw-tools管理单元之后,AppArmor拒绝消息消失,尽管在连接USBCan设备时SocketCAN接口仍然没有出现。

我联系了Kvaser的支持部门,似乎USBcan Light只在内核>= 4.7上被支持,而网关正在运行4.4。docs 应该是3.2中提到的最小内核,但是不支持这个特定的模型。

无论如何,非常感谢您在调试AppArmor方面的帮助。

EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2018-10-09 14:28:04

加载内核后,不要忘记重新启动。

配置CAN总线接口的标准命令是:

代码语言:javascript
运行
复制
ip link set can0 type can bitrate 500000 listen-only on

这将将can0接口的比特率设置为500 Kbps。现在打开接口并开始转储帧:

代码语言:javascript
运行
复制
ip link set can0 up
candump -cae can0,0:0,#FFFFFFFF

或者做一个

代码语言:javascript
运行
复制
ip l sh

关于幻影信息,我不确定--但你可以试试:

  • 首先,我建议安装设备
  • 在您的示例中,profile="snap.uefi-fw-tools.fwupd"拒绝operation="open" name="/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/busnum",在/etc/apparmor.d/snap.uefi-fw-tools.fwupd中添加pid=2327,添加以下行(在/sys/.之前插入2个空格))/sys/设备/pci*/*/usb*/*/busnum rw,
  • 重新加载所有设备配置文件: systemctl重新加载apparmor.service,或者如果没有启动/启用systemctl启用apparmor.service systemctl启动apparmor.service,您可以使用systemctl状态apparmor.service或sudo状态来证明状态。
  • 我建议使用sudo抱怨/etc/parmor.d/sn.uefi-fw-tools.fwupd,这将使配置文件违规成为允许并记录在案。用于测试和开发新的配置文件。稍后,您可以将其设置为使用sudo etc/etc/par.uefi-fw-tools.fwupd强制执行。
票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1082277

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档