Commit e4752fac authored by Ad Schellevis's avatar Ad Schellevis

(legacy) some more cleanups interfaces_assign.php

parent 8c182ca4
...@@ -268,54 +268,57 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -268,54 +268,57 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (count($input_errors) == 0) { if (count($input_errors) == 0) {
/* No errors detected, so update the config */ /* No errors detected, so update the config */
$changes = 0;
foreach ($_POST as $ifname => $ifport) { foreach ($_POST as $ifname => $ifport) {
if ($ifname == 'lan' || $ifname == 'wan' || substr($ifname, 0, 3) == 'opt') { if (!is_array($ifport) && ($ifname == 'lan' || $ifname == 'wan' || substr($ifname, 0, 3) == 'opt')) {
if (!is_array($ifport)) { $reloadif = false;
$reloadif = false; if (!empty($config['interfaces'][$ifname]['if']) && $config['interfaces'][$ifname]['if'] <> $ifport) {
if (!empty($config['interfaces'][$ifname]['if']) && $config['interfaces'][$ifname]['if'] <> $ifport) { interface_bring_down($ifname);
interface_bring_down($ifname); /* Mark this to be reconfigured in any case. */
/* Mark this to be reconfigured in any case. */ $reloadif = true;
$reloadif = true; }
} $config['interfaces'][$ifname]['if'] = $ifport;
$config['interfaces'][$ifname]['if'] = $ifport; if ($interfaces[$ifport]['section'] == 'ppps.ppp') {
if ($interfaces[$ifport]['section'] == 'ppps.ppp') { $config['interfaces'][$ifname]['ipaddr'] = $interfaces[$ifport]['type'];
$config['interfaces'][$ifname]['ipaddr'] = $interfaces[$ifport]['type']; }
}
if (substr($ifport, 0, 3) == 'gre' || substr($ifport, 0, 3) == 'gif') { if (substr($ifport, 0, 3) == 'gre' || substr($ifport, 0, 3) == 'gif') {
unset($config['interfaces'][$ifname]['ipaddr']); unset($config['interfaces'][$ifname]['ipaddr']);
unset($config['interfaces'][$ifname]['subnet']); unset($config['interfaces'][$ifname]['subnet']);
unset($config['interfaces'][$ifname]['ipaddrv6']); unset($config['interfaces'][$ifname]['ipaddrv6']);
unset($config['interfaces'][$ifname]['subnetv6']); unset($config['interfaces'][$ifname]['subnetv6']);
} }
/* check for wireless interfaces, set or clear ['wireless'] */ /* check for wireless interfaces, set or clear ['wireless'] */
if (match_wireless_interface($ifport)) { if (match_wireless_interface($ifport)) {
if (empty($config['interfaces'][$ifname]['wireless'])) { if (empty($config['interfaces'][$ifname]['wireless'])) {
$config['interfaces'][$ifname]['wireless'] = array(); $config['interfaces'][$ifname]['wireless'] = array();
}
} elseif (isset($config['interfaces'][$ifname]['wireless'])) {
unset($config['interfaces'][$ifname]['wireless']);
} }
} elseif (isset($config['interfaces'][$ifname]['wireless'])) {
unset($config['interfaces'][$ifname]['wireless']);
}
/* make sure there is a descr for all interfaces */ /* make sure there is a descr for all interfaces */
if (!isset($config['interfaces'][$ifname]['descr'])) { if (!isset($config['interfaces'][$ifname]['descr'])) {
$config['interfaces'][$ifname]['descr'] = strtoupper($ifname); $config['interfaces'][$ifname]['descr'] = strtoupper($ifname);
} }
if ($reloadif) { if ($reloadif) {
if (match_wireless_interface($ifport)) { if (match_wireless_interface($ifport)) {
interface_sync_wireless_clones($config['interfaces'][$ifname], false); interface_sync_wireless_clones($config['interfaces'][$ifname], false);
}
/* Reload all for the interface. */
interface_configure($ifname, true);
// reload filter (original from apply action)
filter_configure();
} }
/* Reload all for the interface. */
interface_configure($ifname, true);
// count changes
$changes++;
} }
} }
} }
if ($changes > 0) {
// reload filter when interfaces have changed (original from apply action)
filter_configure();
}
write_config(); write_config();
enable_rrd_graphing(); enable_rrd_graphing();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment