This addresses a server performance issue under FreeBSD, where the interface hardware address discovery process (
get_hw_addr) is quite slow when there are hundreds or thousands of addresses/interfaces. The slowness is because the BPF code iterates
getifaddrs() entirely for each interface.
getifaddrs returns all interface aliases, so you end up with a bad O(n^2) performance situation when there are hundreds or thousands of network interfaces (i.e. VLANs). This MR leverages the fact that
if_nametoindex is a fast lookup, which can be passed to a sysctl that returns a single struct containing the MAC address.
I realize this is probably an exceptional corner case, however I have many production systems in this configuration, and I am willing to help get some kind of appropriate fix upstreamed.