summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-20 22:35:02 +0100
committerLennart Poettering <lennart@poettering.net>2016-02-21 20:40:57 +0100
commit273eec24f5ce230a185c75c89d47c562a4bf64fb (patch)
treeff7721c92bdd337538cc33fed9e30711523752b2 /src/network
parent58fb367825b7ce72b466e24c422dd3eb6d5554f4 (diff)
networkd: rework when LLDP reception is enabled
Being on the link-layer LLDP is nothing we should turn on only when there's a link beat. Instead, turn it on, whenever the iface is UP regardless if there's a link beat or not. This closes the race between a link beat being available and us subscribing to LLDP as a result.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-link.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 32437d2195..aa8adf1eae 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -531,12 +531,6 @@ static int link_stop_clients(Link *link) {
r = log_link_warning_errno(link, k, "Could not stop IPv6 Router Discovery: %m");
}
- if (link->lldp) {
- k = sd_lldp_stop(link->lldp);
- if (k < 0)
- r = log_link_warning_errno(link, k, "Could not stop LLDP: %m");
- }
-
return r;
}
@@ -1374,16 +1368,6 @@ static int link_acquire_conf(Link *link) {
return log_link_warning_errno(link, r, "Could not acquire DHCPv4 lease: %m");
}
- if (link_lldp_enabled(link)) {
- assert(link->lldp);
-
- log_link_debug(link, "Starting LLDP");
-
- r = sd_lldp_start(link->lldp);
- if (r < 0)
- return log_link_warning_errno(link, r, "Could not start LLDP: %m");
- }
-
return 0;
}
@@ -2093,6 +2077,27 @@ static int link_drop_foreign_config(Link *link) {
return 0;
}
+static int link_update_lldp(Link *link) {
+ int r;
+
+ assert(link);
+
+ if (!link->lldp)
+ return 0;
+
+ if (link->flags & IFF_UP) {
+ r = sd_lldp_start(link->lldp);
+ if (r > 0)
+ log_link_debug(link, "Started LLDP.");
+ } else {
+ r = sd_lldp_stop(link->lldp);
+ if (r > 0)
+ log_link_debug(link, "Stopped LLDP.");
+ }
+
+ return r;
+}
+
static int link_configure(Link *link) {
int r;
@@ -2190,6 +2195,10 @@ static int link_configure(Link *link) {
r = sd_lldp_set_callback(link->lldp, lldp_handler, link);
if (r < 0)
return r;
+
+ r = link_update_lldp(link);
+ if (r < 0)
+ return r;
}
if (link_has_carrier(link)) {
@@ -2736,6 +2745,10 @@ int link_update(Link *link, sd_netlink_message *m) {
if (r < 0)
return r;
+ r = link_update_lldp(link);
+ if (r < 0)
+ return r;
+
carrier_gained = !had_carrier && link_has_carrier(link);
carrier_lost = had_carrier && !link_has_carrier(link);