do not leak address and dfr proposals if an interface goes away
authorflorian <florian@openbsd.org>
Wed, 31 May 2017 07:30:32 +0000 (07:30 +0000)
committerflorian <florian@openbsd.org>
Wed, 31 May 2017 07:30:32 +0000 (07:30 +0000)
usr.sbin/slaacd/engine.c

index 6ecd6cb..c43bfc4 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: engine.c,v 1.36 2017/05/31 07:14:58 florian Exp $     */
+/*     $OpenBSD: engine.c,v 1.37 2017/05/31 07:30:32 florian Exp $     */
 
 /*
  * Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -847,6 +847,8 @@ remove_slaacd_iface(uint32_t if_index)
 {
        struct slaacd_iface     *iface, *tiface;
        struct radv             *ra;
+       struct address_proposal *addr_proposal;
+       struct dfr_proposal     *dfr_proposal;
 
        LIST_FOREACH_SAFE (iface, &slaacd_interfaces, entries, tiface) {
                if (iface->if_index == if_index) {
@@ -856,6 +858,19 @@ remove_slaacd_iface(uint32_t if_index)
                                LIST_REMOVE(ra, entries);
                                free_ra(ra);
                        }
+                       /* XXX inform netcfgd? */
+                       while(!LIST_EMPTY(&iface->addr_proposals)) {
+                               addr_proposal =
+                                   LIST_FIRST(&iface->addr_proposals);
+                               LIST_REMOVE(addr_proposal, entries);
+                               free(addr_proposal);
+                       }
+                       while(!LIST_EMPTY(&iface->dfr_proposals)) {
+                               dfr_proposal =
+                                   LIST_FIRST(&iface->dfr_proposals);
+                               LIST_REMOVE(dfr_proposal, entries);
+                               free(dfr_proposal);
+                       }
                        free(iface);
                        break;
                }