Commit 4ca71c32 authored by Franco Fichtner's avatar Franco Fichtner

interfaces: one sweep through the file

parent 88787945
...@@ -155,12 +155,15 @@ function interfaces_vlan_configure($realif = '', $verbose = false) ...@@ -155,12 +155,15 @@ function interfaces_vlan_configure($realif = '', $verbose = false)
{ {
global $config; global $config;
if (!isset($config['vlans']['vlan'])) {
return;
}
if ($verbose) { if ($verbose) {
echo 'Configuring VLAN interfaces...'; echo 'Configuring VLAN interfaces...';
flush(); flush();
} }
if (isset($config['vlans']['vlan'])) {
foreach ($config['vlans']['vlan'] as $vlan) { foreach ($config['vlans']['vlan'] as $vlan) {
if (empty($vlan['vlanif'])) { if (empty($vlan['vlanif'])) {
$vlan['vlanif'] = "{$vlan['if']}_vlan{$vlan['tag']}"; $vlan['vlanif'] = "{$vlan['if']}_vlan{$vlan['tag']}";
...@@ -170,7 +173,6 @@ function interfaces_vlan_configure($realif = '', $verbose = false) ...@@ -170,7 +173,6 @@ function interfaces_vlan_configure($realif = '', $verbose = false)
} }
interface_vlan_configure($vlan); interface_vlan_configure($vlan);
} }
}
if ($verbose) { if ($verbose) {
echo "done.\n"; echo "done.\n";
...@@ -318,16 +320,18 @@ function interfaces_qinq_configure($verbose = false) ...@@ -318,16 +320,18 @@ function interfaces_qinq_configure($verbose = false)
{ {
global $config; global $config;
if (!isset($config['qinqs']['qinqentry'])) {
return;
}
if ($verbose) { if ($verbose) {
echo 'Configuring QinQ interfaces...'; echo 'Configuring QinQ interfaces...';
flush(); flush();
} }
if (isset($config['qinqs']['qinqentry'])) {
foreach ($config['qinqs']['qinqentry'] as $qinq) { foreach ($config['qinqs']['qinqentry'] as $qinq) {
interface_qinq_configure($qinq); interface_qinq_configure($qinq);
} }
}
if ($verbose) { if ($verbose) {
echo "done.\n"; echo "done.\n";
...@@ -664,6 +668,10 @@ function interfaces_lagg_configure($realif = '', $verbose = false) ...@@ -664,6 +668,10 @@ function interfaces_lagg_configure($realif = '', $verbose = false)
{ {
global $config; global $config;
if (!isset($config['laggs']['lagg'])) {
return;
}
if ($verbose) { if ($verbose) {
echo 'Configuring LAGG interfaces...'; echo 'Configuring LAGG interfaces...';
flush(); flush();
...@@ -671,7 +679,6 @@ function interfaces_lagg_configure($realif = '', $verbose = false) ...@@ -671,7 +679,6 @@ function interfaces_lagg_configure($realif = '', $verbose = false)
$i = 0; $i = 0;
if (isset($config['laggs']['lagg'])) {
foreach ($config['laggs']['lagg'] as $lagg) { foreach ($config['laggs']['lagg'] as $lagg) {
if (empty($lagg['laggif'])) { if (empty($lagg['laggif'])) {
$lagg['laggif'] = "lagg{$i}"; $lagg['laggif'] = "lagg{$i}";
...@@ -682,7 +689,6 @@ function interfaces_lagg_configure($realif = '', $verbose = false) ...@@ -682,7 +689,6 @@ function interfaces_lagg_configure($realif = '', $verbose = false)
interface_lagg_configure($lagg); interface_lagg_configure($lagg);
$i++; $i++;
} }
}
if ($verbose) { if ($verbose) {
echo "done.\n"; echo "done.\n";
...@@ -743,11 +749,19 @@ function interface_lagg_configure(&$lagg) ...@@ -743,11 +749,19 @@ function interface_lagg_configure(&$lagg)
return $laggif; return $laggif;
} }
function interfaces_gre_configure($checkparent = 0, $realif = "") function interfaces_gre_configure($checkparent = 0, $verbose = false, $realif = '')
{ {
global $config; global $config;
if (isset($config['gres']['gre'])) { if (!isset($config['gres']['gre'])) {
return;
}
if ($verbose) {
echo "Configuring GRE interfaces ($checkparent)...";
flush();
}
foreach ($config['gres']['gre'] as $i => $gre) { foreach ($config['gres']['gre'] as $i => $gre) {
if (empty($gre['greif'])) { if (empty($gre['greif'])) {
$gre['greif'] = "gre{$i}"; $gre['greif'] = "gre{$i}";
...@@ -757,23 +771,26 @@ function interfaces_gre_configure($checkparent = 0, $realif = "") ...@@ -757,23 +771,26 @@ function interfaces_gre_configure($checkparent = 0, $realif = "")
} }
if ($checkparent == 1) { if ($checkparent == 1) {
if (strstr($gre['if'], "_vip")) { if (strstr($gre['if'], '_vip')) {
continue; continue;
} }
if (!empty($config['interfaces'][$gre['if']]) && $config['interfaces'][$gre['if']]['ipaddrv6'] == "track6") { if (!empty($config['interfaces'][$gre['if']]) && $config['interfaces'][$gre['if']]['ipaddrv6'] == 'track6') {
continue; continue;
} }
} elseif ($checkparent == 2) { } elseif ($checkparent == 2) {
if (strstr($gre['if'], "_vip")) { if (strstr($gre['if'], '_vip')) {
continue; continue;
} }
if (empty($config['interfaces'][$gre['if']]) || $config['interfaces'][$gre['if']]['ipaddrv6'] != "track6") { if (empty($config['interfaces'][$gre['if']]) || $config['interfaces'][$gre['if']]['ipaddrv6'] != 'track6') {
continue; continue;
} }
} }
/* XXX: Maybe we should report any errors?! */
interface_gre_configure($gre); interface_gre_configure($gre);
} }
if ($verbose) {
echo "done.\n";
} }
} }
...@@ -845,11 +862,19 @@ function interface_gre_configure(&$gre, $grekey = "") ...@@ -845,11 +862,19 @@ function interface_gre_configure(&$gre, $grekey = "")
return $greif; return $greif;
} }
function interfaces_gif_configure($checkparent = 0, $realif = "") function interfaces_gif_configure($checkparent = 0, $verbose = false, $realif = '')
{ {
global $config; global $config;
if (isset($config['gifs']['gif'])) { if (!isset($config['gifs']['gif'])) {
return;
}
if ($verbose) {
echo "Configuring GIF interfaces ($checkparent)...";
flush();
}
foreach ($config['gifs']['gif'] as $i => $gif) { foreach ($config['gifs']['gif'] as $i => $gif) {
if (empty($gif['gifif'])) { if (empty($gif['gifif'])) {
$gre['gifif'] = "gif{$i}"; $gre['gifif'] = "gif{$i}";
...@@ -859,23 +884,26 @@ function interfaces_gif_configure($checkparent = 0, $realif = "") ...@@ -859,23 +884,26 @@ function interfaces_gif_configure($checkparent = 0, $realif = "")
} }
if ($checkparent == 1) { if ($checkparent == 1) {
if (strstr($gif['if'], "_vip")) { if (strstr($gif['if'], '_vip')) {
continue; continue;
} }
if (!empty($config['interfaces'][$gif['if']]) && $config['interfaces'][$gif['if']]['ipaddrv6'] == "track6") { if (!empty($config['interfaces'][$gif['if']]) && $config['interfaces'][$gif['if']]['ipaddrv6'] == 'track6') {
continue; continue;
} }
} elseif ($checkparent == 2) { } elseif ($checkparent == 2) {
if (strstr($gif['if'], "_vip")) { if (strstr($gif['if'], '_vip')) {
continue; continue;
} }
if (empty($config['interfaces'][$gif['if']]) || $config['interfaces'][$gif['if']]['ipaddrv6'] != "track6") { if (empty($config['interfaces'][$gif['if']]) || $config['interfaces'][$gif['if']]['ipaddrv6'] != 'track6') {
continue; continue;
} }
} }
/* XXX: Maybe we should report any errors?! */
interface_gif_configure($gif); interface_gif_configure($gif);
} }
if ($verbose) {
echo "done.\n";
} }
} }
...@@ -1008,8 +1036,8 @@ function interfaces_configure($verbose = false) ...@@ -1008,8 +1036,8 @@ function interfaces_configure($verbose = false)
* 2 - Do load gre/gif/bridge with parent/member as vip * 2 - Do load gre/gif/bridge with parent/member as vip
*/ */
interfaces_gre_configure(1); interfaces_gre_configure(1, $verbose);
interfaces_gif_configure(1); interfaces_gif_configure(1, $verbose);
interfaces_bridge_configure(1); interfaces_bridge_configure(1);
foreach ($track6_list as $if => $ifname) { foreach ($track6_list as $if => $ifname) {
...@@ -1017,8 +1045,8 @@ function interfaces_configure($verbose = false) ...@@ -1017,8 +1045,8 @@ function interfaces_configure($verbose = false)
} }
interfaces_vips_configure('', $verbose); interfaces_vips_configure('', $verbose);
interfaces_gre_configure(2); interfaces_gre_configure(2, $verbose);
interfaces_gif_configure(2); interfaces_gif_configure(2, $verbose);
foreach ($delayed_list as $if => $ifname) { foreach ($delayed_list as $if => $ifname) {
interface_configure($if, $reload, false, $verbose); interface_configure($if, $reload, false, $verbose);
...@@ -1038,14 +1066,6 @@ function interfaces_configure($verbose = false) ...@@ -1038,14 +1066,6 @@ function interfaces_configure($verbose = false)
plugins_configure('dns', $verbose); plugins_configure('dns', $verbose);
services_dhcpd_configure('all', array(), $verbose); services_dhcpd_configure('all', array(), $verbose);
} }
return 0;
}
function interface_reconfigure($interface = 'wan', $reloadall = false)
{
interface_bring_down($interface);
interface_configure($interface, $reloadall);
} }
function interface_vip_bring_down($vip) function interface_vip_bring_down($vip)
...@@ -1929,9 +1949,19 @@ function interface_sync_wireless_clones(&$ifcfg, $sync_changes = false) ...@@ -1929,9 +1949,19 @@ function interface_sync_wireless_clones(&$ifcfg, $sync_changes = false)
{ {
global $config; global $config;
$shared_settings = array('standard', 'turbo', 'protmode', 'txpower', 'channel', $shared_settings = array(
'diversity', 'txantenna', 'rxantenna', 'channel',
'regdomain', 'regcountry', 'reglocation'); 'diversity',
'protmode',
'regcountry',
'regdomain',
'reglocation',
'rxantenna',
'standard',
'turbo',
'txantenna',
'txpower',
);
if (!is_interface_wireless($ifcfg['if'])) { if (!is_interface_wireless($ifcfg['if'])) {
return; return;
...@@ -2480,18 +2510,18 @@ function interface_virtual_create($interface) ...@@ -2480,18 +2510,18 @@ function interface_virtual_create($interface)
{ {
global $config; global $config;
if (strstr($interface, "_vlan")) { if (strstr($interface, '_vlan')) {
interfaces_vlan_configure($vlan); interfaces_vlan_configure($vlan);
} elseif (substr($interface, 0, 3) == "gre") { } elseif (substr($interface, 0, 3) == 'gre') {
interfaces_gre_configure(0, $interface); interfaces_gre_configure(0, false, $interface);
} elseif (substr($interface, 0, 3) == "gif") { } elseif (substr($interface, 0, 3) == 'gif') {
interfaces_gif_configure(0, $interface); interfaces_gif_configure(0, false, $interface);
} elseif (substr($interface, 0, 4) == "ovpn") { } elseif (substr($interface, 0, 4) == 'ovpn') {
/* XXX this looks like a plugin spot... */ /* XXX this looks like a plugin spot... */
openvpn_configure_interface($interface); openvpn_configure_interface($interface);
} elseif (substr($interface, 0, 4) == "lagg") { } elseif (substr($interface, 0, 4) == 'lagg') {
interfaces_lagg_configure($interface); interfaces_lagg_configure($interface);
} elseif (substr($interface, 0, 6) == "bridge") { } elseif (substr($interface, 0, 6) == 'bridge') {
interfaces_bridge_configure(0, $interface); interfaces_bridge_configure(0, $interface);
} }
} }
...@@ -4034,7 +4064,6 @@ function guess_interface_from_ip($ipaddress) ...@@ -4034,7 +4064,6 @@ function guess_interface_from_ip($ipaddress)
return $ret; return $ret;
} }
function link_interface_to_track6($int, $action = '') function link_interface_to_track6($int, $action = '')
{ {
global $config; global $config;
......
...@@ -489,7 +489,8 @@ $upperifname = strtoupper($interface); ...@@ -489,7 +489,8 @@ $upperifname = strtoupper($interface);
if (!$dry_run) { if (!$dry_run) {
echo "\nPlease wait while the changes are saved to {$upperifname}..."; echo "\nPlease wait while the changes are saved to {$upperifname}...";
write_config(sprintf('%s IP configuration from console menu', $interface)); write_config(sprintf('%s IP configuration from console menu', $interface));
interface_reconfigure(strtolower($upperifname)); interface_bring_down($interface);
interface_configure($interface);
echo "\n Reloading filter..."; echo "\n Reloading filter...";
filter_configure_sync(); filter_configure_sync();
if ($restart_dhcpd) { if ($restart_dhcpd) {
......
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