interfaces: cleanups for MAC spoofing; closes #1352

This commit is contained in:
Franco Fichtner 2019-02-05 22:02:53 +01:00
parent e5deb3e943
commit 7363445d8d

View File

@ -2387,24 +2387,20 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
interface_wireless_configure($realif, $wancfg, $wancfg['wireless']);
}
$mac = get_interface_mac($realhwif);
/*
* 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...
* 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 (!empty($wancfg['spoofmac']) && strcasecmp($wancfg['spoofmac'], $mac)) {
mwexec("/sbin/ifconfig " . escapeshellarg($realhwif) .
" link " . escapeshellarg($wancfg['spoofmac']));
if (!empty($wancfg['spoofmac']) && strcasecmp($wancfg['spoofmac'], get_interface_mac($realhwif))) {
mwexecf('/sbin/ifconfig %s link %s', array($realhwif, $wancfg['spoofmac']));
/* All vlans need to spoof their parent mac address, too. */
if (isset($config['vlans']['vlan'])) {
foreach ($config['vlans']['vlan'] as $vlan) {
if ($vlan['if'] == $realhwif) {
mwexec("/sbin/ifconfig " . escapeshellarg($vlan['vlanif']) .
" link " . escapeshellarg($wancfg['spoofmac']));
mwexecf('/sbin/ifconfig %s link %s', array($vlan['vlanif'], $wancfg['spoofmac']));
}
}
}