diff options
author | Ermal <eri@pfsense.org> | 2013-03-05 11:49:43 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2013-03-05 11:49:43 +0000 |
commit | bcab1b076d4a73bf2ffdb3aa527fe0157185a6cb (patch) | |
tree | c38084f8088f2ca657e1765fa3705326dc86c2d4 | |
parent | 46209e0b790d840cb53f443d0dd8d9bb7b9ab479 (diff) | |
download | pfsense-bcab1b076d4a73bf2ffdb3aa527fe0157185a6cb.zip pfsense-bcab1b076d4a73bf2ffdb3aa527fe0157185a6cb.tar.gz |
Make get_static routes behave correctly with aliases
-rw-r--r-- | etc/inc/util.inc | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index a85e346..0cce818 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -1825,26 +1825,29 @@ function explode_assoc($delimiter, $string) { function get_staticroutes($returnsubnetsonly = false) { global $config; - require_once('filter.inc'); - $allstaticroutes = array(); - $allsubnets = array(); /* Bail if there are no routes, but return an array always so callers don't have to check. */ if (!is_array($config['staticroutes']['route'])) return array(); + $allstaticroutes = array(); + $allsubnets = array(); /* Loop through routes and expand aliases as we find them. */ foreach ($config['staticroutes']['route'] as $route) { if (is_alias($route['network'])) { + if (!function_exists('filter_expand_alias_array')) + require_once('filter.inc'); $subnets = filter_expand_alias_array($route['network']); foreach ($subnets as $net) { - if (is_ipaddrv4($net)) - $net .= "/32"; - if (is_ipaddrv6($net) && !is_subnetv6($net)) - $net .= "/128"; - /* This must be a hostname, we can't use it. */ - if (!is_subnet($net)) - continue; + if (!is_subnet($net)) { + if (is_ipaddrv4($net)) + $net .= "/32"; + else if (is_ipaddrv6($net)) + $net .= "/128"; + /* This must be a hostname, we can't use it. */ + else + continue; + } $temproute = $route; $temproute['network'] = $net; $allstaticroutes[] = $temproute; @@ -1855,11 +1858,10 @@ function get_staticroutes($returnsubnetsonly = false) { $allsubnets[] = $route['network']; } } - if ($returnsubnetsonly) { + if ($returnsubnetsonly) return $allsubnets; - } else { + else return $allstaticroutes; - } } /****f* util/get_alias_list |