diff options
author | gnhb <gnoahb@gmail.com> | 2010-06-07 23:24:17 +0700 |
---|---|---|
committer | gnhb <gnoahb@gmail.com> | 2010-06-07 23:24:17 +0700 |
commit | 277d0250b0b344893c166df91cb66c2269ade1de (patch) | |
tree | 366643a754c140a34db43d4266c8a88b5ca49e60 /etc | |
parent | c1cc447c5d439e973f7d0915d95ad998c575eb65 (diff) | |
parent | 692730bf32b6658bee626c2bb58ffce54b7bcb14 (diff) | |
download | pfsense-277d0250b0b344893c166df91cb66c2269ade1de.zip pfsense-277d0250b0b344893c166df91cb66c2269ade1de.tar.gz |
Merge branch 'master' of http://gitweb.pfsense.org/pfsense/mainline into mlppp
Conflicts:
etc/inc/interfaces.inc
etc/inc/pfsense-utils.inc
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/filter.inc | 7 | ||||
-rw-r--r-- | etc/inc/gwlb.inc | 19 | ||||
-rw-r--r-- | etc/inc/interfaces.inc | 221 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 2 | ||||
-rw-r--r-- | etc/inc/rrd.inc | 2 | ||||
-rw-r--r-- | etc/inc/services.inc | 23 | ||||
-rw-r--r-- | etc/inc/system.inc | 13 | ||||
-rwxr-xr-x | etc/rc.bootup | 3 |
8 files changed, 143 insertions, 147 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index ee9317e..0bbcf58 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -140,8 +140,9 @@ function filter_configure() { touch($g['tmp_path'] . "/filter_dirty"); } -function delete_states_for_down_gateways() { +function filter_delete_states_for_down_gateways() { global $config; + $a_gateways = return_gateways_status(); foreach ($a_gateways as $gateway) { if ($gateway['status'] == "down") { @@ -369,7 +370,7 @@ function filter_configure_sync() { echo "."; update_filter_reload_status("Processing down interface states"); - delete_states_for_down_gateways(); + filter_delete_states_for_down_gateways(); update_filter_reload_status("Running plugins"); @@ -2084,7 +2085,7 @@ EOD; /* if antilockout is enabled, LAN exists and has * an IP and subnet mask assigned */ - $lanif = $FilterIflist["lan"]['if']; + $lanif = $FilterIflist['lan']['if']; $ipfrules .= <<<EOD # make sure the user cannot lock himself out of the webConfigurator or SSH anchor "anti-lockout" diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc index 846d33d..70bfd52 100644 --- a/etc/inc/gwlb.inc +++ b/etc/inc/gwlb.inc @@ -243,9 +243,7 @@ EOD; /* return the status of the apinger targets as a array */ function return_gateways_status() { - global $config; - global $g; - $gateways_arr = return_gateways_array(); + global $config, $g; $apingerstatus = array(); if (file_exists("{$g['tmp_path']}/apinger.status")) { @@ -253,21 +251,6 @@ function return_gateways_status() { } $status = array(); - $i = 2; - /* assign a dummy IP address for dynamic interfaces in case we need it */ - $monitor = array(); - foreach($gateways_arr as $name => $gateway) { - if($gateway['monitor'] == "dynamic") { - $gateway['monitor'] = "127.0.0.{$i}"; - $i++; - } - $status[$gateway['monitor']]['monitor'] = $gateway['monitor']; - $status[$gateway['monitor']]['interface'] = $gateway['interface']; - $status[$gateway['monitor']]['gateway'] = $gateway['gateway']; - $status[$gateway['monitor']]['name'] = $gateway['name']; - $status[$gateway['monitor']]['status'] = "down"; - - } foreach($apingerstatus as $line) { $info = explode("|", $line); $target = $info[0]; diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index a40e549..6b75e7e 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -62,7 +62,7 @@ function get_interface_arr($flush = false) { /* If the cache doesn't exist, build it */ if (!isset($interface_arr_cache) or $flush) - $interface_arr_cache = `/sbin/ifconfig -l`; + $interface_arr_cache = explode(" ", `/sbin/ifconfig -l`); return $interface_arr_cache; } @@ -78,7 +78,7 @@ function does_interface_exist($interface) { return false; $ints = get_interface_arr(); - if(stristr($ints, $interface) !== false) + if (in_array($interface, $ints)) return true; else return false; @@ -2331,7 +2331,10 @@ EOD; function interface_pppoe_configure($interface = "wan") { global $config, $g; - $wancfg = $config['interfaces'][$interface]; + if (!is_array($config['interfaces'][$interface])) + return; + + $wancfg =& $config['interfaces'][$interface]; /* generate mpd.conf */ $fd = fopen("{$g['varetc_path']}/mpd_{$interface}.conf", "w"); @@ -2365,7 +2368,8 @@ EOD; $realif = "pppoe0"; else { // Here code assumes only that strings of form "opt#" will be passed. - $realif = "pppoe" . substr($interface, 3); + $pppoeidx = substr($interface, 3); + $realif = "pppoe{$pppoeidx}"; } $mpdconf .= <<<EOD @@ -2489,7 +2493,10 @@ EOD; function interface_pptp_configure($interface) { global $config, $g; - $wancfg = $config['interfaces'][$interface]; + if (!is_array($config['interfaces'][$interface])) + return; + + $wancfg =& $config['interfaces'][$interface]; /* generate mpd.conf */ $fd = fopen("{$g['varetc_path']}/mpd_{$interface}.conf", "w"); @@ -2523,8 +2530,9 @@ EOD; $realif = "pptp0"; else { // Here code assumes only that strings of form "opt#" will be passed. - $realif = "pptp" . substr($interface, 3); - } + $pptpidx = substr($interface, 3); + $realif = "pptp{$pptpidx}"; + } $mpdconf .= <<<EOD create bundle static {$interface} @@ -2663,52 +2671,66 @@ function convert_real_interface_to_friendly_interface_name($interface = "wan") { global $config; if (stristr($interface, "pppoe")) { - $index = substr($interface, 5); - if (intval($index) > 0) + $index = intval(substr($interface, 5)); + if ($interface == "pppoe") + return "lan"; + if ($index > 0) return "opt{$index}"; else return "wan"; } else if (stristr($interface, "pptp")) { - $index = substr($interface, 4); - if (intval($index) > 0) + $index = intval(substr($interface, 4)); + if ($interface == "pptp") + return "lan"; + if ($index > 0) + return "opt{$index}"; + else + return "wan"; + } else if (stristr($interface, "ppp")) { + $index = intval(substr($interface, 3)); + if ($interface == "ppp") + return "lan"; + if ($index > 0) + return "opt{$index}"; + else + return "wan"; + } else if (stristr($interface, "l2tp")) { + $index = intval(substr($interface, 4)); + if ($interface == "l2tp") + return "lan"; + if ($index > 0) return "opt{$index}"; else return "wan"; } else if (stristr($interface, "vip")) { - $index = substr($interface, 3); - $counter = 0; - foreach ($config['virtualip']['vip'] as $vip) { + $index = intval(substr($interface, 3)); + foreach ($config['virtualip']['vip'] as $counter => $vip) { if ($vip['mode'] == "carpdev-dhcp" || $vip['mode'] == "carp") { - if (intval($index) == $counter) + if ($index == $counter) return $vip['interface']; - $counter++; } } } else if (stristr($interface, "carp")) { - $index = substr($interface, 4); - $counter = 0; - foreach ($config['virtualip']['vip'] as $vip) { + $index = intval(substr($interface, 4)); + foreach ($config['virtualip']['vip'] as $counter => $vip) { if ($vip['mode'] == "carpdev-dhcp" || $vip['mode'] == "carp") { - if (intval($index) == $counter) + if ($index == $counter) return $vip['interface']; - $counter++; } } } - /* if list */ - $ifdescrs = get_configured_interface_list(false, true); + /* XXX: For speed reasons reference directly the interface array */ + $ifdescrs = $config['interfaces']; + //$ifdescrs = get_configured_interface_list(false, true); foreach ($ifdescrs as $if => $ifname) { - if($config['interfaces'][$if]['if'] == $interface) - return $ifname; + if ($config['interfaces'][$if]['if'] == $interface) + return $if; /* XXX: ermal - The 3 lines below are totally bogus code. */ $int = interface_translate_type_to_real($if); - if($ifname == $interface) - return $ifname; - - if($int == $interface) + if ($int == $interface) return $ifname; } return NULL; @@ -2824,66 +2846,61 @@ function get_real_interface($interface = "wan", $get_parent = false) { $wanif = "ppp"; break; default: - $iflist = get_configured_interface_with_descr(false, true); - - foreach ($iflist as $if => $ifdesc) { - // If a real interface was alread passed simply - // pass the real interface back. This encourages - // the usage of this function in more cases so that - // we can combine logic for more flexibility. - if($config['interfaces'][$if]['if'] == $interface) { - if(does_interface_exist($interface)) { - $wanif = $interface; - break; - } - } + // If a real interface was alread passed simply + // pass the real interface back. This encourages + // the usage of this function in more cases so that + // we can combine logic for more flexibility. + if(does_interface_exist($interface)) { + $wanif = $interface; + break; + } + if (empty($config['interfaces'][$interface])) + break; - if ($interface == $if || $interface == $ifdesc) { + $cfg =& $config['interfaces'][$interface]; - $cfg = $config['interfaces'][$if]; - - // Wireless cloned NIC support (FreeBSD 8+) - // interface name format: $parentnic_wlanparentnic# - // example: ath0_wlan0 - if(is_interface_wireless($cfg['if'])) { - $wanif = interface_get_wireless_clone($cfg['if']); - break; - } - - if (empty($cfg['ipaddr'])) { - $wanif = $cfg['if']; - break; - } - - switch ($cfg['ipaddr']) { - case "carpdev-dhcp": - $viparr = &$config['virtualip']['vip']; - $counter = 0; - if(is_array($viparr)) - foreach ($viparr as $vip) { - if ($vip['mode'] == "carpdev-dhcp") { - if($vip['interface'] == $if) { - $wanif = "carp{$counter}"; - break; - } - $counter++; - } else if ($vip['mode'] = "carp") - $counter++; + // Wireless cloned NIC support (FreeBSD 8+) + // interface name format: $parentnic_wlanparentnic# + // example: ath0_wlan0 + if (is_interface_wireless($cfg['if'])) { + $wanif = interface_get_wireless_clone($cfg['if']); + break; + } + /* + if (empty($cfg['if'])) { + $wancfg = $cfg['if']; + break; + } + */ + + switch ($cfg['ipaddr']) { + case "carpdev-dhcp": + $viparr = &$config['virtualip']['vip']; + if(is_array($viparr)) + foreach ($viparr as $counter => $vip) { + if ($vip['mode'] == "carpdev-dhcp") { + if($vip['interface'] == $interface) { + $wanif = "carp{$counter}"; + break; } - break; - default: - $wanif = $cfg['if']; - if ($get_parent && isset($cfg['ptpid'])) - foreach ($config['ppps']['ppp'] as $ppp) { - if ($ppp['ptpid'] == $cfg['ptpid']) - $wanif = $ppp['ports']; - } - break; } - - break; } - } + break; + case "pppoe": + case "pptp": + case "l2tp": + case "ppp": + $wanif = $cfg['if']; + if ($get_parent && isset($cfg['ptpid'])) + foreach ($config['ppps']['ppp'] as $ppp) { + if ($ppp['ptpid'] == $cfg['ptpid']) + $wanif = $ppp['ports']; + } + break; + default: + $wanif = $cfg['if']; + break; + } break; } @@ -3130,10 +3147,6 @@ function get_interface_ip($interface = "wan") return null; } - /* Do we really come here for these interfaces ?! */ - if (in_array($realif, array("pptp", "pppoe", "l2tp", "openvpn", "enc0" /* , "ppp" */))) - return ""; - $curip = find_interface_ip($realif); if ($curip && is_ipaddr($curip) && ($curip != "0.0.0.0")) return $curip; @@ -3153,10 +3166,6 @@ function get_interface_subnet($interface = "wan") return null; } - /* Do we really come here for these interfaces ?! */ - if (in_array($realif, array("pptp", "pppoe", "l2tp", "openvpn", "enc0" /* , "ppp" */))) - return ""; - $cursn = find_interface_subnet($realif); if (!empty($cursn)) return $cursn; @@ -3179,12 +3188,13 @@ function get_interfaces_with_gateway() { case "ppp"; case "pppoe": case "pptp": - case "l2tp"; - $ints[] = $ifdescr; + case "l2tp": + case "ppp"; + $ints[$ifdescr] = $ifdescr; break; default: if (!empty($ifname['gateway'])) - $ints[] = $ifdescr; + $ints[$ifdescr] = $ifdescr; break; } } @@ -3193,10 +3203,25 @@ function get_interfaces_with_gateway() { /* return true if interface has a gateway */ function interface_has_gateway($friendly) { + global $config; - $friendly = strtolower($friendly); - if (in_array($friendly, get_interfaces_with_gateway())) - return true; + if (!empty($config['interfaces'][$friendly])) { + $ifname =& $config['interfaces'][$friendly]; + switch ($ifname['ipaddr']) { + case "dhcp": + case "carpdev-dhcp": + case "pppoe": + case "pptp": + case "l2tp": + case "ppp"; + return true; + break; + default: + if (!empty($ifname['gateway'])) + return true; + break; + } + } return false; } diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 57d900f..9b30248 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1273,7 +1273,7 @@ function get_interface_info($ifdescr) { break; if (file_exists($dev)) { if (file_exists("{$g['varrun_path']}/ppp_{$ifdescr}.pid")) { - $ifinfo['pppinfo'] = $ifinfo['if']; + $ifinfo['pppinfo'] = $ifinfo['ifdescr']; $sec = trim(`/usr/local/sbin/ppp-uptime.sh {$ifinfo['if']}`); $ifinfo['ppp_uptime'] = convert_seconds_to_hms($sec); } diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc index 85221e6..98766e3 100644 --- a/etc/inc/rrd.inc +++ b/etc/inc/rrd.inc @@ -634,7 +634,7 @@ function enable_rrd_graphing() { } function kill_traffic_collector() { - mwexec("/bin/pkill -f updaterrd.sh"); + mwexec("/bin/pkill -f updaterrd.sh", true); } ?> diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 013351b..94f69cd 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -38,26 +38,6 @@ pfSense_MODULE: utils */ -function services_parse_dhcpd_hostnames() { - global $g, $config; - - // Launch if option enabled - if (isset($config['dnsmasq']['regdhcp'])) { - /* Make sure we do not error out */ - @touch("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"); - if (!file_exists("{$g['varetc_path']}/hosts")) - system_hosts_generate(); - if (file_exists("{$g['varrun_path']}/dhcpleases.pid")) - sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "HUP"); - else - mwexec("/usr/local/sbin/dhcpleases -l {$g['dhcpd_chroot_path']}/var/db/dhcpd.leases -d {$config['system']['domain']} -p {$g['varrun_path']}/dnsmasq.pid -h {$g['varetc_path']}/hosts"); - } else { - sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "TERM"); - @unlink("{$g['varrun_path']}/dhcpleases.pid"); - } - -} - function services_dhcpd_configure() { global $config, $g; @@ -648,9 +628,6 @@ function services_dnsmasq_configure() { $return = 1; } - // restart isc-dhcpd parser - services_parse_dhcpd_hostnames(); - return $return; } diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 75e3f6d..a7c3423 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -225,6 +225,19 @@ function system_hosts_generate() { fwrite($fd, $hosts); fclose($fd); + /* Start the monitoring process for dynamic dhcpclients. */ + if (isset($config['dnsmasq']['regdhcp'])) { + /* Make sure we do not error out */ + @touch("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"); + if (file_exists("{$g['varrun_path']}/dhcpleases.pid")) + sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "HUP"); + else + mwexec("/usr/local/sbin/dhcpleases -l {$g['dhcpd_chroot_path']}/var/db/dhcpd.leases -d {$syscfg['domain']} -p {$g['varrun_path']}/dnsmasq.pid -h {$g['varetc_path']}/hosts"); + } else { + sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "TERM"); + @unlink("{$g['varrun_path']}/dhcpleases.pid"); + } + return 0; } diff --git a/etc/rc.bootup b/etc/rc.bootup index 2f977f3..eb5a0b4 100755 --- a/etc/rc.bootup +++ b/etc/rc.bootup @@ -331,9 +331,6 @@ enable_rrd_graphing(); /* start DHCP service */ services_dhcpd_configure(); -/* start DHCP logging service which populates /etc/hosts */ -services_parse_dhcpd_hostnames(); - /* startup OLSR if needed */ setup_wireless_olsr(); |