Properly detect if an ip is already configured for VIP. Remove useless checks for carp

This commit is contained in:
Ermal 2013-12-07 23:07:24 +00:00
parent 92603e27d9
commit a1007e19cf

View File

@ -1,3 +1,4 @@
s_ipaddr_configured
<?php
/* $Id$ */
/*
@ -113,7 +114,7 @@ if ($_POST) {
if ($_POST['subnet']) {
if (!is_ipaddr($_POST['subnet']))
$input_errors[] = gettext("A valid IP address must be specified.");
else if (is_ipaddr_configured($_POST['subnet'], "vip_" . $id))
else if (is_ipaddr_configured($_POST['subnet'], "{$_POST['interface']}_vip{$id}"))
$input_errors[] = gettext("This IP address is being used by another interface or VIP.");
}
@ -123,15 +124,6 @@ if ($_POST) {
$input_errors[] = gettext("The interface chosen for the VIP has no IPv4 or IPv6 address configured so it cannot be used as a parent for the VIP.");
}
if(is_ipaddrv4($_POST['subnet'])) {
if(($_POST['subnet_bits'] == "31" or $_POST['subnet_bits'] == "32") and $_POST['mode'] == "carp")
$input_errors[] = gettext("The /31 and /32 subnet mask are invalid for CARP IPs.");
}
if(is_ipaddrv6($_POST['subnet'])) {
if(($_POST['subnet_bits'] == "127" or $_POST['subnet_bits'] == "128") and $_POST['mode'] == "carp")
$input_errors[] = gettext("The /127 and /128 subnet mask are invalid for CARP IPs.");
}
/* ipalias and carp should not use network or broadcast address */
if ($_POST['mode'] == "ipalias" || $_POST['mode'] == "carp") {
if (is_ipaddrv4($_POST['subnet']) && $_POST['subnet_bits'] != "32") {