From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 18 18:14:59 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 366D12A3; Mon, 18 Aug 2014 18:14:59 +0000 (UTC) Received: from mail-oa0-x236.google.com (mail-oa0-x236.google.com [IPv6:2607:f8b0:4003:c02::236]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E94B03449; Mon, 18 Aug 2014 18:14:58 +0000 (UTC) Received: by mail-oa0-f54.google.com with SMTP id n16so4308083oag.41 for ; Mon, 18 Aug 2014 11:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=z2H2CKxbJ5SQwFGnnhohbyuBVtuHqQJzhvRnjbHGL9E=; b=nnmnuWuuZxw3Bxm2Ky9N0iARWHQQrSkE+Z8TL65iS+LH6unUjdTX1vS4wbLGPey3HJ Xcp2LZRYbVhEMv8Kk2VUJ+lgEFrJ+zgytMYi+fY/VtPnmnhOI3cY2Vqh/p2gxT4sK/U8 Daq4UGbwoEF8hhuPzX1jqKzoeuXP6fVAVJFITWlpU6WY1g4z+NfJJGgtBJCIiaDtgqEz fYwt9Rbu+LwY6L6bEaOP4Y1QLnwys1CT4e7jzk8ckEmXCJCqcI8RX84PuX1wjd/hqmgz 0tBYwr2DrGm7ApCC2//4G6PGEqqkCFfpIkWHUY3TaCLyI7cOITq+31sCmCwiNGUqBiw8 MiVA== MIME-Version: 1.0 X-Received: by 10.60.164.9 with SMTP id ym9mr38197192oeb.26.1408385698309; Mon, 18 Aug 2014 11:14:58 -0700 (PDT) Received: by 10.76.187.39 with HTTP; Mon, 18 Aug 2014 11:14:58 -0700 (PDT) In-Reply-To: References: <20140818081223.GA6099@spindle.one-eyed-alien.net> Date: Mon, 18 Aug 2014 14:14:58 -0400 Message-ID: Subject: Re: Common storage of original MAC address From: Ryan Stone To: "Pokala, Ravi" Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-hackers@freebsd.org" , Brooks Davis 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 18:14:59 -0000 On Mon, Aug 18, 2014 at 11:59 AM, Pokala, Ravi 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.." - 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.