1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-05 06:52:22 +03:00

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.
This commit is contained in:
Lennart Poettering 2016-02-20 22:35:02 +01:00
parent 58fb367825
commit 273eec24f5

View File

@ -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"); 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; 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"); 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; return 0;
} }
@ -2093,6 +2077,27 @@ static int link_drop_foreign_config(Link *link) {
return 0; 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) { static int link_configure(Link *link) {
int r; int r;
@ -2190,6 +2195,10 @@ static int link_configure(Link *link) {
r = sd_lldp_set_callback(link->lldp, lldp_handler, link); r = sd_lldp_set_callback(link->lldp, lldp_handler, link);
if (r < 0) if (r < 0)
return r; return r;
r = link_update_lldp(link);
if (r < 0)
return r;
} }
if (link_has_carrier(link)) { if (link_has_carrier(link)) {
@ -2736,6 +2745,10 @@ int link_update(Link *link, sd_netlink_message *m) {
if (r < 0) if (r < 0)
return r; return r;
r = link_update_lldp(link);
if (r < 0)
return r;
carrier_gained = !had_carrier && link_has_carrier(link); carrier_gained = !had_carrier && link_has_carrier(link);
carrier_lost = had_carrier && !link_has_carrier(link); carrier_lost = had_carrier && !link_has_carrier(link);