Révision 4665dbdd
Ajouté par Renato Botelho il y a plus de 9 ans
etc/inc/pfsense-utils.inc | ||
---|---|---|
2510 | 2510 |
* is_ipaddr_configured |
2511 | 2511 |
* INPUTS |
2512 | 2512 |
* IP Address to check. |
2513 |
* If ignore_if is a VIP (not carp), vip array index is passed after string _virtualip |
|
2513 | 2514 |
* RESULT |
2514 | 2515 |
* returns true if the IP Address is |
2515 | 2516 |
* configured and present on this device. |
... | ... | |
2517 | 2518 |
function is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = false, $check_subnets = false) { |
2518 | 2519 |
global $config; |
2519 | 2520 |
|
2521 |
$pos = strpos($ignore_if, '_virtualip'); |
|
2522 |
if ($pos !== false) { |
|
2523 |
$ignore_vip_id = substr($ignore_if, $pos+10); |
|
2524 |
$ignore_vip_if = substr($ignore_if, 0, $pos); |
|
2525 |
} else { |
|
2526 |
$ignore_vip_id = -1; |
|
2527 |
$ignore_vip_if = $ignore_if; |
|
2528 |
} |
|
2529 |
|
|
2520 | 2530 |
$isipv6 = is_ipaddrv6($ipaddr); |
2521 | 2531 |
|
2522 | 2532 |
if ($check_subnets) { |
... | ... | |
2543 | 2553 |
$interface_list_ips = get_configured_ip_addresses(); |
2544 | 2554 |
|
2545 | 2555 |
foreach($interface_list_ips as $if => $ilips) { |
2546 |
/* Also ignore CARP interfaces, it'll be checked below */ |
|
2547 |
if ($ignore_if == $if || strstr($ignore_if, "_vip")) |
|
2556 |
if ($ignore_if == $if) |
|
2548 | 2557 |
continue; |
2549 | 2558 |
if (strcasecmp($ipaddr, $ilips) == 0) |
2550 | 2559 |
return true; |
... | ... | |
2553 | 2562 |
|
2554 | 2563 |
$interface_list_vips = get_configured_vips_list(true); |
2555 | 2564 |
foreach ($interface_list_vips as $id => $vip) { |
2556 |
if ($ignore_if == $vip['if']) |
|
2565 |
/* Skip CARP interfaces here since they were already checked above */ |
|
2566 |
if ($id == $ignore_vip_id || (strstr($ignore_if, '_vip') && $ignore_vip_if == $vip['if'])) |
|
2557 | 2567 |
continue; |
2558 | 2568 |
if (strcasecmp($ipaddr, $vip['ipaddr']) == 0) |
2559 | 2569 |
return true; |
usr/local/www/firewall_virtual_ip_edit.php | ||
---|---|---|
119 | 119 |
if (isset($id) && isset($a_vip[$id])) { |
120 | 120 |
$ignore_if = $a_vip[$id]['interface']; |
121 | 121 |
$ignore_mode = $a_vip[$id]['mode']; |
122 |
if (isset($a_vip[$id]['vhid'])) |
|
123 |
$ignore_vhid = $a_vip[$id]['vhid']; |
|
122 | 124 |
} else { |
123 | 125 |
$ignore_if = $_POST['interface']; |
124 | 126 |
$ignore_mode = $_POST['mode']; |
125 | 127 |
} |
126 | 128 |
|
129 |
if (!isset($ignore_vhid)) |
|
130 |
$ignore_vhid = $_POST['vhid']; |
|
131 |
|
|
127 | 132 |
if ($ignore_mode == 'carp') |
128 |
$ignore_if .= "_vip{$id}"; |
|
133 |
$ignore_if .= "_vip{$ignore_vhid}"; |
|
134 |
else |
|
135 |
$ignore_if .= "_virtualip{$id}"; |
|
129 | 136 |
|
130 | 137 |
if (is_ipaddr_configured($_POST['subnet'], $ignore_if)) |
131 | 138 |
$input_errors[] = gettext("This IP address is being used by another interface or VIP."); |
Formats disponibles : Unified diff
Make proper check if IP address is configured on another interfaces and ignore current one. It fixes #3807