summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-link.c55
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;