Commit 081415d4 authored by Franco Fichtner's avatar Franco Fichtner

rc: remove IP checks for PPTP and L2TP servers

The console would refuse to assign an IP that was used by the
PPTP or L2TP server (surprisingly not PPPoE).  This rule changed
during the MPD4 -> MDP5 migration, so remove that code.  Also,
the subnet check was never executed, good time to remove it as
well.
parent 7985db12
...@@ -5316,43 +5316,24 @@ function load_mac_manufacturer_table() { ...@@ -5316,43 +5316,24 @@ function load_mac_manufacturer_table() {
* returns true if the IP Address is * returns true if the IP Address is
* configured and present on this device. * configured and present on this device.
*/ */
function is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = false, $check_subnets = false) { function is_ipaddr_configured($ipaddr, $ignore_if = '')
{
global $config; global $config;
$isipv6 = is_ipaddrv6($ipaddr); $isipv6 = is_ipaddrv6($ipaddr);
if ($check_subnets) { if ($isipv6 === true) {
$iflist = get_configured_interface_list(); $interface_list_ips = get_configured_ipv6_addresses();
foreach ($iflist as $if => $ifname) {
if ($ignore_if == $if) {
continue;
}
if ($isipv6 === true) {
$bitmask = get_interface_subnetv6($if);
$subnet = gen_subnetv6(get_interface_ipv6($if), $bitmask);
} else {
$bitmask = get_interface_subnet($if);
$subnet = gen_subnet(get_interface_ip($if), $bitmask);
}
if (ip_in_subnet($ipaddr, $subnet . '/' . $bitmask)) {
return true;
}
}
} else { } else {
if ($isipv6 === true) { $interface_list_ips = get_configured_ip_addresses();
$interface_list_ips = get_configured_ipv6_addresses(); }
} else {
$interface_list_ips = get_configured_ip_addresses(); foreach($interface_list_ips as $if => $ilips) {
/* Also ignore CARP interfaces, it'll be checked below */
if ($ignore_if == $if || strstr($ignore_if, "_vip")) {
continue;
} }
foreach($interface_list_ips as $if => $ilips) { if (strcasecmp($ipaddr, $ilips) == 0) {
/* Also ignore CARP interfaces, it'll be checked below */ return true;
if ($ignore_if == $if || strstr($ignore_if, "_vip")) {
continue;
}
if (strcasecmp($ipaddr, $ilips) == 0) {
return true;
}
} }
} }
...@@ -5366,16 +5347,6 @@ function is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = false, ...@@ -5366,16 +5347,6 @@ function is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = false,
} }
} }
if ($check_localip) {
if (is_array($config['pptpd']) && !empty($config['pptpd']['localip']) && (strcasecmp($ipaddr, $config['pptpd']['localip']) == 0)) {
return true;
}
if (!is_array($config['l2tp']) && !empty($config['l2tp']['localip']) && (strcasecmp($ipaddr, $config['l2tp']['localip']) == 0)) {
return true;
}
}
return false; return false;
} }
......
...@@ -293,7 +293,7 @@ function console_configure_ip_address($version) ...@@ -293,7 +293,7 @@ function console_configure_ip_address($version)
) . "\n> "; ) . "\n> ";
$intip = chop(fgets($fp)); $intip = chop(fgets($fp));
$is_ipaddr = ($version === 6) ? is_ipaddrv6($intip) : is_ipaddrv4($intip); $is_ipaddr = ($version === 6) ? is_ipaddrv6($intip) : is_ipaddrv4($intip);
if ($is_ipaddr && is_ipaddr_configured($intip, $interface, true)) { if ($is_ipaddr && is_ipaddr_configured($intip, $interface)) {
$ip_conflict = true; $ip_conflict = true;
echo gettext("This IP address conflicts with another interface or a VIP") . "\n"; echo gettext("This IP address conflicts with another interface or a VIP") . "\n";
} else { } else {
......
...@@ -710,7 +710,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -710,7 +710,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!is_ipaddrv4($pconfig['ipaddr'])) { if (!is_ipaddrv4($pconfig['ipaddr'])) {
$input_errors[] = gettext("A valid IPv4 address must be specified."); $input_errors[] = gettext("A valid IPv4 address must be specified.");
} else { } else {
if (is_ipaddr_configured($pconfig['ipaddr'], $if, true)) { if (is_ipaddr_configured($pconfig['ipaddr'], $if)) {
$input_errors[] = gettext("This IPv4 address is being used by another interface or VIP."); $input_errors[] = gettext("This IPv4 address is being used by another interface or VIP.");
} }
/* Do not accept network or broadcast address, except if subnet is 31 or 32 */ /* Do not accept network or broadcast address, except if subnet is 31 or 32 */
...@@ -736,7 +736,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -736,7 +736,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!is_ipaddrv6($pconfig['ipaddrv6'])) { if (!is_ipaddrv6($pconfig['ipaddrv6'])) {
$input_errors[] = gettext("A valid IPv6 address must be specified."); $input_errors[] = gettext("A valid IPv6 address must be specified.");
} else { } else {
if (is_ipaddr_configured($pconfig['ipaddrv6'], $if, true)) { if (is_ipaddr_configured($pconfig['ipaddrv6'], $if)) {
$input_errors[] = gettext("This IPv6 address is being used by another interface or VIP."); $input_errors[] = gettext("This IPv6 address is being used by another interface or VIP.");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment