]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add ipv6_freedrop, similar to dhcp6_freedrop so we can easily
authorRoy Marples <roy@marples.name>
Tue, 20 Jan 2015 10:55:04 +0000 (10:55 +0000)
committerRoy Marples <roy@marples.name>
Tue, 20 Jan 2015 10:55:04 +0000 (10:55 +0000)
drop and free or just free IPv6 temporary addresses.

dhcpcd.c
ipv6.c
ipv6.h

index 0c1a8867df6139f90140b3e40125196c3ee68992..be3a5e6ca22493d1f02ee568f5c2fef4cd7b2a89 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -317,6 +317,7 @@ stop_interface(struct interface *ifp)
 
        dhcp6_drop(ifp, NULL);
        ipv6nd_drop(ifp);
+       ipv6_drop(ifp);
        dhcp_drop(ifp, "STOP");
        arp_close(ifp);
        if (ifp->options->options & DHCPCD_DEPARTED)
@@ -601,8 +602,8 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags,
                        ifp->carrier = LINK_DOWN;
                        script_runreason(ifp, "NOCARRIER");
                        dhcp6_drop(ifp, "EXPIRE6");
-                       ipv6_drop(ifp);
                        ipv6nd_drop(ifp);
+                       ipv6_drop(ifp);
                        dhcp_drop(ifp, "EXPIRE");
                        arp_close(ifp);
                }
diff --git a/ipv6.c b/ipv6.c
index f33079363dfbceb4af797f6bed997c2136558a97..ebd3e626a861a242c98658d3c0167cca162331a1 100644 (file)
--- a/ipv6.c
+++ b/ipv6.c
@@ -1066,22 +1066,6 @@ ipv6_addlinklocalcallback(struct interface *ifp,
        return 0;
 }
 
-void
-ipv6_drop(struct interface *ifp)
-{
-       struct ipv6_state *state;
-       struct ll_callback *cb;
-
-       state = IPV6_STATE(ifp);
-       if (state) {
-               while ((cb = TAILQ_FIRST(&state->ll_callbacks))) {
-                       TAILQ_REMOVE(&state->ll_callbacks, cb, next);
-                       free(cb);
-               }
-               ipv6_freedrop_addrs(&state->addrs, 2, NULL);
-       }
-}
-
 static struct ipv6_addr *
 ipv6_newlinklocal(struct interface *ifp)
 {
@@ -1244,19 +1228,19 @@ ipv6_start(struct interface *ifp)
 }
 
 void
-ipv6_free(struct interface *ifp)
+ipv6_freedrop(struct interface *ifp, int drop)
 {
        struct ipv6_state *state;
-       struct ipv6_addr *ap;
+       struct ll_callback *cb;
 
        if (ifp) {
-               ipv6_drop(ifp);
                state = IPV6_STATE(ifp);
                if (state) {
-                       while ((ap = TAILQ_FIRST(&state->addrs))) {
-                               TAILQ_REMOVE(&state->addrs, ap, next);
-                               free(ap);
+                       while ((cb = TAILQ_FIRST(&state->ll_callbacks))) {
+                               TAILQ_REMOVE(&state->ll_callbacks, cb, next);
+                               free(cb);
                        }
+                       ipv6_freedrop_addrs(&state->addrs, drop ? 2 : 0, NULL);
                        free(state);
                        ifp->if_data[IF_DATA_IPV6] = NULL;
                        eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
diff --git a/ipv6.h b/ipv6.h
index d910c6eb851e09e9d6e410930267d741f24c81b4..5b480f45b4ce3e475644bdadfe622b38a09978eb 100644 (file)
--- a/ipv6.h
+++ b/ipv6.h
@@ -235,7 +235,9 @@ struct ipv6_addr *ipv6_findaddr(struct dhcpcd_ctx *,
     const struct in6_addr *, short);
 #define ipv6_linklocal(ifp) (ipv6_iffindaddr((ifp), NULL))
 int ipv6_addlinklocalcallback(struct interface *, void (*)(void *), void *);
-void ipv6_drop(struct interface *);
+void ipv6_freedrop(struct interface *, int);
+#define ipv6_free(ifp) ipv6_freedrop(ifp, 0)
+#define ipv6_drop(ifp) ipv6_freedrop(ifp, 2)
 
 #ifdef IPV6_MANAGETEMPADDR
 void ipv6_gentempifid(struct interface *);
@@ -250,7 +252,6 @@ void ipv6_addtempaddrs(struct interface *, const struct timeval *);
 #endif
 
 int ipv6_start(struct interface *);
-void ipv6_free(struct interface *);
 void ipv6_ctxfree(struct dhcpcd_ctx *);
 int ipv6_routedeleted(struct dhcpcd_ctx *, const struct rt6 *);
 int ipv6_removesubnet(struct interface *, struct ipv6_addr *);
@@ -261,6 +262,7 @@ void ipv6_buildroutes(struct dhcpcd_ctx *);
 #define ipv6_start(a) (-1)
 #define ipv6_free_ll_callbacks(a) {}
 #define ipv6_free(a) {}
+#define ipv6_drop(a) {}
 #define ipv6_ctxfree(a) {}
 #endif