chiark / gitweb /
networkd: network - do reference counting on netdevs
authorTom Gundersen <teg@jklm.no>
Thu, 8 May 2014 17:28:17 +0000 (19:28 +0200)
committerTom Gundersen <teg@jklm.no>
Fri, 9 May 2014 12:41:27 +0000 (14:41 +0200)
src/network/networkd-network.c

index 4493359..a452096 100644 (file)
@@ -145,6 +145,7 @@ int network_load(Manager *manager) {
 }
 
 void network_free(Network *network) {
+        NetDev *netdev;
         Route *route;
         Address *address;
         Iterator i;
@@ -167,8 +168,16 @@ void network_free(Network *network) {
 
         set_free(network->dns);
 
+        netdev_unref(network->bridge);
+
+        netdev_unref(network->bond);
+
+        HASHMAP_FOREACH(netdev, network->vlans, i)
+                netdev_unref(netdev);
         hashmap_free(network->vlans);
 
+        HASHMAP_FOREACH(netdev, network->macvlans, i)
+                netdev_unref(netdev);
         hashmap_free(network->macvlans);
 
         while ((route = network->static_routes))
@@ -317,5 +326,7 @@ int config_parse_netdev(const char *unit,
                 assert_not_reached("Can not parse NetDev");
         }
 
+        netdev_ref(netdev);
+
         return 0;
 }