]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Free other ARP states in a better way.
authorRoy Marples <roy@marples.name>
Fri, 24 Oct 2014 19:30:24 +0000 (19:30 +0000)
committerRoy Marples <roy@marples.name>
Fri, 24 Oct 2014 19:30:24 +0000 (19:30 +0000)
arp.c
arp.h
dhcp.c

diff --git a/arp.c b/arp.c
index f4f644798ffb771a759051c62ea9dbf8479e99b6..fbc6a469746eaeebaf9df2a26ab6123f0f0300cc 100644 (file)
--- a/arp.c
+++ b/arp.c
@@ -314,12 +314,26 @@ arp_free(struct arp_state *astate)
        struct dhcp_state *state;
 
        if (astate) {
+               eloop_timeout_delete(astate->iface->ctx->eloop, NULL, astate);
                state = D_STATE(astate->iface);
                TAILQ_REMOVE(&state->arp_states, astate, next);
                free(astate);
        }
 }
 
+void
+arp_free_but(struct arp_state *astate)
+{
+       struct arp_state *p, *n;
+       struct dhcp_state *state;
+
+       state = D_STATE(astate->iface);
+       TAILQ_FOREACH_SAFE(p, &state->arp_states, next, n) {
+               if (p != astate)
+                       arp_free(p);
+       }
+}
+
 void
 arp_close(struct interface *ifp)
 {
@@ -336,8 +350,6 @@ arp_close(struct interface *ifp)
        }
 
        while ((astate = TAILQ_FIRST(&state->arp_states))) {
-               TAILQ_REMOVE(&state->arp_states, astate, next);
-               eloop_timeout_delete(ifp->ctx->eloop, NULL, astate);
-               free(astate);
+               arp_free(astate);
        }
 }
diff --git a/arp.h b/arp.h
index ccea36038db2627bff3f81a812a300f29e5a2cb3..9666c47f84b1b99ff32356a9c0b95689f99f7392 100644 (file)
--- a/arp.h
+++ b/arp.h
@@ -71,5 +71,6 @@ void arp_probe(struct arp_state *);
 struct arp_state *arp_new(struct interface *);
 void arp_cancel(struct arp_state *);
 void arp_free(struct arp_state *);
+void arp_free_but(struct arp_state *);
 void arp_close(struct interface *);
 #endif
diff --git a/dhcp.c b/dhcp.c
index d2346108046a8bec5e178519b11339dc19336dfe..aa1d06859afd5ac9321309520480d8ac82184659 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -1972,10 +1972,7 @@ applyaddr:
                        }
                        if (astate) {
                                arp_announce(astate);
-                               if (astate != state->arp_ipv4ll) {
-                                       arp_free(state->arp_ipv4ll);
-                                       state->arp_ipv4ll = NULL;
-                               }
+                               arp_free_but(astate);
                        }
                } else if (!ipv4ll)
                        arp_close(ifp);