Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
8.95k stars 5.16k forks source link

Recommend using "ip" instead of "ifconfig" in CANBUS.md #6563

Closed KevinOConnor closed 1 month ago

KevinOConnor commented 2 months ago

Some Linux systems do not install ifconfig, while ip should always be available. So, update the canbus documentation to recommend that.

-Kevin

Sineos commented 2 months ago

Depending on the Linux distribution and version, it seems that different approaches are needed.

Using systemd ( version newer than v248 required): To use the networking support of systemd, one needs to create the file /etc/systemd/network/80-can.network with following content:

[Match]
Name=can*

[Link]
TransmitQueueLength=128
RequiredForOnline=no

[CAN]
BitRate=1000000

The configuration change is applied and activated by running:

sudo systemctl daemon-reload
sudo networkctl reload

If Linux appears to be rejecting the queue length, the udev system can be used to force this parameter. To do so, create a file named /etc/udev/rules.d/99-persistent-can.rules with the following content:

SUBSYSTEM=="net", ACTION=="add|change", KERNEL=="can*", ATTR{tx_queue_len}="128"

This change is activated by issuing the following commands:

sudo udevadm control --reload-rules
sudo udevadm trigger
KevinOConnor commented 2 months ago

So, are you saying this change from "ifconfig" to "ip" could break systems that were previously working?

I understand the /etc/network/interfaces.d/can0 doesn't necessarily work on all systems, but I'm not sure if you are reporting that this change could be a regression.

Thanks, -Kevin

Sineos commented 2 months ago

As far as I can tell, there are distributions that do not process /etc/network/interfaces.d/*, but rely on systemd-networkd or netplan as their network management backend (often desktop flavors, it seems).

Also, there are reports on Discourse that Linux (for whatever reason) is finicky about accepting TX queue lengths.

These additions are meant to show alternatives in case the user runs into trouble with the regular approach.

Edit: The above essentially is the gist from https://github.com/linux-can/can-utils/issues/68

Edit 2:

but I'm not sure if you are reporting that this change could be a regression.

No, I think the changes are fine. I'm not aware that distributions that rely on the time-honored /etc/network/interfaces.d/* would not support the ip command.