diff options
author | NOYB <Al_Stu@Frontier.com> | 2017-02-05 02:01:29 -0800 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-04-26 18:06:39 -0300 |
commit | a822576e9b3d563eff0791c9d43350e0feef9442 (patch) | |
tree | 64f9d70395a2fb313c85b39c6889f9df33d52d12 | |
parent | e90c506f3b5479a278aef845087bc9b25c382ec0 (diff) | |
download | pfsense-a822576e9b3d563eff0791c9d43350e0feef9442.zip pfsense-a822576e9b3d563eff0791c9d43350e0feef9442.tar.gz |
Vendor MAC Retention File Consolidate
Use a single file for vendor MAC retention (vendor_mac).
a) Writes only one file during boot up rather than a file for each interface.
b) More efficient than numerous tiny files.
c) Friendlier to write cycle sensitive media in a RAM disk disabled system.
-rw-r--r-- | src/etc/inc/interfaces.inc | 8 | ||||
-rwxr-xr-x | src/etc/rc.bootup | 8 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index a1a6d3b..277f98b 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -5862,12 +5862,10 @@ function get_interface_vendor_mac($interface) { global $g; $mac = ""; - $mac_file = "{$g['vardb_path']}/vendor_mac_($interface)"; + $mac_file = "{$g['vardb_path']}/vendor_mac"; if (file_exists($mac_file)) { - $mac = file_get_contents($mac_file); - if (!is_macaddr($mac)) { - $mac = ""; - } + $vendor_mac_arr = json_decode(file_get_contents($mac_file), true); + $mac = (is_macaddr($vendor_mac_arr[$interface])) ? $vendor_mac_arr[$interface] : ''; } return $mac; diff --git a/src/etc/rc.bootup b/src/etc/rc.bootup index c084e89..c175214 100755 --- a/src/etc/rc.bootup +++ b/src/etc/rc.bootup @@ -190,7 +190,7 @@ echo "done.\n"; if (mwexec("/bin/kenv -q pfSense.boot 2>/dev/null") != 0) { /* Collect vendor MAC address for all interfaces */ $ifs = pfSense_interface_listget(); - unlink_if_exists("{$g['vardb_path']}/vendor_mac_*"); + unlink_if_exists("{$g['vardb_path']}/vendor_mac"); foreach ($ifs as $if) { $if_details = pfSense_get_interface_addresses($if); if (isset($if_details['iftype']) && @@ -203,10 +203,10 @@ if (mwexec("/bin/kenv -q pfSense.boot 2>/dev/null") != 0) { continue; } - @file_put_contents("{$g['vardb_path']}/vendor_mac_{$if}", - $if_details['macaddr']); + $vendor_mac_arr[$if] = $if_details['macaddr']; } - unset($ifs, $if); + @file_put_contents("{$g['vardb_path']}/vendor_mac", json_encode($vendor_mac_arr)); + unset($ifs, $if, $vendor_mac_arr); mwexec("/bin/kenv pfSense.boot=1"); } |