Project

General

Profile

« Previous | Next » 

Revision b030e035

Added by Renato Botelho over 12 years ago

Allow deleting all aliases but the last one within the same subnet of a CARP IP. Fixes #2406

View differences:

usr/local/www/firewall_virtual_ip.php
108 108
		}
109 109

  
110 110
		if ($a_vip[$_GET['id']]['mode'] == "ipalias") {
111
			$found_carp = false;
112
			$found_other_alias = false;
113

  
111 114
			$vipiface = $a_vip[$_GET['id']]['interface'];
112
			foreach ($a_vip as $vip) {
113
				if ($vip['interface'] == $vipiface && $vip['mode'] == "carp")
114
					if (ip_in_subnet($vip['subnet'], gen_subnet($a_vip[$_GET['id']]['subnet'], $a_vip[$_GET['id']]['subnet_bits']) . "/" . $a_vip[$_GET['id']]['subnet_bits']))
115
						$input_errors[] = gettext("This entry cannot be deleted because it is still referenced by a CARP IP with the description") . " {$vip['descr']}.";
115
			foreach ($a_vip as $vip_id => $vip) {
116
				if ($vip_id == $_GET['id'])
117
					continue;
118

  
119
				if ($vip['interface'] == $vipiface && ip_in_subnet($vip['subnet'], gen_subnet($a_vip[$_GET['id']]['subnet'], $a_vip[$_GET['id']]['subnet_bits']) . "/" . $a_vip[$_GET['id']]['subnet_bits']))
120
					if ($vip['mode'] == "carp")
121
						$found_carp = true;
122
					else if ($vip['mode'] == "ipalias")
123
						$found_other_alias = true;
116 124
			}
125

  
126
			if ($found_carp === true && $found_other_alias === false)
127
				$input_errors[] = gettext("This entry cannot be deleted because it is still referenced by a CARP IP with the description") . " {$vip['descr']}.";
117 128
		} else if ($a_vip[$_GET['id']]['mode'] == "carp") {
118 129
			$vipiface = "{$a_vip[$_GET['id']]['interface']}_vip{$a_vip[$_GET['id']]['vhid']}";
119 130
			foreach ($a_vip as $vip) {

Also available in: Unified diff