summaryrefslogtreecommitdiff
path: root/src/network/networkd-link.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-04-22 19:25:31 +0200
committerTom Gundersen <teg@jklm.no>2014-04-22 21:06:00 +0200
commit111bb8f93a2e936fc62fc2f34350b85c5f0000c8 (patch)
tree0d799657b5d570c3bf874ca6feed1fb91181a949 /src/network/networkd-link.c
parent0fbedd1fdc98ab6d0a29d34b00079afda01b99c1 (diff)
networkd: link - stop clients when failing
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r--src/network/networkd-link.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 392665a4d1..d9b38c1f6d 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -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);
}