summaryrefslogtreecommitdiff
path: root/src/network/networkd-link.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r--src/network/networkd-link.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 341ae88ec1..725e22b93f 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -75,6 +75,19 @@ static bool link_ipv4ll_enabled(Link *link) {
return link->network->ipv4ll;
}
+static bool link_lldp_enabled(Link *link) {
+ if (link->flags & IFF_LOOPBACK)
+ return false;
+
+ if (!link->network)
+ return false;
+
+ if(link->network->bridge)
+ return false;
+
+ return link->network->lldp;
+}
+
#define FLAG_STRING(string, flag, old, new) \
(((old ^ new) & flag) \
? ((old & flag) ? (" -" string) : (" +" string)) \
@@ -364,6 +377,16 @@ static int link_stop_clients(Link *link) {
}
}
+ if (link->lldp) {
+
+ k = sd_lldp_stop(link->lldp);
+ if (k < 0) {
+ log_link_warning(link, "Could not stop LLDP : %s",
+ strerror(-r));
+ r = k;
+ }
+ }
+
return r;
}
@@ -919,6 +942,18 @@ static int link_acquire_conf(Link *link) {
}
}
+ if (link_lldp_enabled(link)) {
+ assert(link->lldp);
+
+ log_link_debug(link, "Starting LLDP");
+
+ r = sd_lldp_start(link->lldp);
+ if (r < 0) {
+ log_link_warning(link, "could not start LLDP ");
+ return r;
+ }
+ }
+
return 0;
}
@@ -1194,6 +1229,16 @@ static int link_configure(Link *link) {
return r;
}
+ if (link_lldp_enabled(link)) {
+ r = sd_lldp_new(link->ifindex, link->ifname, &link->mac, &link->lldp);
+ if (r < 0)
+ return r;
+
+ r = sd_lldp_attach_event(link->lldp, NULL, 0);
+ if (r < 0)
+ return r;
+ }
+
if (link_has_carrier(link)) {
r = link_acquire_conf(link);
if (r < 0)