]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Expire the DHCPv6 lease when carrier drops.
authorRoy Marples <roy@marples.name>
Sun, 11 Nov 2012 19:56:01 +0000 (19:56 +0000)
committerRoy Marples <roy@marples.name>
Sun, 11 Nov 2012 19:56:01 +0000 (19:56 +0000)
dhcp6.c
dhcp6.h
dhcpcd-run-hooks.8.in
dhcpcd.c

diff --git a/dhcp6.c b/dhcp6.c
index bf2f7736c7c580837f85e4e0bbf9b64871a61e42..b0e9221d39598ee480061e171799b280b4cab665 100644 (file)
--- 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 3a1b023bfc2f53d08c212a1ae9802619103560a8..f3ba5cce8b2da373604fb68da99013eb2a4a7b0d 100644 (file)
--- 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
index 49a2962a8435afcaedca3b39f8bbd1d2bc833735..ed5c2518052c41286f4c05586658b9d8e0758ad5 100644 (file)
@@ -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.
index 7bee966b5c2f3e66ca69dc8c8973ba98aef472f8..2678edebbf889c4f2f61d26bfa12c71cf7d38598 100644 (file)
--- 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");
                }