diff options
author | Tom Gundersen <teg@jklm.no> | 2014-01-03 00:55:09 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-01-03 01:42:26 +0100 |
commit | 1746cf2ad70d95c36064686d4f9b07a80e3bae99 (patch) | |
tree | 98623c174f97febdcdba333b6d949e9991451308 /src/network | |
parent | b11d8d199334494d3434875e63856540cec7f8d1 (diff) |
networkd: add more asserts and ignore all events when link has failed
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-link.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index a59434019d..87f32f00a6 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -288,6 +288,11 @@ static int link_up_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { Link *link = userdata; int r; + assert(link); + + if (link->state == LINK_STATE_FAILED) + return 1; + r = sd_rtnl_message_get_errno(m); if (r < 0) { log_warning("%s: could not bring up interface: %s", @@ -295,6 +300,8 @@ static int link_up_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { link_enter_failed(link); } + log_debug("%s: brought up interface", link->ifname); + return 1; } @@ -342,12 +349,8 @@ static int link_bridge_joined(Link *link) { return r; } - if (!link->network->dhcp) { - r = link_enter_set_addresses(link); - if (r < 0) - link_enter_failed(link); - return r; - } + if (!link->network->dhcp) + return link_enter_set_addresses(link); return 0; } @@ -356,6 +359,7 @@ static int bridge_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { Link *link = userdata; int r; + assert(link); assert(link->state == LINK_STATE_JOINING_BRIDGE || link->state == LINK_STATE_FAILED); assert(link->network); @@ -406,6 +410,11 @@ static int link_get_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { Link *link = userdata; int r; + assert(link); + + if (link->state == LINK_STATE_FAILED) + return 1; + r = sd_rtnl_message_get_errno(m); if (r < 0) { log_warning("%s: could not get state: %s", @@ -413,6 +422,8 @@ static int link_get_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { link_enter_failed(link); } + log_debug("%s: got link state", link->ifname); + link_update(link, m); return 1; @@ -456,11 +467,7 @@ int link_configure(Link *link) { return r; } - r = link_enter_join_bridge(link); - if (r < 0) - return r; - - return 0; + return link_enter_join_bridge(link); } static int address_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { @@ -490,6 +497,8 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) { int prefixlen; int r; + assert(link); + if (link->state == LINK_STATE_FAILED) return; @@ -622,6 +631,9 @@ int link_update(Link *link, sd_rtnl_message *m) { assert(link->network); assert(m); + if (link->state == LINK_STATE_FAILED) + return 0; + r = sd_rtnl_message_link_get_flags(m, &flags); if (r < 0) { log_warning("%s: could not get link flags", link->ifname); @@ -657,7 +669,7 @@ int link_update(Link *link, sd_rtnl_message *m) { link->flags = flags; - log_debug("%s: updated state", link->ifname); + log_debug("%s: updated link state", link->ifname); return 0; } |