Project

General

Profile

« Previous | Next » 

Revision 7de83e03

Added by Ermal LUÇI about 15 years ago

Simplify/optimize code for carp [re]configuration. This is possibly related to Ticket #601. Also this speedups vip creation on large number of interfaces.

View differences:

etc/inc/interfaces.inc
1616 1616
		return;
1617 1617
	}
1618 1618

  
1619
	/* ensure CARP IP really exists prior to loading up */
1620
	/* XXX: this can be bound to only the interface choosen in the carp creation. Not yet since upgrade is needed! */
1621
	$found = false;
1622
	$iflist = get_configured_interface_list();
1623
	foreach($iflist as $if) {
1624
		$ww_subnet_ip = get_interface_ip($if);
1625
		$ww_subnet_bits = get_interface_subnet($if);
1626
		if (ip_in_subnet($vip['subnet'], gen_subnet($ww_subnet_ip, $ww_subnet_bits) . "/" . $ww_subnet_bits)) {
1627
			$found = true;
1628
			break;
1629
		}
1630
	}
1631
	if($found == false) {
1619
	/* Ensure CARP IP really exists prior to loading up. */
1620
	$ww_subnet_ip = find_interface_ip($realif);
1621
	$ww_subnet_bits = find_interface_subnet($realif);
1622
	if (!ip_in_subnet($vip['subnet'], gen_subnet($ww_subnet_ip, $ww_subnet_bits) . "/" . $ww_subnet_bits)) {
1632 1623
		file_notice("CARP", "Sorry but we could not find a matching real interface subnet for the virtual IP address {$vip['subnet']}.", "Firewall: Virtual IP", "");
1633 1624
		return;
1634 1625
	}
1635 1626

  
1636
	/* invalidate interface cache */
1637
	get_interface_arr(true);
1638

  
1639 1627
	/* create the carp interface and setup */
1640 1628
	if (does_interface_exist($vipif)) {
1641 1629
		pfSense_interface_flags($vipif, -IFF_UP);

Also available in: Unified diff