diff options
author | Bill Marquette <billm@pfsense.org> | 2006-08-11 22:55:40 +0000 |
---|---|---|
committer | Bill Marquette <billm@pfsense.org> | 2006-08-11 22:55:40 +0000 |
commit | 3f7d2120ae310e87217a0db98e5f3f2e1983b682 (patch) | |
tree | a945c4763a3888c440b38fc61a93f5d951a521e7 /etc | |
parent | 9e097ada68ac69c0933753dcf0cca04aa205c630 (diff) | |
download | pfsense-3f7d2120ae310e87217a0db98e5f3f2e1983b682.zip pfsense-3f7d2120ae310e87217a0db98e5f3f2e1983b682.tar.gz |
flush the interface cache every time an interface is created
thanks go to MxxCon for testing
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/interfaces.inc | 22 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 12 |
2 files changed, 25 insertions, 9 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index ab12a8f..6ced05b 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -77,6 +77,9 @@ function interfaces_vlan_configure() { mwexec($cmd); + /* invalidate interface cache */ + get_interface_arr(true); + /* make sure the parent interface is up */ mwexec("/sbin/ifconfig " . escapeshellarg($vlan['if']) . " up"); @@ -160,7 +163,8 @@ function interfaces_lan_configure() { $bridges_total++; /* update cache */ - find_number_of_created_bridges(); + if ($bridges_total != find_number_of_created_bridges()) + find_number_of_created_bridges(true); } /* media */ @@ -289,6 +293,9 @@ function interfaces_optional_configure_if($opti) { mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . " delete up"); /* use open/netBSD style bridge */ mwexec("/sbin/ifconfig bridge{$bridges_total} create"); + + /* invalidate interface cache */ + get_interface_arr(true); /* force all bridged interfaces to use same mtu */ $mtu = get_interface_mtu($config['interfaces'][$optcfg['bridge']]['if']); @@ -322,7 +329,8 @@ function interfaces_optional_configure_if($opti) { $bridges_total++; /* update cache */ - find_number_of_created_bridges(); + if ($bridges_total != find_number_of_created_bridges()) + find_number_of_created_bridges(true); } else { /* if user has selected DHCP type then act accordingly */ if($optcfg['ipaddr'] == "dhcp") { @@ -403,6 +411,10 @@ function interfaces_carp_configure() { $vip_password = str_replace(" ", "", $vip_password); /* create the carp interface and setup */ mwexec("/sbin/ifconfig carp" . $carp_instances_counter . " create"); + + /* invalidate interface cache */ + get_interface_arr(true); + $broadcast_address = gen_subnet_max($vip['subnet'], $vip['subnet_bits']); if($vip['password'] != "") $password = " pass \"" . $vip_password . "\""; @@ -851,6 +863,9 @@ function interfaces_wan_configure() { if ($wancfg['bridge']) { /* use open/netBSD style bridge */ mwexec("/sbin/ifconfig bridge{$bridges_total} create"); + + /* invalidate interface cache */ + get_interface_arr(true); /* force all bridged interfaces to use same mtu */ $mtu = get_interface_mtu($config['interfaces'][$wancfg['bridge']]['if']); @@ -884,7 +899,8 @@ function interfaces_wan_configure() { $bridges_total++; /* update cache */ - find_number_of_created_bridges(); + if ($bridges_total != find_number_of_created_bridges()) + find_number_of_created_bridges(true); } if (!$g['booting']) { diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 5947cad..9509043 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -529,11 +529,11 @@ function is_jumbo_capable($int) { /* * Return the interface array */ -function get_interface_arr() { +function get_interface_arr($flush = false) { global $interface_arr_cache; /* If the cache doesn't exist, build it */ - if (!isset($interface_arr_cache)) + if (!isset($interface_arr_cache) or $flush) $interface_arr_cache = exec_command("/sbin/ifconfig -l"); return $interface_arr_cache; @@ -564,12 +564,12 @@ function convert_ip_to_network_format($ip, $subnet) { /* * find_interface_ip($interface): return the interface ip (first found) */ -function find_interface_ip($interface) { +function find_interface_ip($interface, $flush = false) { global $interface_ip_arr_cache; $interface = str_replace("\n", "", $interface); if(does_interface_exist($interface) == false) return; /* Setup IP cache */ - if (!isset($interface_ip_arr_cache[$interface])) { + if (!isset($interface_ip_arr_cache[$interface]) or $flush) { $interface_ip_arr_cache[$interface] = exec_command("/sbin/ifconfig {$interface} | /usr/bin/grep -w \"inet\" | /usr/bin/cut -d\" \" -f 2"); $interface_ip_arr_cache[$interface] = str_replace("\n", "", $interface_ip_arr_cache[$interface]); } @@ -708,9 +708,9 @@ function setup_filter_bridge() { /* * find_number_of_created_bridges(): returns the number of currently created bridges */ -function find_number_of_created_bridges() { +function find_number_of_created_bridges($flush = false) { global $bridge_interface_count_cache; - if(!isset($bridge_interface_count_cache)) + if(!isset($bridge_interface_count_cache) or $flush) $bridge_interface_count_cache = exec_command('/sbin/ifconfig | /usr/bin/grep "bridge[0-999]" | /usr/bin/wc -l'); return $bridge_interface_count_cache; |