chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
networkd: integrate LLDP
[elogind.git]
/
src
/
network
/
networkd-link.c
diff --git
a/src/network/networkd-link.c
b/src/network/networkd-link.c
index 341ae88ec101569a848205666157d736455988ec..725e22b93f69bda768e7c28fe6e164cafe55b6c7 100644
(file)
--- 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;
}
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)) \
#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;
}
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;
}
return 0;
}
@@
-1194,6
+1229,16
@@
static int link_configure(Link *link) {
return r;
}
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)
if (link_has_carrier(link)) {
r = link_acquire_conf(link);
if (r < 0)