networkd: integrate LLDP
This patch integrates LLDP with networkd. Example conf: file : lldp.network [Match] Name=em1 [Network] LLDP=yes
This commit is contained in:
parent
ad1ad5c8e3
commit
ce43e48446
|
@ -257,6 +257,13 @@
|
||||||
announcement. Defaults to true.</para>
|
announcement. Defaults to true.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>LLDP=</varname></term>
|
||||||
|
<listitem>
|
||||||
|
<para>A boolean. When true, enables LLDP link receive support.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>Address=</varname></term>
|
<term><varname>Address=</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
|
@ -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) \
|
#define FLAG_STRING(string, flag, old, new) \
|
||||||
(((old ^ new) & flag) \
|
(((old ^ new) & flag) \
|
||||||
? ((old & flag) ? (" -" string) : (" +" string)) \
|
? ((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)) {
|
if (link_has_carrier(link)) {
|
||||||
r = link_acquire_conf(link);
|
r = link_acquire_conf(link);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
|
|
@ -91,6 +91,8 @@ struct Link {
|
||||||
|
|
||||||
sd_icmp6_nd *icmp6_router_discovery;
|
sd_icmp6_nd *icmp6_router_discovery;
|
||||||
sd_dhcp6_client *dhcp6_client;
|
sd_dhcp6_client *dhcp6_client;
|
||||||
|
|
||||||
|
sd_lldp *lldp;
|
||||||
};
|
};
|
||||||
|
|
||||||
Link *link_unref(Link *link);
|
Link *link_unref(Link *link);
|
||||||
|
|
|
@ -37,6 +37,7 @@ Network.DHCP, config_parse_dhcp, 0,
|
||||||
Network.DHCPServer, config_parse_bool, 0, offsetof(Network, dhcp_server)
|
Network.DHCPServer, config_parse_bool, 0, offsetof(Network, dhcp_server)
|
||||||
Network.IPv4LL, config_parse_bool, 0, offsetof(Network, ipv4ll)
|
Network.IPv4LL, config_parse_bool, 0, offsetof(Network, ipv4ll)
|
||||||
Network.IPv4LLRoute, config_parse_bool, 0, offsetof(Network, ipv4ll_route)
|
Network.IPv4LLRoute, config_parse_bool, 0, offsetof(Network, ipv4ll_route)
|
||||||
|
Network.LLDP, config_parse_bool, 0, offsetof(Network, lldp)
|
||||||
Network.Address, config_parse_address, 0, 0
|
Network.Address, config_parse_address, 0, 0
|
||||||
Network.Gateway, config_parse_gateway, 0, 0
|
Network.Gateway, config_parse_gateway, 0, 0
|
||||||
Network.Domains, config_parse_domains, 0, offsetof(Network, domains)
|
Network.Domains, config_parse_domains, 0, offsetof(Network, domains)
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "sd-icmp6-nd.h"
|
#include "sd-icmp6-nd.h"
|
||||||
#include "sd-dhcp6-client.h"
|
#include "sd-dhcp6-client.h"
|
||||||
#include "udev.h"
|
#include "udev.h"
|
||||||
|
#include "sd-lldp.h"
|
||||||
|
|
||||||
#include "rtnl-util.h"
|
#include "rtnl-util.h"
|
||||||
#include "hashmap.h"
|
#include "hashmap.h"
|
||||||
|
@ -122,6 +123,8 @@ struct Network {
|
||||||
struct ether_addr *mac;
|
struct ether_addr *mac;
|
||||||
unsigned mtu;
|
unsigned mtu;
|
||||||
|
|
||||||
|
bool lldp;
|
||||||
|
|
||||||
LIST_HEAD(Address, static_addresses);
|
LIST_HEAD(Address, static_addresses);
|
||||||
LIST_HEAD(Route, static_routes);
|
LIST_HEAD(Route, static_routes);
|
||||||
LIST_HEAD(FdbEntry, static_fdb_entries);
|
LIST_HEAD(FdbEntry, static_fdb_entries);
|
||||||
|
|
Loading…
Reference in a new issue