chiark / gitweb /
networkd: link - stop clients when failing
authorTom Gundersen <teg@jklm.no>
Tue, 22 Apr 2014 17:25:31 +0000 (19:25 +0200)
committerTom Gundersen <teg@jklm.no>
Tue, 22 Apr 2014 19:06:00 +0000 (21:06 +0200)
src/network/networkd-link.c

index 392665a4d16d32923cb709563d8a6cb1d0df305b..d9b38c1f6d1ecd1a59ba94b7ccd937596ed7373e 100644 (file)
@@ -151,6 +151,39 @@ static void link_enter_unmanaged(Link *link) {
         link_save(link);
 }
 
+static int link_stop_clients(Link *link) {
+        int r = 0, k;
+
+        assert(link);
+        assert(link->manager);
+        assert(link->manager->event);
+
+        if (!link->network)
+                return 0;
+
+        if (link->network->dhcp) {
+                assert(link->dhcp_client);
+
+                k = sd_dhcp_client_stop(link->dhcp_client);
+                if (k < 0) {
+                        log_warning_link(link, "Could not stop DHCPv4 client: %s", strerror(-r));
+                        r = k;
+                }
+        }
+
+        if (link->network->ipv4ll) {
+                assert(link->ipv4ll);
+
+                k = sd_ipv4ll_stop(link->ipv4ll);
+                if (k < 0) {
+                        log_warning_link(link, "Could not stop IPv4 link-local: %s", strerror(-r));
+                        r = k;
+                }
+        }
+
+        return r;
+}
+
 static void link_enter_failed(Link *link) {
         assert(link);
 
@@ -158,6 +191,8 @@ static void link_enter_failed(Link *link) {
 
         link->state = LINK_STATE_FAILED;
 
+        link_stop_clients(link);
+
         link_save(link);
 }