From ad700f39a25ed94e03e0d1509a19b011db9f71ea Mon Sep 17 00:00:00 2001 From: Seth Mos Date: Tue, 11 Oct 2011 21:55:09 +0200 Subject: Fix static routes editing and removal for both IPv4 and IPv6. Changing a route should clean up too. Fix ticket #1892 --- usr/local/www/system_routes.php | 4 +++- usr/local/www/system_routes_edit.php | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'usr/local/www') diff --git a/usr/local/www/system_routes.php b/usr/local/www/system_routes.php index 959c940..64484a7 100755 --- a/usr/local/www/system_routes.php +++ b/usr/local/www/system_routes.php @@ -81,7 +81,9 @@ if ($_POST) { if ($_GET['act'] == "del") { if ($a_routes[$_GET['id']]) { $changedesc .= gettext("removed route to") . " " . $a_routes[$_GET['id']['route']]; - mwexec("/sbin/route delete " . escapeshellarg($a_routes[$_GET['id']]['network'])); + if(is_ipaddrv6($a_routes[$_GET['id']]['network'])) + $family = "-inet6"; + mwexec("/sbin/route delete {$family} " . escapeshellarg($a_routes[$_GET['id']]['network'])); unset($a_routes[$_GET['id']]); write_config($changedesc); header("Location: system_routes.php"); diff --git a/usr/local/www/system_routes_edit.php b/usr/local/www/system_routes_edit.php index 1e23707..cf38206 100755 --- a/usr/local/www/system_routes_edit.php +++ b/usr/local/www/system_routes_edit.php @@ -93,12 +93,12 @@ if ($_POST) { do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); if (($_POST['network'] && !is_ipaddr($_POST['network']))) { - $input_errors[] = gettext("A valid destination network must be specified."); + $input_errors[] = gettext("A valid IPv4 or IPv6 destination network must be specified."); } if (($_POST['network_subnet'] && !is_numeric($_POST['network_subnet']))) { $input_errors[] = gettext("A valid destination network bit count must be specified."); } - if ($_POST['gateway']) { + if (($_POST['gateway']) && is_ipaddr($_POST['network'])) { if (!isset($a_gateways[$_POST['gateway']])) $input_errors[] = gettext("A valid gateway must be specified."); if(!validate_address_family($_POST['network'], lookup_gateway_ip_by_name($_POST['gateway']))) @@ -144,8 +144,11 @@ if ($_POST) { if (!empty($oroute)) { $osn = explode('/', $oroute['network']); $sn = explode('/', $route['network']); - if ($oroute['network'] <> $route['network']) - $toapplylist[] = "/sbin/route delete {$oroute['network']}"; + if ($oroute['network'] <> $route['network']) { + if(is_ipaddrv6($oroute['network'])) + $family = "-inet6"; + $toapplylist[] = "/sbin/route delete {$family} {$oroute['network']}"; + } } file_put_contents("{$g['tmp_path']}/.system_routes.apply", serialize($toapplylist)); staticroutes_sort(); -- cgit v1.1