Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Aug 2014 14:14:58 -0400
From:      Ryan Stone <rysto32@gmail.com>
To:        "Pokala, Ravi" <rpokala@panasas.com>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>, Brooks Davis <brooks@freebsd.org>
Subject:   Re: Common storage of original MAC address
Message-ID:  <CAFMmRNwDrEY-Z5VP%2B_03-ZGf_6Ye89jCKO-HpfqYAoZjATFAdQ@mail.gmail.com>
In-Reply-To: <D0175C55.11C472%rpokala@panasas.com>
References:  <D0168955.11C3AD%rpokala@panasas.com> <20140818081223.GA6099@spindle.one-eyed-alien.net> <D0175C55.11C472%rpokala@panasas.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Aug 18, 2014 at 11:59 AM, Pokala, Ravi <rpokala@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFMmRNwDrEY-Z5VP%2B_03-ZGf_6Ye89jCKO-HpfqYAoZjATFAdQ>