Skip to main content
1 of 3
engineer14
  • 153
  • 1
  • 5

Udev rules for a device with multiple interfaces

So, I'm delving into udev and running into an issue.

I think that I understand the basic premise (please correct me if i'm wrong). Device is attached either due to your system booting up or sometime afterwards. Udev goes through all the rules looking for matches. once it finds a match, it executes whatever actions were requested, and continues going down the list of rules until it gets to the last one. Then it starts off on the next device.

Now, I have a usb device that creates 2 interfaces. When I attach it, i get both an can0 and can1 when I look in /sys/class/net/. But in /dev, there is only one entry for this under /dev/bus/usb/002/00X.

Now, here is where my problem comes. I want to name each of these interfaces something specific. I know that one always comes up before the other. If i do nothing, they get named can0 and can1. If I put a udev rule in, the first one that comes up gets renamed properly, but looking at the dmesg logs, the second one errs out because the kernel name is also can0 (since there is no can1).

How would one get around this? udevadm doesn't help since there is only one device listed in /dev, so it seems that I can't differentiate them by attributes .

engineer14
  • 153
  • 1
  • 5