Re: How to handle USB CDC driver randomly assigned MAC



On Mon, Mar 18, 2013 at 5:45 PM, Dan Williams <dcbw redhat com> wrote:
On Sun, 2013-03-17 at 13:39 +0200, test name wrote:
Hi,

I'm busy with a new embedded design, and I'd really like to use the
USB gadget CDC EEM driver for connectivity to the device. On the PC
side I get a random MAC address for the usb0 interface each time the
usbnet and cdc_eem driver is reloaded.

That's probably because your device doesn't have an assigned MAC stored
anywhere right?  EEM/usbnet do have the ability to retrieve the
permanent MAC address if the device has one, but of course that requires
support on the embedded device side, and some memory to store the MAC,
and the ability of your organization to assign MAC addresses to devices
with your vendor OUI.

What would be the best way to handle this in NM? I want to use ipv4
link local addressing on the usb0 interface, but NM forgets this each
time the MAC is reset.

Teach usbnet/cdc_eem to give the same MAC every time?
Use udev/systemd to rename device based on USB VID/PID?
Handle locally assigned MACs differently in NM?

At the moment, the best solution is to use udev rules to assign the same
MAC to the interface every time it's connected, either based on
interface name or based on USB serial number or other characteristics.
We just merged a feature (targeted to NM 0.9.10) that will allow you to
"lock" a connection to an interface based on name, where previously you
could only do this on MAC address.

In any case, if you do use udev rules to assign a stable MAC to the
device, then you'll create a new connection that's "locked" to that MAC
address and set the IPv4 addressing method to "link-local".  That would
be represented by a 'keyfile'-type connection like this, which you'd
drop into /etc/NetworkManager/system-connections/ :

[connection]
id=Embedded Link-Local
uuid=4e80a56d-c99f-4aad-a6dd-b449bc398c57
type=802-3-ethernet
autoconnect=true

[802-3-ethernet]
mac-address=00:11:22:33:44:55

[ipv4]
method=link-local

Dan


Thanks, got it working with this udev rule:

SUBSYSTEM=="net", ACTION=="add", ENV{ID_BUS}=="usb",
ENV{ID_VENDOR_ID}=="xxxx", RUN="/sbin/ip link set %k address
02:11:22:33:44:%n"


where xxxx is my USB VID.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]