summaryrefslogtreecommitdiff
path: root/src/network/networkd-link.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-02-03 15:44:12 +0100
committerTom Gundersen <teg@jklm.no>2015-02-03 22:20:38 +0100
commit9c0a72f961e00b0447767973e7117e131bea5b5d (patch)
tree7f717f0f0f0b47d09faff128558cef720f9b0acd /src/network/networkd-link.c
parent4cd552bc502077f2626b07b8aa0706c3fb6c7f56 (diff)
networkd: handle suspend events
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r--src/network/networkd-link.c68
1 files changed, 57 insertions, 11 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index a8d9bc0a13..22864bd403 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1656,6 +1656,57 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
return 0;
}
+static int link_carrier_gained(Link *link) {
+ int r;
+
+ assert(link);
+
+ if (link->network) {
+ r = link_acquire_conf(link);
+ if (r < 0) {
+ link_enter_failed(link);
+ return r;
+ }
+ }
+
+ return 0;
+}
+
+static int link_carrier_lost(Link *link) {
+ int r;
+
+ assert(link);
+
+ r = link_stop_clients(link);
+ if (r < 0) {
+ link_enter_failed(link);
+ return r;
+ }
+
+ return 0;
+}
+
+int link_carrier_reset(Link *link) {
+ int r;
+
+ assert(link);
+
+ if (link_has_carrier(link)) {
+ r = link_carrier_lost(link);
+ if (r < 0)
+ return r;
+
+ r = link_carrier_gained(link);
+ if (r < 0)
+ return r;
+
+ log_link_info(link, "reset carrier");
+ }
+
+ return 0;
+}
+
+
int link_update(Link *link, sd_rtnl_message *m) {
struct ether_addr mac;
const char *ifname;
@@ -1773,21 +1824,16 @@ int link_update(Link *link, sd_rtnl_message *m) {
if (carrier_gained) {
log_link_info(link, "gained carrier");
- if (link->network) {
- r = link_acquire_conf(link);
- if (r < 0) {
- link_enter_failed(link);
- return r;
- }
- }
+ r = link_carrier_gained(link);
+ if (r < 0)
+ return r;
} else if (carrier_lost) {
log_link_info(link, "lost carrier");
- r = link_stop_clients(link);
- if (r < 0) {
- link_enter_failed(link);
+ r = link_carrier_lost(link);
+ if (r < 0)
return r;
- }
+
}
return 0;