Commit 79a6df22 authored by Ad Schellevis's avatar Ad Schellevis

(gwlb.inc) remove some unreachable code in return_gateways_array()

parent dc1ebe5b
...@@ -473,16 +473,7 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive ...@@ -473,16 +473,7 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
$found_defaultv4 = 0; $found_defaultv4 = 0;
$found_defaultv6 = 0; $found_defaultv6 = 0;
$interfaces = legacy_interface_listget(); $iflist = get_configured_interface_with_descr();
$interfaces_v4 = array();
$interfaces_v6 = array();
/* Loop through all interfaces with a gateway and add it to a array */
if ($disabled == false) {
$iflist = get_configured_interface_with_descr();
} else {
$iflist = get_configured_interface_with_descr(false, true);
}
/* Process/add dynamic v4 gateways. */ /* Process/add dynamic v4 gateways. */
foreach ($iflist as $ifname => $friendly) { foreach ($iflist as $ifname => $friendly) {
...@@ -490,23 +481,12 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive ...@@ -490,23 +481,12 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
continue; continue;
} }
if (empty($config['interfaces'][$ifname])) {
continue;
}
$ifcfg = &$config['interfaces'][$ifname]; $ifcfg = &$config['interfaces'][$ifname];
if (!isset($ifcfg['enable'])) {
continue;
}
if (!empty($ifcfg['ipaddr']) && is_ipaddrv4($ifcfg['ipaddr'])) { if (!empty($ifcfg['ipaddr']) && is_ipaddrv4($ifcfg['ipaddr'])) {
continue; continue;
} }
if (isset($interfaces_v4[$ifname])) {
continue;
}
$ctype = ''; $ctype = '';
switch($ifcfg['ipaddr']) { switch($ifcfg['ipaddr']) {
case "dhcp": case "dhcp":
...@@ -542,7 +522,7 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive ...@@ -542,7 +522,7 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
$gateway['name'] = "{$friendly}{$ctype}"; $gateway['name'] = "{$friendly}{$ctype}";
$gateway['attribute'] = "system"; $gateway['attribute'] = "system";
if (($gateway['dynamic'] === "default") && ($found_defaultv4 == 0)) { if ($gateway['dynamic'] === "default" && $found_defaultv4 == 0) {
$gateway['defaultgw'] = true; $gateway['defaultgw'] = true;
$gateway['dynamic'] = true; $gateway['dynamic'] = true;
$found_defaultv4 = 1; $found_defaultv4 = 1;
...@@ -568,7 +548,6 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive ...@@ -568,7 +548,6 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
$gateway['monitor_disable'] = true; $gateway['monitor_disable'] = true;
$gateways_arr[$gateway['name']] = $gateway; $gateways_arr[$gateway['name']] = $gateway;
} }
unset($gateway);
/* Process/add dynamic v6 gateways. */ /* Process/add dynamic v6 gateways. */
foreach ($iflist as $ifname => $friendly) { foreach ($iflist as $ifname => $friendly) {
...@@ -586,18 +565,11 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive ...@@ -586,18 +565,11 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
} }
$ifcfg = &$config['interfaces'][$ifname]; $ifcfg = &$config['interfaces'][$ifname];
if (!isset($ifcfg['enable'])) {
continue;
}
if (!empty($ifcfg['ipaddrv6']) && is_ipaddrv6($ifcfg['ipaddrv6'])) { if (!empty($ifcfg['ipaddrv6']) && is_ipaddrv6($ifcfg['ipaddrv6'])) {
continue; continue;
} }
if (isset($interfaces_v6[$ifname])) {
continue;
}
$ctype = ''; $ctype = '';
switch($ifcfg['ipaddrv6']) { switch($ifcfg['ipaddrv6']) {
case "slaac": case "slaac":
...@@ -669,7 +641,6 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive ...@@ -669,7 +641,6 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
$gateway['monitor_disable'] = true; $gateway['monitor_disable'] = true;
$gateways_arr[$gateway['name']] = $gateway; $gateways_arr[$gateway['name']] = $gateway;
} }
unset($gateway);
$i = -1; $i = -1;
/* Process/add all the configured gateways. */ /* Process/add all the configured gateways. */
...@@ -736,10 +707,8 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive ...@@ -736,10 +707,8 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
/* special treatment for tunnel interfaces */ /* special treatment for tunnel interfaces */
if ($gateway['ipprotocol'] == "inet6") { if ($gateway['ipprotocol'] == "inet6") {
$gateway['interface'] = get_real_interface($gateway['interface'], "inet6", false, false); $gateway['interface'] = get_real_interface($gateway['interface'], "inet6", false, false);
$interfaces_v6[$gateway['friendlyiface']] = $gateway['friendlyiface'];
} else { } else {
$gateway['interface'] = get_real_interface($gateway['interface'], "all", false, false); $gateway['interface'] = get_real_interface($gateway['interface'], "all", false, false);
$interfaces_v4[$gateway['friendlyiface']] = $gateway['friendlyiface'];
} }
/* entry has a default flag, use it */ /* entry has a default flag, use it */
...@@ -758,7 +727,6 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive ...@@ -758,7 +727,6 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
$gateways_arr[$gateway['name']] = $gateway; $gateways_arr[$gateway['name']] = $gateway;
} }
} }
unset($gateway);
if ($localhost === true) { if ($localhost === true) {
/* attach localhost for Null routes */ /* attach localhost for Null routes */
...@@ -776,7 +744,7 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive ...@@ -776,7 +744,7 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
$gateways_arr['Null6'] = $gwlo6; $gateways_arr['Null6'] = $gwlo6;
} }
return($gateways_arr); return $gateways_arr;
} }
function fixup_default_gateway($ipprotocol, $gateways_status, $gateways_arr) function fixup_default_gateway($ipprotocol, $gateways_status, $gateways_arr)
......
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