diff options
author | Tom Gundersen <teg@jklm.no> | 2014-04-20 19:49:00 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-04-20 19:54:35 +0200 |
commit | 57bd6899b35b84d1f23809133ae45d29a87b2eaa (patch) | |
tree | 461fa2a3ed8d70966ea56c739ecc63838a035c5d /src | |
parent | 4bb40e8125ae0a83a13cb8e020950975eeeb1ad2 (diff) |
networkd: link - add explicit unmanaged state
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-link.c | 20 | ||||
-rw-r--r-- | src/network/networkd.h | 1 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index cf22778b42..392665a4d1 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -141,6 +141,16 @@ static int link_enter_configured(Link *link) { return 0; } +static void link_enter_unmanaged(Link *link) { + assert(link); + + log_info_link(link, "unmanaged"); + + link->state = LINK_STATE_UNMANAGED; + + link_save(link); +} + static void link_enter_failed(Link *link) { assert(link); @@ -1471,8 +1481,11 @@ int link_initialized(Link *link, struct udev_device *device) { log_debug_link(link, "link initialized"); r = network_get(link->manager, device, link->ifname, &link->mac, &network); - if (r < 0) - return r == -ENOENT ? 0 : r; + if (r == -ENOENT) { + link_enter_unmanaged(link); + return 0; + } else if (r < 0) + return r; r = network_apply(link->manager, network, link); if (r < 0) @@ -1541,7 +1554,7 @@ int link_update(Link *link, sd_rtnl_message *m) { assert(link->ifname); assert(m); - if (link->state == LINK_STATE_FAILED) + if (link->state == LINK_STATE_FAILED || link->state == LINK_STATE_UNMANAGED) return 0; r = sd_rtnl_message_read_string(m, IFLA_IFNAME, &ifname); @@ -1667,6 +1680,7 @@ static const char* const link_state_table[_LINK_STATE_MAX] = { [LINK_STATE_SETTING_ADDRESSES] = "configuring", [LINK_STATE_SETTING_ROUTES] = "configuring", [LINK_STATE_CONFIGURED] = "configured", + [LINK_STATE_UNMANAGED] = "unmanaged", [LINK_STATE_FAILED] = "failed", }; diff --git a/src/network/networkd.h b/src/network/networkd.h index 4a62fb8396..f481ddec5c 100644 --- a/src/network/networkd.h +++ b/src/network/networkd.h @@ -190,6 +190,7 @@ typedef enum LinkState { LINK_STATE_SETTING_ADDRESSES, LINK_STATE_SETTING_ROUTES, LINK_STATE_CONFIGURED, + LINK_STATE_UNMANAGED, LINK_STATE_FAILED, _LINK_STATE_MAX, _LINK_STATE_INVALID = -1 |