From: Roy Marples Date: Sun, 11 Nov 2012 19:56:01 +0000 (+0000) Subject: Expire the DHCPv6 lease when carrier drops. X-Git-Tag: v5.99.3~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=94582a4d23a922f24684945fe87258f710c49aca;p=thirdparty%2Fdhcpcd.git Expire the DHCPv6 lease when carrier drops. --- diff --git a/dhcp6.c b/dhcp6.c index bf2f7736..b0e9221d 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -1507,7 +1507,7 @@ dhcp6_start(struct interface *ifp, int manage) } static void -dhcp6_freedrop(struct interface *ifp, int drop) +dhcp6_freedrop(struct interface *ifp, int drop, const char *reason) { struct dhcp6_state *state; @@ -1515,8 +1515,11 @@ dhcp6_freedrop(struct interface *ifp, int drop) state = D6_STATE(ifp); if (state) { dhcp6_freedrop_addrs(ifp, drop); - if (drop && state->new) - run_script_reason(ifp, "STOP6"); + if (drop && state->new) { + if (reason == NULL) + reason = "STOP6"; + run_script_reason(ifp, reason); + } free(state->send); free(state->recv); free(state->new); @@ -1538,17 +1541,17 @@ dhcp6_freedrop(struct interface *ifp, int drop) } void -dhcp6_drop(struct interface *ifp) +dhcp6_drop(struct interface *ifp, const char *reason) { - dhcp6_freedrop(ifp, 1); + dhcp6_freedrop(ifp, 1, reason); } void dhcp6_free(struct interface *ifp) { - dhcp6_freedrop(ifp, 0); + dhcp6_freedrop(ifp, 0, NULL); } ssize_t diff --git a/dhcp6.h b/dhcp6.h index 3a1b023b..f3ba5cce 100644 --- a/dhcp6.h +++ b/dhcp6.h @@ -202,6 +202,6 @@ int dhcp6_start(struct interface *, int); ssize_t dhcp6_env(char **, const char *, const struct interface *, const struct dhcp6_message *, ssize_t); void dhcp6_free(struct interface *); -void dhcp6_drop(struct interface *); +void dhcp6_drop(struct interface *, const char *); #endif diff --git a/dhcpcd-run-hooks.8.in b/dhcpcd-run-hooks.8.in index 49a2962a..ed5c2518 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 November 6, 2012 +.Dd November 11, 2012 .Dt DHCPCD-RUN-HOOKS 8 .Os .Sh NAME @@ -95,7 +95,7 @@ obtained from a DHCP server. dhcpcd is monitoring the interface for a 3rd party to give it an IP address. .It Dv TIMEOUT dhcpcd failed to contact any DHCP servers but was able to use an old lease. -.It Dv EXPIRE +.It Dv EXPIRE | EXPIRE6 dhcpcd's lease or state expired and it failed to obtain a new one. .It Dv RELEASE dhcpcd's lease was released back to the DHCP server for re-use. diff --git a/dhcpcd.c b/dhcpcd.c index 7bee966b..2678edeb 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -277,7 +277,7 @@ stop_interface(struct interface *iface) else ifaces = ifp->next; - dhcp6_drop(iface); + dhcp6_drop(iface, NULL); ipv6rs_drop(iface); if (strcmp(iface->state->reason, "RELEASE") != 0) drop_dhcp(iface, "STOP"); @@ -955,7 +955,7 @@ handle_carrier(int action, int flags, const char *ifname) syslog(LOG_INFO, "%s: carrier lost", iface->name); close_sockets(iface); delete_timeouts(iface, start_expire, NULL); - dhcp6_drop(iface); + dhcp6_drop(iface, "EXPIRE6"); ipv6rs_drop(iface); drop_dhcp(iface, "NOCARRIER"); }