summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/etc/inc/interfaces.inc16
-rw-r--r--src/etc/inc/services.inc117
2 files changed, 2 insertions, 131 deletions
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc
index 64e712e..5b375ec 100644
--- a/src/etc/inc/interfaces.inc
+++ b/src/etc/inc/interfaces.inc
@@ -5716,14 +5716,6 @@ function get_possible_traffic_source_addresses($include_ipv6_link_local=false) {
return $sourceips;
}
-function get_interface_ip_family($interface = "wan", $family = 'inet') {
- if ($family == 'inet') {
- return get_interface_ip($interface = "wan");
- } else {
- return get_interface_ipv6($interface = "wan");
- }
-}
-
function get_interface_ip($interface = "wan") {
if (substr($interface, 0, 4) == '_vip') {
@@ -5843,14 +5835,6 @@ function get_interface_linklocal($interface = "wan") {
}
}
-function get_interface_subnet_family($interface = "wan", $family = 'inet') {
- if ($family == 'inet') {
- return get_interface_subnet($interface = "wan");
- } else {
- return get_interface_subnetv6($interface = "wan");
- }
-}
-
function get_interface_subnet($interface = "wan") {
if (substr($interface, 0, 4) == '_vip') {
diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc
index d90f0fe..f27d2e8 100644
--- a/src/etc/inc/services.inc
+++ b/src/etc/inc/services.inc
@@ -1663,119 +1663,6 @@ EOD;
return 0;
}
-function get_realinterface_for_destination($destip) {
- /*
- * Returns the realinterface that traffic will be send out on for the destination $destip
- * This is is checked against the items below (first match applies), final resort the default gateway.
- * 1-interface subnets (todo VIPs?)
- * 2-static routes configured in pfSense
- * 3-current routing table
- * 4-the default gateway
- *
- * DESIGN QUESTION, is it right to use this 'first match' ??
- * as routing table could contain a smaller subnet that also matches which could point to a different interface..
- * should the routing table always be used skipping options 1 and 2
- *
- */
- global $config;
-
- if (is_ipaddrv4($destip)) {
- $family = 'inet';
- } else {
- $family = 'inet6';
- }
-
- $iflist = get_configured_interface_list();
- foreach ($iflist as $ifname) {
- $subnet = get_interface_ip_family($ifname, $family);
- if (!is_ipaddr($subnet)) {
- continue;
- }
- $subnet .= "/" . get_interface_subnet_family($ifname, $family);
- if (ip_in_subnet($destip, $subnet)) {
- $destif = get_real_interface($ifname);
- break;
- }
- }
- if (!isset($destif)) {
- // For each enabled static route
- foreach (get_staticroutes(false, false, true) as $rtent) {
- if (ip_in_subnet($destip, $rtent['network'])) {
- $a_gateways = return_gateways_array(true);
- $destif = $a_gateways[$rtent['gateway']]['interface'];
- break;
- }
- }
- }
-
- if (!isset($destif)) {
- $smallestsubnet = -1;
- /* Create a array from the existing route table */
- exec("/usr/bin/netstat -rnWf {$family}", $route_str);
- array_shift($route_str);
- array_shift($route_str);
- array_shift($route_str);
- array_shift($route_str);
- foreach ($route_str as $routeline) {
- $items = preg_split("/[ ]+/i", $routeline);
- $subnet = $items[0];
-
- switch ($family) {
- case 'inet':
- if ($subnet == 'default') {
- $subnet = "0.0.0.0/0";
- } else if (!is_subnetv4($subnet)) {
- if (is_ipaddrv4($subnet)) {
- $subnet .= "/32";
- } else {
- continue;
- }
- }
- break;
- case 'inet6':
- if ($subnet == 'default') {
- $subnet = "::/0";
- } else
- if (!is_subnetv6($subnet)) {
- if (is_ipaddrv6($subnet)) {
- $subnet .= "/128";
- } else {
- continue;
- }
- }
- break;
- default:
- continue;
- }
- if (ip_in_subnet($destip, $subnet)) {
- list($ip, $mask) = explode('/', $subnet);
- if ($mask > $smallestsubnet) {
- $smallestsubnet = $mask;
- $destif = trim($items[5]);
- }
- }
- }
- }
-
- if (!isset($destif)) {
- if (is_array($config['gateways']['gateway_item'])) {
- foreach ($config['gateways']['gateway_item'] as $gateway) {
- if ($gateway['ipprotocol'] != $family) {
- continue;
- }
- if (isset($gateway['defaultgw'])) {
- $destif = get_real_interface($gateway['interface']);
- break;
- }
- }
- } else {
- $destif = get_real_interface("wan");
- }
- }
-
- return $destif;
-}
-
function services_dhcrelay_configure() {
global $config, $g;
@@ -1825,7 +1712,7 @@ function services_dhcrelay_configure() {
}
foreach ($srvips as $srcidx => $srvip) {
- $destif = get_realinterface_for_destination($srvip);
+ $destif = guess_interface_from_ip($srvip);
if (!empty($destif)) {
$dhcrelayifs[] = $destif;
}
@@ -1897,7 +1784,7 @@ function services_dhcrelay6_configure() {
$srvips = explode(",", $dhcrelaycfg['server']);
$srvifaces = array();
foreach ($srvips as $srcidx => $srvip) {
- $destif = get_realinterface_for_destination($srvip);
+ $destif = guess_interface_from_ip($srvip);
if (!empty($destif)) {
$srvifaces[] = "{$srvip}%{$destif}";
}
OpenPOWER on IntegriCloud