1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 14:55:37 +03:00

network: start/stop LLDP client on carrier gained/lost

Then, link_acquire_dynamic_conf() matches link_stop_engines().
Previously, LLDP client is started on interface is up, and stopped
on both down and carrier loss.
This commit is contained in:
Yu Watanabe 2021-06-12 12:26:37 +09:00
parent d09a179e69
commit f85499108f
3 changed files with 6 additions and 34 deletions

View File

@ -690,6 +690,12 @@ static int link_acquire_dynamic_conf(Link *link) {
if (r < 0)
return log_link_warning_errno(link, r, "Failed to start LLDP transmission: %m");
if (link->lldp) {
r = sd_lldp_start(link->lldp);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to start LLDP client: %m");
}
return 0;
}
@ -1986,10 +1992,6 @@ static int link_update_flags(Link *link, sd_netlink_message *message) {
return r;
}
r = link_update_lldp(link);
if (r < 0)
return r;
if (!had_carrier && link_has_carrier(link)) {
log_link_info(link, "Gained carrier");

View File

@ -103,38 +103,9 @@ int link_lldp_rx_configure(Link *link) {
if (r < 0)
return r;
r = link_update_lldp(link);
if (r < 0)
return r;
return 0;
}
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)
return log_link_warning_errno(link, r, "Failed to start LLDP: %m");
if (r > 0)
log_link_debug(link, "Started LLDP.");
} else {
r = sd_lldp_stop(link->lldp);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to stop LLDP: %m");
if (r > 0)
log_link_debug(link, "Stopped LLDP.");
}
return r;
}
int link_lldp_save(Link *link) {
_cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;

View File

@ -14,7 +14,6 @@ typedef enum LLDPMode {
} LLDPMode;
int link_lldp_rx_configure(Link *link);
int link_update_lldp(Link *link);
int link_lldp_save(Link *link);
const char* lldp_mode_to_string(LLDPMode m) _const_;