diff options
author | Ermal <eri@pfsense.org> | 2013-02-09 09:26:33 +0000 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2013-02-09 09:26:33 +0000 |
commit | 8be135cd114fbc9294ec9dafed2125d0e553956c (patch) | |
tree | bb5eaeedf67b5b944fd277930180b53f34ffd230 | |
parent | aeaf0a67adca3e64e1bd889974368319b0d6d9c9 (diff) | |
download | pfsense-8be135cd114fbc9294ec9dafed2125d0e553956c.zip pfsense-8be135cd114fbc9294ec9dafed2125d0e553956c.tar.gz |
Correct system_routing_configure to do the right thing and guess the address family for the routing table correctly. While here cleanup some other code and leave a comment that disabled routing entries probably should not be dealt in here!
-rw-r--r-- | etc/inc/system.inc | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc index e5c6c93..295c6eb 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -373,9 +373,11 @@ function system_routing_configure($interface = "") { if (is_array($config['gateways']['gateway_item'])) { mwexec("/bin/rm {$g['tmp_path']}/*_defaultgw", true); foreach ($config['gateways']['gateway_item'] as $gateway) { - if (isset($gateway['defaultgw']) && ((is_ipaddrv4($gateway['gateway'])) || ($gateway['gateway'] == "dynamic"))) { + if (isset($gateway['defaultgw']) && (is_ipaddrv4($gateway['gateway']) || $gateway['gateway'] == "dynamic")) { + if ($gateway['ipprotocol'] == "inet6") + continue; if(strstr($gateway['gateway'], ":")) - break; + continue; if ($gateway['gateway'] == "dynamic") $gateway['gateway'] = get_interface_gateway($gateway['interface']); $gatewayip = $gateway['gateway']; @@ -391,6 +393,8 @@ function system_routing_configure($interface = "") { } foreach ($config['gateways']['gateway_item'] as $gateway) { if (isset($gateway['defaultgw']) && ((is_ipaddrv6($gateway['gateway'])) || ($gateway['gateway'] == "dynamic6"))) { + if ($gateway['ipprotocol'] != "inet6") + continue; if ($gateway['gateway'] == "dynamic6") $gateway['gateway'] = get_interface_gateway_v6($gateway['interface']); $gatewayipv6 = $gateway['gateway']; @@ -440,6 +444,7 @@ function system_routing_configure($interface = "") { if (!empty($interface) && $interface != $interfacegwv6) ; else if (($interfacegwv6 <> "bgpd") && (is_ipaddrv6($gatewayipv6))) { + $ifscope = ""; if(preg_match("/fe80::/i", $gatewayipv6)) $ifscope = "%{$defaultifv6}"; log_error("ROUTING: setting IPv6 default route to {$gatewayipv6}{$ifscope}"); @@ -461,6 +466,7 @@ function system_routing_configure($interface = "") { if (!empty($interface) && $interface != $gateway['friendlyiface']) continue; + /* XXX: This is a bit dangerous in case of routing daemons!? */ if(isset($rtent['disabled'])) { mwexec("/sbin/route delete " . escapeshellarg($rtent['network']), true); continue; @@ -469,21 +475,24 @@ function system_routing_configure($interface = "") { $gatewayip = $gateway['gateway']; $interfacegw = $gateway['interface']; - if(is_ipaddrv6($gatewayip)) { - $inetfamily = "-inet6"; - } else { - $inetfamily = "-inet"; - } $blackhole = ""; - if(preg_match("/^Null/i", $rtent['gateway'])) + if (!strcasecmp("Null", substr($rtent['gateway'], 0, 3))) $blackhole = "-blackhole"; - if (is_ipaddr($gatewayip) && ((is_ipaddrv6($gatewayip) && is_subnetv6($rtent['network'])) || (is_ipaddrv4($gatewayip) && is_subnetv4($rtent['network'])))) { - mwexec("/sbin/route change {$inetfamily} {$blackhole} " . escapeshellarg($rtent['network']) . - " " . escapeshellarg($gatewayip)); - } else if (!empty($interfacegw) && ((is_ipaddrv6($gatewayip) && is_subnetv6($rtent['network'])) || (is_ipaddrv4($gatewayip) && is_subnetv4($rtent['network'])))) { - mwexec("/sbin/route change {$inetfamily} {$blackhole} " . escapeshellarg($rtent['network']) . - " -iface " . escapeshellarg($interfacegw)); + if (is_subnetv6($rtent['network'])) { + if (is_ipaddrv6($gatewayip)) + mwexec("/sbin/route change -inet6 {$blackhole} " . escapeshellarg($rtent['network']) . + " " . escapeshellarg($gatewayip)); + else if (!empty($interfacegw)) + mwexec("/sbin/route change -inet6 {$blackhole} " . escapeshellarg($rtent['network']) . + " -iface " . escapeshellarg($interfacegw)); + } else if (is_subnetv4($rtent['network'])) { + if (is_ipaddrv4($gatewayip)) + mwexec("/sbin/route change -inet {$blackhole} " . escapeshellarg($rtent['network']) . + " " . escapeshellarg($gatewayip)); + else if (!empty($interfacegw)) + mwexec("/sbin/route change -inet {$blackhole} " . escapeshellarg($rtent['network']) . + " -iface " . escapeshellarg($interfacegw)); } } } |