Commit 9ed1bd79 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

getInterfaceGateways() should only return first found entry per ipprotocol

parent 013f3c7e
...@@ -78,6 +78,7 @@ class Plugin ...@@ -78,6 +78,7 @@ class Plugin
if (Util::isIpAddress($gw['gateway']) && !empty($gw['interface'])) { if (Util::isIpAddress($gw['gateway']) && !empty($gw['interface'])) {
$this->gatewayMapping[$key] = array("logic" => "route-to ( {$gw['interface']} {$gw['gateway']} )", $this->gatewayMapping[$key] = array("logic" => "route-to ( {$gw['interface']} {$gw['gateway']} )",
"interface" => $gw['interface'], "interface" => $gw['interface'],
"gateway" => $gw['gateway'],
"type" => "gateway"); "type" => "gateway");
} }
} }
...@@ -120,9 +121,18 @@ class Plugin ...@@ -120,9 +121,18 @@ class Plugin
public function getInterfaceGateways($intf) public function getInterfaceGateways($intf)
{ {
$result = array(); $result = array();
$protos_found = array();
foreach ($this->gatewayMapping as $key => $gw) { foreach ($this->gatewayMapping as $key => $gw) {
if ($gw['type'] == 'gateway' && $gw['interface'] == $intf) { if ($gw['type'] == 'gateway' && $gw['interface'] == $intf) {
if (strstr($gw['gateway'], ':')) {
$proto = 'v6';
} else {
$proto = 'v4';
}
if (!in_array($proto, $protos_found)) {
$result[] = $key; $result[] = $key;
$protos_found[] = $proto;
}
} }
} }
return $result; return $result;
......
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