Common storage of original MAC address
Pokala, Ravi
rpokala at panasas.com
Mon Aug 18 17:54:30 UTC 2014
-----Original Message-----
From: Brooks Davis <brooks at freebsd.org>
Date: Monday, August 18, 2014 at 1:12 AM
To: Ravi Pokala <rpokala at panasas.com>
Cc: "freebsd-hackers at freebsd.org" <freebsd-hackers at freebsd.org>
Subject: Re: Common storage of original MAC address
>On Sun, Aug 17, 2014 at 11:31:19PM +0000, Pokala, Ravi wrote:
>>...
>>
>> Are there any objections to this idea? Any suggestions as to where we
>> might stash the original MAC?
>
>I think I'd store the original address in struct arpcom at attach time
>and publish it in the dev.<driver>.<unit> sysctl namespace.
>
>-- Brooks
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
More information about the freebsd-hackers
mailing list