From 62a4abc92cd31983d4b1c09eb95d28e001d9869d Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 31 Aug 2010 12:47:58 +0000 Subject: [PATCH] Ticket #543. Do not allow to change an interface already configured to a type none if it is referenced by VIPs and also do not allow VIPs to be configured on an interface with type none. Maybe the latest should be relaxed to only disallow this for ipaliases?! --- usr/local/www/firewall_virtual_ip_edit.php | 5 ++++- usr/local/www/interfaces.php | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/usr/local/www/firewall_virtual_ip_edit.php b/usr/local/www/firewall_virtual_ip_edit.php index 895143522a..214d127c8e 100755 --- a/usr/local/www/firewall_virtual_ip_edit.php +++ b/usr/local/www/firewall_virtual_ip_edit.php @@ -109,9 +109,12 @@ if ($_POST) { $input_errors[] = gettext("A valid IP address must be specified."); $natiflist = get_configured_interface_with_descr(); - foreach ($natiflist as $natif => $natdescr) + foreach ($natiflist as $natif => $natdescr) { + if (empty($config['interfaces'][$natif]['ipaddr'])) + $input_errors[] = gettext("The interface choosen for the VIP has no ip configured so it cannot be used as a parent for the VIP."); if ($_POST['subnet'] == get_interface_ip($natif)) $input_errors[] = sprintf(gettext("The %s IP address may not be used in a virtual entry."),$natdescr); + } if($_POST['subnet_bits'] == "32" and $_POST['type'] == "carp") $input_errors[] = gettext("The /32 subnet mask is invalid for CARP IPs."); diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index a451954c34..ac75ddae00 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -375,9 +375,15 @@ if ($_POST) { $reqdfieldsn = array(gettext("IP address"),gettext("Subnet bit count"),gettext("Gateway")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); case "none": + if(is_array($config['virtualip']['vip'])) { + foreach ($config['virtualip']['vip'] as $vip) { + if ($vip['interface'] == $if) + $input_errors[] = gettext("This interface is referenced by VIPs please delete those before setting the interface to 'none' configuration."); + } + } case "dhcp": if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) - $input_errors[] = "You have to reassign the interface to be able to configure as {$_POST['type']}."; + $input_errors[] = gettext("You have to reassign the interface to be able to configure as {$_POST['type']}."); break; case "ppp": $reqdfields = explode(" ", "port phone");