From: Roy Marples Date: Thu, 15 Jan 2009 09:30:11 +0000 (+0000) Subject: New configure reasons NOCARRIER and NAK instead of just sending EXPIRE. X-Git-Tag: v5.0.0~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b66d49d3863e7ef38648ed59789bf0343a2a4798;p=thirdparty%2Fdhcpcd.git New configure reasons NOCARRIER and NAK instead of just sending EXPIRE. --- diff --git a/dhcpcd-hooks/20-resolv.conf b/dhcpcd-hooks/20-resolv.conf index 601ef0ad..357dddc4 100644 --- a/dhcpcd-hooks/20-resolv.conf +++ b/dhcpcd-hooks/20-resolv.conf @@ -120,5 +120,5 @@ remove_resolv_conf() case "${reason}" in BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) add_resolv_conf;; -PREINIT|EXPIRE|FAIL|IPV4LL|RELEASE|STOP) remove_resolv_conf;; +PREINIT|EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) remove_resolv_conf;; esac diff --git a/dhcpcd-hooks/50-ntp.conf b/dhcpcd-hooks/50-ntp.conf index 3193cb2d..1a25e31c 100644 --- a/dhcpcd-hooks/50-ntp.conf +++ b/dhcpcd-hooks/50-ntp.conf @@ -85,5 +85,5 @@ remove_ntp_conf() case "${reason}" in BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) add_ntp_conf add;; -PREINIT|EXPIRE|FAIL|IPV4LL|RELEASE|STOP) remove_ntp_conf del;; +PREINIT|EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) remove_ntp_conf del;; esac diff --git a/dhcpcd-hooks/50-yp.conf b/dhcpcd-hooks/50-yp.conf index 6060696e..2758606d 100644 --- a/dhcpcd-hooks/50-yp.conf +++ b/dhcpcd-hooks/50-yp.conf @@ -45,5 +45,5 @@ restore_yp_conf() case "${reason}" in BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) make_yp_conf;; -EXPIRE|FAIL|IPV4LL|RELEASE|STOP) restore_yp_conf;; +EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) restore_yp_conf;; esac diff --git a/dhcpcd-run-hooks.8.in b/dhcpcd-run-hooks.8.in index a2e4951d..dcc2f60a 100644 --- a/dhcpcd-run-hooks.8.in +++ b/dhcpcd-run-hooks.8.in @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd January 1, 2008 +.Dd January 15, 2009 .Dt DHCPCD.SH 8 SMM .Sh NAME .Nm dhcpcd-run-hooks @@ -68,7 +68,7 @@ argument. Here's a list of reasons why .Nm could be invoked: -.Bl -tag -width indent +.Bl -tag -width PREINIT .It Dv PREINIT dhcpcd is starting up and any pre-initialisation should be done. .It Dv INFORM @@ -82,22 +82,30 @@ dhcpcd renewed it's lease. dhcpcd has rebound to a new DHCP server. .It Dv REBOOT dhcpcd successfully requested a lease from a DHCP server. -.It Dv EXPIRE -dhcpcd's lease or state expired and it failed to obtain a new one. .It Dv IPV4LL dhcpcd failed to contact any DHCP servers but did obtain an IPV4LL address. -.It Dv FAIL -dhcpcd failed to contact any DHCP servers or use an old lease. +.It Dv STATIC +dhcpcd has been configured with a static configuration which has not been +obtained from a DHCP server. .It Dv TIMEOUT dhcpcd failed to contact any DHCP servers but was able to use an old lease. +.It Dv EXPIRE +dhcpcd's lease or state expired and it failed to obtain a new one. +.It Dv NAK +dhcpcd received a NAK from the DHCP server. +This should be treated as EXPIRE. +.It Dv NOCARRIER +dhcpcd lost the carrier. +The cable may have been unplugged or association to the wireless point lost. +.It Dv FAIL +dhcpcd failed to contact any DHCP servers or use an old lease. +.It Dv STOP +dhcpcd will stop running on the interface. .It Dv TEST dhcpcd received an OFFER from a DHCP server but will not configure the interface. This is primarily used to test the variables are filled correctly for the script to process them. -.It Dv STATIC -dhcpcd has been configured with a static configuration which has not been -obtained from a DHCP server. .El .Sh FILES When diff --git a/dhcpcd.c b/dhcpcd.c index f9e120cf..3b466a4b 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -449,7 +449,7 @@ handle_dhcp(struct interface *iface, struct dhcp_message **dhcpp) /* We should restart on a NAK */ if (type == DHCP_NAK) { log_dhcp(LOG_WARNING, "NAK:", iface, dhcp); - drop_config(iface, "EXPIRE"); + drop_config(iface, "NAK"); unlink(iface->leasefile); delete_event(iface->raw_fd); close(iface->raw_fd); @@ -726,7 +726,7 @@ handle_carrier(const char *ifname) syslog(LOG_INFO, "%s: carrier lost", iface->name); close_sockets(iface); delete_timeouts(iface, start_expire, NULL); - drop_config(iface, "EXPIRE"); + drop_config(iface, "NOCARRIER"); } break; default: