]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Update remembered addresses for netmask and broadcast addresss.
authorRoy Marples <roy@marples.name>
Mon, 25 Apr 2016 16:23:37 +0000 (16:23 +0000)
committerRoy Marples <roy@marples.name>
Mon, 25 Apr 2016 16:23:37 +0000 (16:23 +0000)
ipv4.c

diff --git a/ipv4.c b/ipv4.c
index 9a6e39597cd8b48337d59c7d62af0c8f473beaab..1ccdaa97e1f86d47710e7f88ad5d4c068a7da5d3 100644 (file)
--- a/ipv4.c
+++ b/ipv4.c
@@ -1162,13 +1162,11 @@ ipv4_applyaddr(void *arg)
                }
        }
 
-       /* If the netmask or broadcast is different, delete the addresss */
+       /* If the netmask or broadcast is different, re-add the addresss */
        ap = ipv4_iffindaddr(ifp, &lease->addr, NULL);
-       if (ap && (ap->net.s_addr != lease->net.s_addr ||
-           ap->brd.s_addr != lease->brd.s_addr))
-               ipv4_deladdr(ifp, &ap->addr, &ap->net, 0);
-
-       if (ipv4_iffindaddr(ifp, &lease->addr, &lease->net))
+       if (ap &&
+           ap->net.s_addr == lease->net.s_addr &&
+           ap->brd.s_addr == lease->brd.s_addr)
                logger(ifp->ctx, LOG_DEBUG,
                    "%s: IP address %s/%d already exists",
                    ifp->name, inet_ntoa(lease->addr),
@@ -1244,7 +1242,7 @@ ipv4_handleifa(struct dhcpcd_ctx *ctx,
                return;
        }
 
-       ap = ipv4_iffindaddr(ifp, addr, net);
+       ap = ipv4_iffindaddr(ifp, addr, NULL);
        if (cmd == RTM_NEWADDR) {
                if (ap == NULL) {
                        if ((ap = malloc(sizeof(*ap))) == NULL) {
@@ -1253,10 +1251,10 @@ ipv4_handleifa(struct dhcpcd_ctx *ctx,
                        }
                        ap->iface = ifp;
                        ap->addr = *addr;
-                       ap->net = *net;
-                       ap->brd = *brd;
                        TAILQ_INSERT_TAIL(&state->addrs, ap, next);
                }
+               ap->net = *net;
+               ap->brd = *brd;
                ap->addr_flags = flags;
        } else if (cmd == RTM_DELADDR) {
                if (ap) {