mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
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.
This commit is contained in:
parent
e90c506f3b
commit
a822576e9b
@ -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;
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user