From 25c3f30c612dba4c7ee6c15eed3f9feee28d5603 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Mon, 15 Apr 2013 12:12:07 -0300 Subject: Be able to delete static routes that uses aliases. Fixes #2948 --- usr/local/www/system_routes.php | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'usr/local/www/system_routes.php') diff --git a/usr/local/www/system_routes.php b/usr/local/www/system_routes.php index b331dbb..b5dd849 100755 --- a/usr/local/www/system_routes.php +++ b/usr/local/www/system_routes.php @@ -80,18 +80,33 @@ if ($_POST) { if ($_GET['act'] == "del") { if ($a_routes[$_GET['id']]) { - $changedesc .= gettext("removed route to") . " " . $a_routes[$_GET['id']['route']]; - list($ip, $mask) = explode("/", $a_routes[$_GET['id']]['network']); - if (is_ipaddr($ip)) { - $family = ""; - if(is_ipaddrv6($ip)) - $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"); - exit; + $changedesc .= gettext("removed route to") . " " . $a_routes[$_GET['id']]['route']; + + $targets = array(); + if (is_alias($a_routes[$_GET['id']]['network'])) { + foreach (filter_expand_alias_array($a_routes[$_GET['id']]['network']) as $tgt) { + if (is_ipaddrv4($tgt)) + $tgt .= "/32"; + else if (is_ipaddrv6($tgt)) + $tgt .= "/128"; + if (!is_subnet($tgt)) + continue; + $targets[] = $tgt; + } + } else { + $targets[] = $a_routes[$_GET['id']]['network']; } + + foreach ($targets as $tgt) { + $family = (is_subnetv6($tgt) ? "-inet6" : "-inet"); + mwexec("/sbin/route delete {$family} " . escapeshellarg($tgt)); + } + + unset($a_routes[$_GET['id']]); + unset($targets); + write_config($changedesc); + header("Location: system_routes.php"); + exit; } } -- cgit v1.1