mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Use recently added hwaddr field to restore original MAC address
This commit is contained in:
parent
576cbe26c1
commit
03af3cfd44
@ -5863,16 +5863,8 @@ function get_interface_mac($interface) {
|
||||
}
|
||||
|
||||
function get_interface_vendor_mac($interface) {
|
||||
global $g;
|
||||
|
||||
$mac = "";
|
||||
$mac_file = "{$g['vardb_path']}/vendor_mac";
|
||||
if (file_exists($mac_file)) {
|
||||
$vendor_mac_arr = json_decode(file_get_contents($mac_file), true);
|
||||
$mac = (is_macaddr($vendor_mac_arr[$interface])) ? $vendor_mac_arr[$interface] : '';
|
||||
}
|
||||
|
||||
return $mac;
|
||||
$macinfo = pfSense_get_interface_addresses($interface);
|
||||
return $macinfo["hwaddr"] ?: '';
|
||||
}
|
||||
|
||||
/****f* pfsense-utils/generate_random_mac_address
|
||||
|
||||
@ -186,32 +186,7 @@ echo "Loading configuration...";
|
||||
parse_config_bootup();
|
||||
echo "done.\n";
|
||||
|
||||
/* If pfSense.boot kenv is set, it's a reroot */
|
||||
if (mwexec("/bin/kenv -q pfSense.boot 2>/dev/null") != 0) {
|
||||
/* Collect vendor MAC address for all interfaces */
|
||||
$ifs = pfSense_interface_listget();
|
||||
foreach ($ifs as $if) {
|
||||
$if_details = pfSense_get_interface_addresses($if);
|
||||
if (isset($if_details['iftype']) &&
|
||||
$if_details['iftype'] == 'virtual') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($if_details['macaddr']) ||
|
||||
$if_details['macaddr'] == "00:00:00:00:00:00") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$vendor_mac_arr[$if] = $if_details['macaddr'];
|
||||
}
|
||||
$vendor_mac_arr_json = json_encode($vendor_mac_arr);
|
||||
if (@file_get_contents("{$g['vardb_path']}/vendor_mac") !== $vendor_mac_arr_json) {
|
||||
@file_put_contents("{$g['vardb_path']}/vendor_mac", $vendor_mac_arr_json);
|
||||
}
|
||||
unset($ifs, $if, $vendor_mac_arr, $vendor_mac_arr_json);
|
||||
mwexec("/usr/sbin/gnid > {$g['vardb_path']}/uniqueid 2>/dev/null");
|
||||
mwexec("/bin/kenv pfSense.boot=1");
|
||||
}
|
||||
mwexec("/usr/sbin/gnid > {$g['vardb_path']}/uniqueid 2>/dev/null");
|
||||
|
||||
/* run any early shell commands specified in config.xml */
|
||||
system_do_shell_commands(1);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user