Bug 194386 - Common storage of original MAC address
Summary: Common storage of original MAC address
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Gleb Smirnoff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-15 19:59 UTC by Ravi Pokala
Modified: 2017-05-18 23:42 UTC (History)
7 users (show)

See Also:


Attachments
Patch to add common storage of original MAC address (4.59 KB, patch)
2014-10-15 20:01 UTC, Ravi Pokala
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ravi Pokala 2014-10-15 19:59:08 UTC
Add a common location in the network stack to store the original MAC address for an interface. It will be preserved even if the working MAC address has changed due to being manually set w/ `ifconfig', or being part of a lagg(4).

Discussed on freebsd-hackers@ in thread "Common storage of original MAC address":

https://lists.freebsd.org/pipermail/freebsd-hackers/2014-August/thread.html#45822
https://lists.freebsd.org/pipermail/freebsd-hackers/2014-September/thread.html#45955
Comment 1 Ravi Pokala 2014-10-15 20:01:25 UTC
Created attachment 148347 [details]
Patch to add common storage of original MAC address

194386.patch - Patch to implement the desired functionality, as discussed on freebsd-hackers@.
Comment 2 Ravi Pokala 2014-10-16 21:27:30 UTC
Brooks / Allan / John - since you all chimed in on the thread where this was designed, could one of you review this and submit it for me? Thanks!
Comment 3 Ravi Pokala 2014-11-07 15:43:17 UTC
Urk. https://svnweb.freebsd.org/base?view=revision&revision=274231 just made it into -HEAD. It removes 'struct arpcom', which slightly... destroys this patch. And just after I harassed jhb@ at the DevSummit about submitting it for me! :-(

glebius@ - how do you suggest I rework this patch in light of your removal of 'struct arpcom'?
Comment 4 Gleb Smirnoff freebsd_committer 2014-11-10 08:45:29 UTC
Ravi,

I grabbed the PR to not forget about the problem and address during my ifnet work, that I am doing in head.
Comment 5 Ravi Pokala 2014-11-10 15:33:04 UTC
Thanks Gleb.
Comment 6 rainbow 2015-06-29 16:57:32 UTC
any news? because will be great to have a way to "reset" the mac address, maybe through ifconfig.
thanks
Comment 7 Ravi Pokala 2015-11-05 01:21:39 UTC
Gleb,

My understanding is that (the bulk of?) your "struct ifnet" work is done. When do you think you could get to this? Thanks!
Comment 8 Gleb Smirnoff freebsd_committer 2015-11-05 07:37:32 UTC
Unfortunately no. And it is likely that it won't be done before 11.0-RELEASE.

https://wiki.freebsd.org/projects/ifnet
Comment 9 Ravi Pokala 2017-05-05 21:36:53 UTC
Re-worked diff: https://reviews.freebsd.org/D10609
Comment 10 commit-hook freebsd_committer 2017-05-10 22:14:43 UTC
A commit references this bug:

Author: rpokala
Date: Wed May 10 22:13:48 UTC 2017
New revision: 318160
URL: https://svnweb.freebsd.org/changeset/base/318160

Log:
  Persistently store NIC's hardware MAC address, and add a way to retrive it

  The MAC address reported by `ifconfig ${nic} ether' does not always match
  the address in the hardware, as reported by the driver during attach. In
  particular, NICs which are components of a lagg(4) interface all report the
  same MAC.

  When attaching, the NIC driver passes the MAC address it read from the
  hardware as an argument to ether_ifattach(). Keep a second copy of it, and
  create ioctl(SIOCGHWADDR) to return it. Teach `ifconfig' to report it along
  with the active MAC address.

  PR:		194386
  Reviewed by:	glebius
  MFC after:	1 week
  Sponsored by:	Panasas
  Differential Revision:	https://reviews.freebsd.org/D10609

Changes:
  head/sbin/ifconfig/af_link.c
  head/sys/net/if.c
  head/sys/net/if_ethersubr.c
  head/sys/net/if_var.h
  head/sys/sys/sockio.h
Comment 11 commit-hook freebsd_committer 2017-05-17 05:53:54 UTC
A commit references this bug:

Author: rpokala
Date: Wed May 17 05:53:25 UTC 2017
New revision: 318397
URL: https://svnweb.freebsd.org/changeset/base/318397

Log:
  MFC r318160, 318176: Persistently store NIC's hardware MAC address, and add
  a way to retrive it

  The MAC address reported by `ifconfig ${nic} ether' does not always match
  the address in the hardware, as reported by the driver during attach. In
  particular, NICs which are components of a lagg(4) interface all report the
  same MAC.

  When attaching, the NIC driver passes the MAC address it read from the
  hardware as an argument to ether_ifattach(). Keep a second copy of it, and
  create ioctl(SIOCGHWADDR) to return it. Teach `ifconfig' to report it along
  with the active MAC address.

  PR:		194386

Changes:
_U  stable/11/
  stable/11/sbin/ifconfig/af_link.c
  stable/11/sys/net/if.c
  stable/11/sys/net/if_ethersubr.c
  stable/11/sys/net/if_var.h
  stable/11/sys/sys/sockio.h
Comment 12 commit-hook freebsd_committer 2017-05-17 22:29:54 UTC
A commit references this bug:

Author: rpokala
Date: Wed May 17 22:29:26 UTC 2017
New revision: 318430
URL: https://svnweb.freebsd.org/changeset/base/318430

Log:
  MFC r318160, 318176: Persistently store NIC's hardware MAC address, and add
  a way to retrive it

  NOTE: Due to restructuring, the merges didn't apply cleanly; the resulting
  change is almost identical to what went into stable/11, but in some cases in
  different locations.

  The MAC address reported by `ifconfig ${nic} ether' does not always match
  the address in the hardware, as reported by the driver during attach. In
  particular, NICs which are components of a lagg(4) interface all report the
  same MAC.

  When attaching, the NIC driver passes the MAC address it read from the
  hardware as an argument to ether_ifattach(). Keep a second copy of it, and
  create ioctl(SIOCGHWADDR) to return it. Teach `ifconfig' to report it along
  with the active MAC address.

  PR:		194386

Changes:
_U  stable/10/
  stable/10/sbin/ifconfig/af_link.c
  stable/10/sys/net/if.c
  stable/10/sys/net/if_ethersubr.c
  stable/10/sys/net/if_var.h
  stable/10/sys/sys/sockio.h
Comment 13 commit-hook freebsd_committer 2017-05-18 23:42:03 UTC
A commit references this bug:

Author: rpokala
Date: Thu May 18 23:41:18 UTC 2017
New revision: 318504
URL: https://svnweb.freebsd.org/changeset/base/318504

Log:
  Persistently store NIC's hardware MAC address, and add a way to retrive it

  jhb pointed out that (struct ifnet) is part of the network driver KBI, and
  thus the offsets of internal fields must not change. Therefore, move the new
  "if_hw_addr" field to the end, and consume one of the "if_pspare"s; that's
  what they're there for. The new field replaces the *last* element of that
  array; that way, offsetof(if_pspare) and offsetof(if_ispare) are unchanged
  compared to before r318397.

  PR:		194386
  Reviewed by:	jhb
  Pointyhat to:	rpokala
  Sponsored by:	Panasas

Changes:
  stable/11/sys/net/if_var.h
Comment 14 commit-hook freebsd_committer 2017-05-18 23:42:06 UTC
A commit references this bug:

Author: rpokala
Date: Thu May 18 23:41:34 UTC 2017
New revision: 318505
URL: https://svnweb.freebsd.org/changeset/base/318505

Log:
  Persistently store NIC's hardware MAC address, and add a way to retrive it

  jhb pointed out that (struct ifnet) is part of the network driver KBI, and
  thus the offsets of internal fields must not change. Therefore, move the new
  "if_hw_addr" field to the end, and consume one of the "if_pspare"s; that's
  what they're there for. Because netmap on stable/10 uses "if_pspare[0]", the
  new field replaces the *last* element of that array; that way,
  offsetof(if_pspare) is unchanged compared to before r318430.

  PR:		194386
  Reviewed by:	jhb
  Pointyhat to:	rpokala
  Sponsored by:	Panasas

Changes:
  stable/10/sys/net/if_var.h