]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix moving a lease from one interface to another.
authorRoy Marples <roy@marples.name>
Tue, 15 Sep 2015 13:37:44 +0000 (13:37 +0000)
committerRoy Marples <roy@marples.name>
Tue, 15 Sep 2015 13:37:44 +0000 (13:37 +0000)
dhcp.c

diff --git a/dhcp.c b/dhcp.c
index 3467a68e3681ac9d31ea0916e2c9468db8563074..946079efdc2f3afc366a772a137b1575b1f492c0 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -1980,10 +1980,14 @@ dhcp_bind(struct interface *ifp)
        struct dhcp_lease *lease = &state->lease;
 
        state->reason = NULL;
-       free(state->old);
-       state->old = state->new;
-       state->new = state->offer;
-       state->offer = NULL;
+       /* If we don't have an offer, we are re-binding a lease on preference,
+        * normally when two interfaces have a lease matching IP addresses. */
+       if (state->offer) {
+               free(state->old);
+               state->old = state->new;
+               state->new = state->offer;
+               state->offer = NULL;
+       }
        get_lease(ifp->ctx, lease, state->new);
        if (ifo->options & DHCPCD_STATIC) {
                logger(ifp->ctx, LOG_INFO, "%s: using static address %s/%d",