summaryrefslogtreecommitdiffstats
path: root/etc/inc/pfsense-utils.inc
diff options
context:
space:
mode:
authorBill Marquette <billm@pfsense.org>2006-08-11 02:23:21 +0000
committerBill Marquette <billm@pfsense.org>2006-08-11 02:23:21 +0000
commit8b124b2a2a28a23dddfc2314022c02e3daf34ae6 (patch)
tree8f863721ca7a22de8213426df36970406ab55e06 /etc/inc/pfsense-utils.inc
parenta960d9909e6b6b3bc8ff721ebc5e1482cf811a10 (diff)
downloadpfsense-8b124b2a2a28a23dddfc2314022c02e3daf34ae6.zip
pfsense-8b124b2a2a28a23dddfc2314022c02e3daf34ae6.tar.gz
MFC 13714
Cache interface IPs - this led to a 60+ second speed up on my 4801 when running rc.filter_configure
Diffstat (limited to 'etc/inc/pfsense-utils.inc')
-rw-r--r--etc/inc/pfsense-utils.inc11
1 files changed, 8 insertions, 3 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 36f73b5..01b61d6 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -561,11 +561,16 @@ function convert_ip_to_network_format($ip, $subnet) {
* find_interface_ip($interface): return the interface ip (first found)
*/
function find_interface_ip($interface) {
+ global $interface_ip_arr_cache;
$interface = str_replace("\n", "", $interface);
if(does_interface_exist($interface) == false) return;
- $ip = exec_command("/sbin/ifconfig {$interface} | /usr/bin/grep -w \"inet\" | /usr/bin/cut -d\" \" -f 2");
- $ip = str_replace("\n","",$ip);
- return $ip;
+ /* Setup IP cache */
+ if (!isset($interface_ip_arr_cache[$interface])) {
+ $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]);
+ }
+
+ return $interface_ip_arr_cache[$interface];
}
function guess_interface_from_ip($ipaddress) {
OpenPOWER on IntegriCloud