summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Buechler <cmb@pfsense.org>2015-07-30 01:27:41 -0500
committerChris Buechler <cmb@pfsense.org>2015-07-30 01:27:41 -0500
commit97613114b5b74c334609d7fcd79c94741b111793 (patch)
tree46fdaba1f2e14c24c007e3b4adf2bbf59cee50d9
parentfc3e3bdbe0e85005a528801bedb827a22d3c3a69 (diff)
downloadpfsense-97613114b5b74c334609d7fcd79c94741b111793.zip
pfsense-97613114b5b74c334609d7fcd79c94741b111793.tar.gz
remove the destination server's interface(s) from dhcrelay. Ticket #4908
-rw-r--r--etc/inc/services.inc138
1 files changed, 6 insertions, 132 deletions
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index 73c2411..ffc131c 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -1489,73 +1489,6 @@ function services_dhcrelay_configure() {
$dhcrelayifs[] = get_real_interface($dhcrelayif);
}
- /*
- * In order for the relay to work, it needs to be active
- * on the interface in which the destination server sits.
- */
- $srvips = explode(",", $dhcrelaycfg['server']);
- foreach ($srvips as $srcidx => $srvip) {
- unset($destif);
- foreach ($iflist as $ifname) {
- $subnet = get_interface_ip($ifname);
- if (!is_ipaddr($subnet))
- continue;
- $subnet .= "/" . get_interface_subnet($ifname);
- if (ip_in_subnet($srvip, $subnet)) {
- $destif = get_real_interface($ifname);
- break;
- }
- }
- if (!isset($destif)) {
- foreach (get_staticroutes() as $rtent) {
- if (ip_in_subnet($srvip, $rtent['network'])) {
- $a_gateways = return_gateways_array(true);
- $destif = $a_gateways[$rtent['gateway']]['interface'];
- break;
- }
- }
- }
-
- if (!isset($destif)) {
- /* Create a array from the existing route table */
- exec("/usr/bin/netstat -rnWf inet", $route_str);
- array_shift($route_str);
- array_shift($route_str);
- array_shift($route_str);
- array_shift($route_str);
- $route_arr = array();
- foreach($route_str as $routeline) {
- $items = preg_split("/[ ]+/i", $routeline);
- if (is_subnetv4($items[0])) {
- $subnet = $items[0];
- } elseif (is_ipaddrv4($items[0])) {
- $subnet = "{$items[0]}/32";
- } else {
- // Not a subnet or IP address, skip to the next line.
- continue;
- }
- if (ip_in_subnet($srvip, $subnet)) {
- $destif = trim($items[6]);
- break;
- }
- }
- }
-
- if (!isset($destif)) {
- if (is_array($config['gateways']['gateway_item'])) {
- foreach ($config['gateways']['gateway_item'] as $gateway) {
- if (isset($gateway['defaultgw'])) {
- $destif = get_real_interface($gateway['interface']);
- break;
- }
- }
- } else
- $destif = get_real_interface("wan");
- }
-
- if (!empty($destif))
- $dhcrelayifs[] = $destif;
- }
$dhcrelayifs = array_unique($dhcrelayifs);
/* fire up dhcrelay */
@@ -1569,6 +1502,11 @@ function services_dhcrelay_configure() {
if (isset($dhcrelaycfg['agentoption']))
$cmd .= " -a -m replace";
+ $srvips = explode(",", $dhcrelaycfg['server']);
+ if (!is_array($srvips)) {
+ log_error("No DHCP relay destination IP has been configured!");
+ return;
+ }
$cmd .= " " . implode(" ", $srvips);
mwexec($cmd);
unset($cmd);
@@ -1611,76 +1549,12 @@ function services_dhcrelay6_configure() {
$dhcrelayifs[] = get_real_interface($dhcrelayif);
}
$dhcrelayifs = array_unique($dhcrelayifs);
-
- /*
- * In order for the relay to work, it needs to be active
- * on the interface in which the destination server sits.
- */
$srvips = explode(",", $dhcrelaycfg['server']);
if (!is_array($srvips)) {
- log_error("No destination ip has been configured!");
+ log_error("No destination IP has been configured!");
return;
}
- $srvifaces = array();
- foreach ($srvips as $srcidx => $srvip) {
- unset($destif);
- foreach ($iflist as $ifname) {
- $subnet = get_interface_ipv6($ifname);
- if (!is_ipaddrv6($subnet))
- continue;
- $subnet .= "/" . get_interface_subnetv6($ifname);
- if (ip_in_subnet($srvip, $subnet)) {
- $destif = get_real_interface($ifname);
- break;
- }
- }
- if (!isset($destif)) {
- if (is_array($config['staticroutes']['route'])) {
- foreach ($config['staticroutes']['route'] as $rtent) {
- if (ip_in_subnet($srvip, $rtent['network'])) {
- $a_gateways = return_gateways_array(true);
- $destif = $a_gateways[$rtent['gateway']]['interface'];
- break;
- }
- }
- }
- }
-
- if (!isset($destif)) {
- /* Create a array from the existing route table */
- exec("/usr/bin/netstat -rnWf inet6", $route_str);
- array_shift($route_str);
- array_shift($route_str);
- array_shift($route_str);
- array_shift($route_str);
- $route_arr = array();
- foreach($route_str as $routeline) {
- $items = preg_split("/[ ]+/i", $routeline);
- if (ip_in_subnet($srvip, $items[0])) {
- $destif = trim($items[6]);
- break;
- }
- }
- }
-
- if (!isset($destif)) {
- if (is_array($config['gateways']['gateway_item'])) {
- foreach ($config['gateways']['gateway_item'] as $gateway) {
- if (isset($gateway['defaultgw'])) {
- $destif = get_real_interface($gateway['interface']);
- break;
- }
- }
- } else
- $destif = get_real_interface("wan");
- }
-
- if (!empty($destif)) {
- $srvifaces[] = "{$srvip}%{$destif}";
- }
- }
-
/* fire up dhcrelay */
if (empty($dhcrelayifs) || empty($srvifaces) ) {
log_error("No suitable interface found for running dhcrelay -6!");
OpenPOWER on IntegriCloud