diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2006-12-28 21:49:45 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2006-12-28 21:49:45 +0000 |
commit | 2305d4c590a2645e2a294c20adb323b3dc25307d (patch) | |
tree | c23b1a2fdd24b4669587896921f2ade535f097c2 /etc | |
parent | 06246e5bbe4407b19fc93f40bed3835a7656160a (diff) | |
download | pfsense-2305d4c590a2645e2a294c20adb323b3dc25307d.zip pfsense-2305d4c590a2645e2a294c20adb323b3dc25307d.tar.gz |
Go back to stock FreeBSD dhclient. ISC's is not very multi wan friendly and will make rearchitecting our code a complete interface rewrite.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/devd.conf | 18 | ||||
-rw-r--r-- | etc/inc/interfaces.inc | 75 |
2 files changed, 61 insertions, 32 deletions
diff --git a/etc/devd.conf b/etc/devd.conf index 310f293..847f6f5 100644 --- a/etc/devd.conf +++ b/etc/devd.conf @@ -11,6 +11,18 @@ options { [0-9]+"; }; +# Handle ethernet linkup and linkdown +notify 0 { + match "type" "LINK_UP"; + media-type "ethernet"; + action "/bin/echo -n '$subsystem start ' >>/tmp/rc.linkup"; +}; +notify 0 { + match "type" "LINK_DOWN"; + media-type "ethernet"; + action "/bin/echo -n '$subsystem stop ' >>/tmp/rc.linkup"; +}; + # When a USB keyboard arrives, attach it as the console keyboard. attach 100 { device-name "ukbd0"; @@ -21,12 +33,6 @@ detach 100 { action "kbdcontrol -k /dev/kbd0 < /dev/console"; }; -notify 0 { - match "type" "LINK_DOWN"; - media-type "ethernet"; - action "/bin/echo -n '$subsystem stop ' >>/tmp/rc.linkup"; -}; - # Notify all users before beginning emergency shutdown when we get # a _CRT or _HOT thermal event and we're going to power down the system # very soon. diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index f649370..cf8b7c9 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -742,8 +742,9 @@ function kill_wpasupplicant($interface) { } function find_dhclient_process($interface) { - $interface = convert_friendly_interface_to_real_interface_name($interface); - $pid = exec("/bin/ps awwux | /usr/bin/grep dhclient | /usr/bin/grep -v grep | /usr/bin/grep {$interface} | /usr/bin/awk '{ print \$2 }'"); + if(filter_translate_type_to_real_interface($interface) <> "") + $realinterface = filter_translate_type_to_real_interface($interface); + $pid = `/usr/bin/pgrep -f "dhclient: {$realinterface}(\$| .*)"`; return $pid; } @@ -756,9 +757,7 @@ function interfaces_wan_configure() { mute_kernel_msgs(); /* find dhclient process for wan and kill it */ - $dhclient_pid = find_dhclient_process("wan"); - if($dhclient_pid) - mwexec("kill {$dhclient_pid}"); + killbypid(find_dhclient_process("wan")); /* remove wanup file if it exists */ unlink_if_exists("{$g['tmp_path']}/wanup"); @@ -947,12 +946,19 @@ function interfaces_opt_dhcp_configure($interface) { return 1; } + if ($optcfg['dhcphostname']) { + $dhclientconf_hostname = "send dhcp-client-identifier \"{$optcfg['dhcphostname']}\";\n"; + $dhclientconf_hostname .= "\tsend host-name \"{$optcfg['dhcphostname']}\";\n"; + } else { + $dhclientconf_hostname = ""; + } + $dhclientconf = ""; $dhclientconf .= <<<EOD -send dhcp-client-identifier "{$optcfg['dhcphostname']}"; interface "{$optif}" { - send host-name "{$optcfg['dhcphostname']}"; + script "/sbin/dhclient-script"; + {$dhclientconf_hostname} } EOD; @@ -964,7 +970,7 @@ EOD; mwexec("/sbin/ifconfig {$optif} up"); /* fire up dhclient */ - mwexec("/sbin/dhclient -cf {$g['varetc_path']}/dhclient_{$optif}.conf -sf /sbin/dhclient-script {$optif}"); + mwexec("/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$optif}.conf {$optif}"); return 0; } @@ -984,12 +990,19 @@ function interfaces_dhcp_configure($interface) { return 1; } + if ($optcfg['dhcphostname']) { + $dhclientconf_hostname = "send dhcp-client-identifier \"{$optcfg['dhcphostname']}\";\n"; + $dhclientconf_hostname .= "\tsend host-name \"{$optcfg['dhcphostname']}\";\n"; + } else { + $dhclientconf_hostname = ""; + } + $dhclientconf = ""; $dhclientconf .= <<<EOD -send dhcp-client-identifier "{$optcfg['dhcphostname']}"; interface "{$realinterface}" { - send host-name "{$optcfg['dhcphostname']}"; + {$dhclientconf_hostname} + script "/sbin/dhclient-script"; } EOD; @@ -1003,10 +1016,10 @@ EOD; mwexec("/sbin/ifconfig {$optif} up"); /* fire up dhclient */ - mwexec("/sbin/dhclient -cf {$g['varetc_path']}/dhclient_{$optif}.conf -sf /sbin/dhclient-script {$optif} "); + mwexec("/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$optif}.conf {$optif} >/tmp/{$optif}_output >/tmp/{$optif}_error_output"); $fout = fopen("/tmp/ifconfig_{$optif}","w"); - fwrite($fout, "/sbin/dhclient -cf {$g['varetc_path']}/dhclient_{$optif}.conf -sf /sbin/dhclient-script {$optif}"); + fwrite($fout, "/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$optif}.conf {$optif}"); fclose($fout); return 0; @@ -1024,12 +1037,19 @@ function interfaces_wan_dhcp_configure() { return 1; } + if ($wancfg['dhcphostname']) { + $dhclientconf_hostname = "send dhcp-client-identifier \"{$wancfg['dhcphostname']}\";\n"; + $dhclientconf_hostname .= "\tsend host-name \"{$wancfg['dhcphostname']}\";\n"; + } else { + $dhclientconf_hostname = ""; + } + $dhclientconf = ""; $dhclientconf .= <<<EOD -send dhcp-client-identifier "{$wancfg['dhcphostname']}"; interface "{$wancfg['if']}" { - send host-name "{$wancfg['dhcphostname']}"; + {$dhclientconf_hostname} + script "/sbin/dhclient-script"; } EOD; @@ -1043,29 +1063,32 @@ EOD; mwexec("/sbin/ifconfig {$wanif} up"); /* fire up dhclient */ - mwexec("/sbin/dhclient -cf {$g['varetc_path']}/dhclient_wan.conf -sf /sbin/dhclient-script {$wanif}"); + mwexec("/sbin/dhclient -c {$g['varetc_path']}/dhclient_wan.conf {$wanif} >/tmp/{$wanif}_output >/tmp/{$wanif}_error_output"); $fout = fopen("/tmp/ifconfig_{$wanif}","w"); - fwrite($fout, "/sbin/dhclient -cf {$g['varetc_path']}/dhclient_wan.conf -sf /sbin/dhclient-script {$wanif}"); + fwrite($fout, "/sbin/dhclient -c {$g['varetc_path']}/dhclient_wan.conf {$wanif}"); fclose($fout); return 0; } function interfaces_wan_dhcp_down() { - interfaces_dhcp_down("wan"); + global $config; + $wancfg = $config['interfaces']['wan']; + $wanif = $wancfg['if']; + mwexec("/sbin/ifconfig {$wanif} delete"); + sleep(1); } function interfaces_dhcp_down($interface) { - global $config, $g; - $interface = convert_friendly_interface_to_real_interface_name($interface); - $dhclient_pid = find_dhclient_process($interface); - if($dhclient_pid) - exec("kill {$dhclient_pid}"); - log_error("deleting interface $interface"); - sleep(2); - exec("/sbin/ifconfig {$interface} delete"); - exec("/sbin/ifconfig {$interface} down"); + global $config; + if(filter_translate_type_to_real_interface($interface) <> "") + $realinterface = filter_translate_type_to_real_interface($interface); + mwexec("/sbin/ifconfig {$realinterface} down"); + sleep(1); + $pid = find_dhclient_process($interface); + if($pid) + mwexec("kill {$pid}"); } function interfaces_dhcp_up($interface) { |