diff options
author | Tom Gundersen <teg@jklm.no> | 2014-01-03 16:20:10 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-01-03 16:20:10 +0100 |
commit | efbc88b8ed8a47c3e09f094f8dcb39422f855a01 (patch) | |
tree | 28c7ffe6bb3eb3007e3c63e37ebaae069825c7cc /src | |
parent | d0d311d62f5d922dba97f0023c068e2bf90e7803 (diff) |
networkd: improve link state change logging
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-link.c | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index b004936e53..f0fb0d93e6 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -450,33 +450,44 @@ static int link_update_flags(Link *link, unsigned flags) { if (link->state == LINK_STATE_FAILED) return 0; - if (link->flags & IFF_UP && !(flags & IFF_UP)) - log_info("%s: interface is down", link->ifname); - else if (!(link->flags & IFF_UP) && flags & IFF_UP) - log_info("%s: interface is up", link->ifname); - - if (link->flags & IFF_LOWER_UP && !(flags & IFF_LOWER_UP)) { - log_info("%s: disconnected", link->ifname); - - if (link->network->dhcp) { - r = sd_dhcp_client_stop(link->dhcp); - if (r < 0) { - link_enter_failed(link); - return r; + if (link->flags == flags) { + log_debug("%s: link status unchanged: %#x", link->ifname, flags); + return 0; + } + + if ((link->flags & IFF_UP) != (flags & IFF_UP)) { + if (flags & IFF_UP) + log_info("%s: power on", link->ifname); + else + log_info("%s: power off", link->ifname); + } + + if ((link->flags & IFF_LOWER_UP) != (flags & IFF_LOWER_UP)) { + if (flags & IFF_LOWER_UP) { + log_info("%s: carrier on", link->ifname); + + if (link->network->dhcp) { + r = link_acquire_conf(link); + if (r < 0) { + link_enter_failed(link); + return r; + } } - } - } else if (!(link->flags & IFF_LOWER_UP) && flags & IFF_LOWER_UP) { - log_info("%s: connected", link->ifname); - - if (link->network->dhcp) { - r = link_acquire_conf(link); - if (r < 0) { - link_enter_failed(link); - return r; + } else { + log_info("%s: carrier off", link->ifname); + + if (link->network->dhcp) { + r = sd_dhcp_client_stop(link->dhcp); + if (r < 0) { + link_enter_failed(link); + return r; + } } } } + log_debug("%s: link status updated: %#x -> %#x", link->ifname, link->flags, flags); + link->flags = flags; return 0; |