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