Common storage of original MAC address
Allan Jude
allanjude at freebsd.org
Mon Aug 18 19:15:00 UTC 2014
On 2014-08-18 14:14, Ryan Stone wrote:
> On Mon, Aug 18, 2014 at 11:59 AM, Pokala, Ravi <rpokala at panasas.com> wrote:
>
>> Thanks you Brooks.
>>
>> I'm not very familiar w/ the network stack, so I could use a little more
>> guidance. The naive part of me says to just add
>>
>> char orig_mac_addr[18];
>>
>> to arpcom, and do something like
>>
>> snprintf(IFP2AC(ifp)->orig_mac_addr,
>> sizeof(IFP2AC(ifp)->orig_mac_addr), "%6D", lla, ":");
>>
>> to populate it in ether_ifattach().
>>
>> The slightly more knowledgeable part of me is aware that there are things
>> other than ethernet out there, we might want to save the original address
>> for those too at some point, and so a perfectly-sized char-array might not
>> be the right thing here.
>>
>> With regards to using "dev.<driver>.<unit>" - that's actually what we've
>> been doing:
>>
>> SYSCTL_ADD_STRING(device_get_sysctl_ctx(dev),
>> SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
>> "orig_mac_addr", CTLFLAG_RD, sc->orig_mac_addr, 0,
>> "Original MAC address");
>>
>>
>> The wrinkle is that we need the device_t to put stuff under the "dev"
>> portion of the sysctl namespace, and we don't pass that into
>> ether_ifattach() (nor should we). So, we'd have to do that in every NIC
>> driver, which gets us back to having to modify the world.
>>
>> Thoughts?
>>
>> Thanks again,
>>
>> Ravi
>
> Personally I think that it would be better to save it in binary format
> and convert it to a string as needed. It would be useful to have the
> MAC address saved aside somewhere so that a "Restore MAC to HW
> default" ioctl could be implemented; this would be useful in the
> if_lagg driver to restore the MAC on a port after it has been removed
> from a lagg.
>
+1 for restoring the MAC after removing a device from a lagg(4) or bridge(4)
--
Allan Jude
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20140818/70b4ffc3/attachment.sig>
More information about the freebsd-hackers
mailing list