Using mdev to assign names to USB network interfaces


#1

I have made a custom board with a WP7607. The board has a USB3503 HSIC USB hub to which two LAN9500 ethernet interfaces are connected. Now when the board is started, eth0 and eth1 are assigned to the ports in a random fashion. I want to statically assign eth0 to the left port and eth1 to the right port.

The left port is connected to USB port 3 and the right one to USB port 2. When I take a look in /sys/class/net I see the following:

eth0 -> …/…/devices/7c00000.hsic_host/usb1/1-1/1-1.2/1-1.2:1.0/net/eth0
eth1 -> …/…/devices/7c00000.hsic_host/usb1/1-1/1-1.3/1-1.3:1.0/net/eth1

I believe it should be possible to assign them the other way around. I can’t find any clear documentation on this unfortunately. Does anyone know how to get this working?


#2

I found a gist on github which seems like it could be helpful. It shows an mdev.conf file which includes a line for renaming interfaces.

-net/.* root:root 600 @/sbin/nameif -s

Unfortunately, nameif is not part of busybox that is enabled in the regular WP images. You would need to rebuild yocto and enable CONFIG_NAMEIF and CONFIG_FEATURE_NAMEIF_EXTENDED. Once you have done that, I think you need to put a /etc/mactab file into the root filesystem with the content:

eth0 bus=usb-0000:00:08.2-0
eth1 bus=usb-0000:00:08.3-0

I’m not really sure about the format of the data after bus=.


#3

I’ve found that, too. However this mactab/nameif method seems to name the interfaces by mac address. I’m working the other way around: I read the mac-addresses from two MAC-eeprom chips and write them to the /etc/network/interfaces file (hwaddress ether xx:xx:xx:xx:xx:xx line). So this won’t work for me I guess.


#4

I think the original purpose of nameif was to do it based on mac addr, but in my example above, the rule is based on a bus identifier. I’m not sure what the expected bus identifier would be for your devices though.