diff options
author | Renato Botelho <renato@netgate.com> | 2017-02-03 08:46:14 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-02-03 08:46:14 -0200 |
commit | 042911d34ab846e7241deeb9fd6469a1460febcf (patch) | |
tree | 4cbe758519212be432abbd496dc799b54982b6da /src/etc/inc/interfaces.inc | |
parent | 77890d7d47e6d759a4b614a5564dbe6aeb7df91c (diff) | |
download | pfsense-042911d34ab846e7241deeb9fd6469a1460febcf.zip pfsense-042911d34ab846e7241deeb9fd6469a1460febcf.tar.gz |
Fix #7120: Restore vendor mac address when spoofmac is set to blank
Diffstat (limited to 'src/etc/inc/interfaces.inc')
-rw-r--r-- | src/etc/inc/interfaces.inc | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 7310e13..1889fda 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -3272,17 +3272,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. */ @@ -5990,11 +5992,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 |