summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2017-02-03 08:46:14 -0200
committerRenato Botelho <renato@netgate.com>2017-04-26 18:05:59 -0300
commit358354b9f79376b9f163b73b766821dc061beaae (patch)
tree0ba2754d114dac8be27e66a4b0003e54323226d0
parentdeb15e0d35a5e16c53355ff20537e781f9538ab0 (diff)
downloadpfsense-358354b9f79376b9f163b73b766821dc061beaae.zip
pfsense-358354b9f79376b9f163b73b766821dc061beaae.tar.gz
Fix #7120: Restore vendor mac address when spoofmac is set to blank
-rw-r--r--src/etc/inc/interfaces.inc26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc
index f92a33c..db011cf 100644
--- a/src/etc/inc/interfaces.inc
+++ b/src/etc/inc/interfaces.inc
@@ -3264,17 +3264,19 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
interface_wireless_configure($realif, $wancfg, $wancfg['wireless']);
}
- $mac = get_interface_mac($realhwif);
+ $current_mac = get_interface_mac($realhwif);
+ $vendor_mac = get_interface_vendor_mac($realhwif);
+ $spoof_mac = $wancfg['spoofmac'] ?: $vendor_mac;
/*
* Don't try to reapply the spoofed MAC if it's already applied.
* When ifconfig link is used, it cycles the interface down/up, which triggers
* the interface config again, which attempts to spoof the MAC again,
* which cycles the link again...
*/
- if ($wancfg['spoofmac'] && ($wancfg['spoofmac'] != $mac)) {
+ if (!empty($spoof_mac) && ($spoof_mac != $current_mac)) {
mwexec("/sbin/ifconfig " . escapeshellarg($realhwif) .
- " link " . escapeshellarg($wancfg['spoofmac']));
- } elseif ($mac == "ff:ff:ff:ff:ff:ff") {
+ " link " . escapeshellarg($spoof_mac));
+ } elseif ($current_mac == "ff:ff:ff:ff:ff:ff") {
/* this is not a valid mac address. generate a
* temporary mac address so the machine can get online.
*/
@@ -5847,11 +5849,25 @@ function get_interface_mtu($interface) {
}
function get_interface_mac($interface) {
-
$macinfo = pfSense_get_interface_addresses($interface);
return $macinfo["macaddr"];
}
+function get_interface_vendor_mac($interface) {
+ global $g;
+
+ $mac = "";
+ $mac_file = "{$g['cf_conf_path']}/vendor_mac_{$interface}";
+ if (file_exists($mac_file)) {
+ $mac = file_get_contents($mac_file);
+ if (!is_macaddr($mac)) {
+ $mac = "";
+ }
+ }
+
+ return $mac;
+}
+
/****f* pfsense-utils/generate_random_mac_address
* NAME
* generate_random_mac - generates a random mac address
OpenPOWER on IntegriCloud