From 38080cc14c677802493b3a7670498dca8a5e851f Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 21 May 2010 22:20:44 -0400 Subject: Move get_include_contents function to pfsense-utils.inc --- etc/inc/pfsense-utils.inc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'etc/inc/pfsense-utils.inc') diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 703d421..0b8317a 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -2039,4 +2039,16 @@ function nanobsd_detect_slice_info() { $COMPLETE_BOOT_PATH="{$BOOT_DRIVE}s{$OLDSLICE}"; $BOOTFLASH="{$BOOT_DRIVE}s{$OLDSLICE}"; } -?> + +function get_include_contents($filename) { + if (is_file($filename)) { + ob_start(); + include $filename; + $contents = ob_get_contents(); + ob_end_clean(); + return $contents; + } + return false; +} + +?> \ No newline at end of file -- cgit v1.1 From a57d6170198bf46e21a178732b32982ed8b8ab62 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 22 May 2010 14:19:32 -0400 Subject: Ensure config.cache does not exist so the subsequent requests can cleanly reload the configuration. Ticket #601 --- etc/inc/pfsense-utils.inc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'etc/inc/pfsense-utils.inc') diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 0b8317a..c30a818 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -642,6 +642,8 @@ function restore_config_section($section, $new_contents) { if ($section_xml != -1) $config[$section] = &$section_xml; @unlink($g['tmp_path'] . "/tmpxml"); + if(file_exists("{$g['tmp_path']}/config.cache")) + unlink("{$g['tmp_path']}/config.cache"); write_config("Restored {$section} of config file (maybe from CARP partner)"); conf_mount_ro(); return; -- cgit v1.1 From cffe41cb24961fc08fccc438672a8424b751abd2 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 25 May 2010 15:22:52 +0000 Subject: Do not run netstat but use pfSense_get_interface_stats to gather interface statistics. This speedups a lot on nanobsd which needed some time to generate the statistics especially with dashboard --- etc/inc/pfsense-utils.inc | 73 ++++++++++++++--------------------------------- 1 file changed, 21 insertions(+), 52 deletions(-) (limited to 'etc/inc/pfsense-utils.inc') diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index c30a818..efacbe8 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1185,49 +1185,30 @@ function get_ppp_uptime($port){ //returns interface information function get_interface_info($ifdescr) { - global $config, $linkinfo, $netstatrninfo, $g; + global $config, $g; $ifinfo = array(); - /* if list */ - $iflist = get_configured_interface_with_descr(false,true); - - $found = false; - foreach ($iflist as $if => $ifname) { - if ($ifdescr == $if || $ifdescr == $ifname) { - $ifinfo['hwif'] = $config['interfaces'][$if]['if']; - $ifinfo['if'] = get_real_interface($if); - $found = true; - break; - } - } - if ($found == false) + if (empty($config['interfaces'][$ifdescr])) return; + $ifinfo['hwif'] = $config['interfaces'][$if]['if']; + $ifinfo['if'] = get_real_interface($ifdescr); - /* run netstat to determine link info */ - - unset($linkinfo); $chkif = $ifinfo['if']; - - exec("/usr/bin/netstat -I {$chkif} -nWb -f link", $linkinfo); - $linkinfo = preg_split("/\s+/", $linkinfo[1]); - $ifinfotmp = pfSense_get_interface_addresses($chkif); $ifinfo['status'] = $ifinfotmp['status']; + if (empty($ifinfo['status'])) + $ifinfo['status'] = "down"; $ifinfo['macaddr'] = $ifinfotmp['macaddr']; $ifinfo['ipaddr'] = $ifinfotmp['ipaddr']; $ifinfo['subnet'] = $ifinfotmp['subnet']; if (isset($ifinfotmp['link0'])) $link0 = "down"; - - - if (preg_match("/^enc|^tun|^ppp|^pptp|^ovpn/i", $chkif)) { - $ifinfo['inpkts'] = $linkinfo[3]; - $ifinfo['outpkts'] = $linkinfo[6]; - } else { - $ifinfo['inerrs'] = $linkinfo[5]; - $ifinfo['outerrs'] = $linkinfo[9]; - $ifinfo['collisions'] = $linkinfo[11]; - } + $ifinfotmp = pfSense_get_interface_stats($chkif); + $ifinfo['inpkts'] = $ifinfotmp['inpkts']; + $ifinfo['outpkts'] = $ifinfotmp['outpkts']; + $ifinfo['inerrs'] = $ifinfotmp['inerrs']; + $ifinfo['outerrs'] = $ifinfotmp['outerrs']; + $ifinfo['collisions'] = $ifinfotmp['collisions']; /* Use pfctl for non wrapping 64 bit counters */ /* Pass */ @@ -1262,10 +1243,6 @@ function get_interface_info($ifdescr) { $ifconfiginfo = ""; - unset($linkinfo); - exec("/usr/bin/netstat -I " . $ifinfo['if'] . " -nWb -f link", $linkinfo); - $linkinfo = preg_split("/\s+/", $linkinfo[1]); - switch ($config['interfaces'][$ifdescr]['ipaddr']) { /* DHCP? -> see if dhclient is up */ case "dhcp": @@ -1279,35 +1256,27 @@ function get_interface_info($ifdescr) { break; /* PPPoE interface? -> get status from virtual interface */ case "pppoe": - if ("{$ifinfo['if']}*" == $linkinfo[0]) - $ifinfo['pppoelink'] = "down"; - else if ($ifinfo['if'] == $linkinfo[0] && !isset($link0)) - /* get PPPoE link status for dial on demand */ - $ifinfo['pppoelink'] = "up"; + if ($ifinfo['status'] == "up" && !isset($link0)) + /* get PPPoE link status for dial on demand */ + $ifinfo['pppoelink'] = "up"; else $ifinfo['pppoelink'] = "down"; break; /* PPTP interface? -> get status from virtual interface */ case "pptp": - if ("{$ifinfo['if']}*" == $linkinfo[0]) - $ifinfo['pptplink'] = "down"; - else if ($ifinfo['if'] == $linkinfo[0] && !isset($link0)) - /* get PPTP link status for dial on demand */ - $ifinfo['pptplink'] = "up"; + if ($ifinfo['status'] == "up" && !isset($link0)) + /* get PPTP link status for dial on demand */ + $ifinfo['pptplink'] = "up"; else $ifinfo['pptplink'] = "down"; break; /* PPP interface? -> get uptime for this session and cumulative uptime from the persistant log file in conf */ case "ppp": - if ("{$ifinfo['if']}*" == $linkinfo[0]) - $ifinfo['ppplink'] = "down"; - else if ($ifinfo['if'] == $linkinfo[0]) - $ifinfo['ppplink'] = "up"; + if ($ifinfo['status'] == "up") + $ifinfo['ppplink'] = "up"; else $ifinfo['ppplink'] = "down" ; - if (empty($ifinfo['status'])) - $ifinfo['status'] = "down"; $dev = $config['interfaces'][$if]['if']; if (empty($dev)) @@ -2053,4 +2022,4 @@ function get_include_contents($filename) { return false; } -?> \ No newline at end of file +?> -- cgit v1.1 From 9b1a8d98f600fadffea6a5865d135151a8e48e9c Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 25 May 2010 16:22:36 +0000 Subject: Ticket #444. Use noatime even here. --- etc/inc/pfsense-utils.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'etc/inc/pfsense-utils.inc') diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index efacbe8..1015023 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1965,8 +1965,8 @@ function nanobsd_update_fstab($gslice, $complete_path, $oldufs, $newufs) { if (!file_exists($fstabpath)) { $fstab = <<