diff options
author | Ermal <eri@pfsense.org> | 2010-08-19 18:32:51 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2010-08-19 18:32:51 +0000 |
commit | 2f06cc3f6c9a15d7295323283703c418227c6b1b (patch) | |
tree | c106e19dc3434d5ad2a8c4a679eb67862bdddd71 /etc | |
parent | 2445e8515882368b5d8335409c50abeb9653b1e1 (diff) | |
download | pfsense-2f06cc3f6c9a15d7295323283703c418227c6b1b.zip pfsense-2f06cc3f6c9a15d7295323283703c418227c6b1b.tar.gz |
Make dhcrelay GUI be simple and easy to use by collapsing the interface tabs to a multiselect control. Remove proxydhcp option because it is broken and is not trivial to make it usable(if user request for it a reconsideration will be made). Allow multiple server ips on the server input box separated by commas. Also on the interface list do not show interfaces without an ip because dhcrelay will not be happy with them. Upgrade code is also included in this commit.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/interfaces.inc | 2 | ||||
-rw-r--r-- | etc/inc/services.inc | 131 | ||||
-rw-r--r-- | etc/inc/upgrade_config.inc | 21 |
3 files changed, 86 insertions, 68 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 5d5075a..057c684 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -2854,7 +2854,7 @@ function guess_interface_from_ip($ipaddress) { return false; } /* create a route table we can search */ - exec("netstat -rnW", $output, $ret); + exec("netstat -rnWf inet", $output, $ret); foreach($output as $line) { if(preg_match("/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\/[0-9]+[ ]+link[#]/", $line)) { $fields = preg_split("/[ ]+/", $line); diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 877368a..86bb78c 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -477,20 +477,10 @@ function services_dhcrelay_configure() { /* kill any running dhcrelay */ killbypid("{$g['varrun_path']}/dhcrelay.pid"); - $dhcrelaycfg = $config['dhcrelay']; + $dhcrelaycfg =& $config['dhcrelay']; /* DHCPRelay enabled on any interfaces? */ - $dhcrelayenable = false; - if(is_array($dhcrelaycfg)) { - foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) { - if (isset($dhcrelayifconf['enable']) || - (isset($config['interfaces'][$dhcrelayif]['enable']) && - (!link_interface_to_bridge($dhcrelayif)))) - $dhcrelayenable = true; - } - } - - if (!$dhcrelayenable) + if (!isset($dhcrelaycfg['enable'])) return 0; if ($g['booting']) @@ -498,72 +488,79 @@ function services_dhcrelay_configure() { else sleep(1); - $dhcrelayifs = array(); - foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) { - - $ifcfg = $config['interfaces'][$dhcrelayif]; + $iflist = get_configured_interface_list(); - if (!isset($dhcrelayifconf['enable']) || - (!isset($ifcfg['enable']) || - link_interface_to_bridge($dhcrelayif))) + $dhcifaces = explode(",", $dhcrelaycfg['interface']); + foreach ($dhcifaces as $dhcrelayif) { + if (!isset($iflist[$dhcrelayif]) || + link_interface_to_bridge($dhcrelayif)) continue; - $dhcrelayifs[] = get_real_interface($dhcrelayif); + if (is_ipaddr(get_interface_ip($dhcrelayif))) + $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 */ - $iflist = get_configured_interface_list(); - foreach ($iflist as $ifname) { - $subnet = get_interface_ip($ifname) . "/" . get_interface_subnet($ifname); - if (ip_in_subnet($dhcrelaycfg['server'],$subnet)) { - $destif = get_real_interface($ifname); - break; + /* + * 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)) { - if (is_array($config['staticroutes']['route'])) { - foreach ($config['staticroutes']['route'] as $rtent) { - if (ip_in_subnet($dhcrelaycfg['server'], $rtent['network'])) { - $a_gateways = return_gateways_array(true); - $destif = $a_gateways[$rtent['gateway']]['interface']; - 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 -rnf 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 (ip_in_subnet($$dhcrelaycfg['server'], $items[0])) { - $destif = trim($items[2]); - break; - } - } - } - - if (!isset($destif)) { - if (is_array($config['gateways']['gateway_item'])) { - foreach ($config['gateways']['gateway_item'] as $gateway) { - if (isset($gateway['defaultgw'])) { - $a_gateways = return_gateways_array(true); - $destif = $a_gateways[$rtent['gateway']]['interface']; + 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 (ip_in_subnet($srvip, $items[0])) { + $destif = trim($items[2]); break; - } - } - } else - $destif = get_real_interface("wan"); - } + } + } + } + + if (!isset($destif)) { + if (is_array($config['gateways']['gateway_item'])) { + foreach ($config['gateways']['gateway_item'] as $gateway) { + if (isset($gateway['defaultgw'])) { + $a_gateways = return_gateways_array(true); + $destif = $a_gateways[$rtent['gateway']]['interface']; + break; + } + } + } else + $destif = get_real_interface("wan"); + } - $dhcrelayifs[] = $destif; + $dhcrelayifs[] = $destif; + } $dhcrelayifs = array_unique($dhcrelayifs); /* fire up dhcrelay */ @@ -572,7 +569,7 @@ function services_dhcrelay_configure() { if (isset($dhcrelaycfg['agentoption'])) $cmd .= " -a -m replace"; - $cmd .= " {$dhcrelaycfg['server']}"; + $cmd .= " " . implode(" ", $srvips); mwexec($cmd); return 0; diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc index 574be98..24f56f7 100644 --- a/etc/inc/upgrade_config.inc +++ b/etc/inc/upgrade_config.inc @@ -2069,4 +2069,25 @@ function upgrade_064_to_065() { $config['system']['disablelargereceiveoffloading'] = true; } +function upgrade_065_to_066() { + global $config; + + $dhcrelaycfg =& $config['dhcrelay']; + + if (is_array($dhcrelaycfg)) { + $dhcrelayifs = array(); + $foundifs = false; + /* DHCPRelay enabled on any interfaces? */ + foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) { + if (isset($dhcrelayifconf['enable'])) { + $dhcrelayifs[] = $dhcrelayif; + unset($dhcrelaycfg['dhcrelayif']); + $foundifs = true; + } + } + if ($foundifs == true) + $dhcrelaycfg['interface'] = implode(",", $dhcrelayifs); + } +} + ?> |