From 111bb8f93a2e936fc62fc2f34350b85c5f0000c8 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 22 Apr 2014 19:25:31 +0200 Subject: [PATCH] networkd: link - stop clients when failing --- src/network/networkd-link.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 392665a4d16..d9b38c1f6d1 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); }