From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 18 17:54:30 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2A3B67B3; Mon, 18 Aug 2014 17:54:30 +0000 (UTC) Received: from natasha.panasas.com (natasha.panasas.com [209.166.131.148]) by mx1.freebsd.org (Postfix) with ESMTP id D5B303202; Mon, 18 Aug 2014 17:54:29 +0000 (UTC) Received: from seabiscuit.panasas.com (seabiscuit.panasas.com [172.17.132.204]) by natasha.panasas.com (8.13.1/8.13.1) with ESMTP id s7IFxSls018186; Mon, 18 Aug 2014 11:59:28 -0400 Received: from SEABISCUIT.int.panasas.com ([172.17.132.204]) by seabiscuit ([172.17.132.204]) with mapi id 14.03.0181.006; Mon, 18 Aug 2014 08:59:27 -0700 From: "Pokala, Ravi" To: Brooks Davis Subject: Re: Common storage of original MAC address Thread-Topic: Common storage of original MAC address Thread-Index: AQHPunNYUBEgYXTq+ky03AEN5pUz3ZvWeLmAgAANIwA= Date: Mon, 18 Aug 2014 15:59:26 +0000 Message-ID: References: <20140818081223.GA6099@spindle.one-eyed-alien.net> In-Reply-To: <20140818081223.GA6099@spindle.one-eyed-alien.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.4.3.140616 x-originating-ip: [172.17.28.63] Content-Type: text/plain; charset="us-ascii" Content-ID: <9CBE8B653AF6B14396904E107E276EEF@panasas.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2014 17:54:30 -0000 -----Original Message----- From: Brooks Davis Date: Monday, August 18, 2014 at 1:12 AM To: Ravi Pokala Cc: "freebsd-hackers@freebsd.org" Subject: Re: Common storage of original MAC address >On Sun, Aug 17, 2014 at 11:31:19PM +0000, Pokala, Ravi wrote: >>... >>=20 >> 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.. 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.." - 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