Bug 195692 - Feature request: Make devd read MAC addresses
Summary: Feature request: Make devd read MAC addresses
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-net (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-04 22:49 UTC by greencoppermine
Modified: 2017-12-08 22:50 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description greencoppermine 2014-12-04 22:49:59 UTC
I have been struggling with this problem:

https://docs.freebsd.org/cgi/getmsg.cgi?fetch=615680+0+current/freebsd-net

Which eventually lead me to use devd to solve the problem, however the ONLY reason I could solve it was because the vendor actually provided a unique serial number for each device.

Now, coming from Linux with 70-persistent-net.rules, in which devices can be matched and fixed for udev using their MAC addresses, I cannot imagine how easy it would have been to solve this problem had devd been able to read MAC addresses.

IMHO, and in all respect, it makes absolutely no sense that devd can get the device vendor, product, serialnumber, etc, but not the MAC address.

This would be extremely useful.

So hence this feature request.

Kindest regards.
Comment 1 greencoppermine 2014-12-04 22:51:38 UTC
Not to mention, which I forgot, most vendor does NOT provide a unique serial number! Hence, the MAC address is really important to be able to get from devd.
Comment 2 Warner Losh freebsd_committer freebsd_triage 2014-12-05 15:04:02 UTC
The MAC isn't a published piece of data in newbus. The data exists at the wrong layer for newbus to access it. devd operates only at the newbus level for most things. However, devd doesn't care or need to care.  Just invoke a script whenever you get a ueX device. This script does a lookup on the MAC address using ifconfig. It can then rename it to whatever it wants for the fixup.

% cat /etc/ifmap
00:25:90:34:54:32 fred
00:25:90:34:44:23 barney
00:25:90:33:45:06 wilma
% cat fix-name
#!/bin/sh
dev=$1
mac=$(ifconfig $dev | grep ether | awk '{print $2;}')
name=$(grep ^$mac /etc/ifmap | awk '{print $2;}')
if [ -n $name ]; then
    ifconfig $dev name $name
fi
%

which seems simple and straight forward enough...
Comment 3 greencoppermine 2014-12-06 04:15:08 UTC
I agree this would work.

Nice solution based upon this:

https://docs.freebsd.org/cgi/getmsg.cgi?fetch=778441+0+current/freebsd-net

Thanks!
Comment 4 florian.heigl 2017-12-08 22:50:17 UTC
(In reply to greencoppermine from comment #3)
Hi,

you gave a link to a working solution, but the link is dead.
Do you happen to remember more info?

Got a similar issue (hub full of usb2serial's) and don't yet understand to convince devd to do the right things.
(call a script it seems)