networkd: enable LLDP only on ethernet

This commit is contained in:
Lennart Poettering 2016-02-18 22:49:02 +01:00
parent 1c4a6088ed
commit b710e6b68d
2 changed files with 15 additions and 7 deletions

View File

@ -89,9 +89,14 @@ bool link_ipv6ll_enabled(Link *link) {
}
bool link_lldp_enabled(Link *link) {
assert(link);
if (link->flags & IFF_LOOPBACK)
return false;
if (link->iftype != ARPHRD_ETHER)
return false;
if (!link->network)
return false;
@ -300,6 +305,7 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
uint16_t type;
const char *ifname;
int r, ifindex;
unsigned short iftype;
assert(manager);
assert(message);
@ -317,6 +323,10 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
else if (ifindex <= 0)
return -EINVAL;
r = sd_rtnl_message_link_get_type(message, &iftype);
if (r < 0)
return r;
r = sd_netlink_message_read_string(message, IFLA_IFNAME, &ifname);
if (r < 0)
return r;
@ -330,6 +340,7 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
link->state = LINK_STATE_PENDING;
link->rtnl_extended_attrs = true;
link->ifindex = ifindex;
link->iftype = iftype;
link->ifname = strdup(ifname);
if (!link->ifname)
return -ENOMEM;
@ -338,22 +349,18 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
if (r < 0)
log_link_debug(link, "MAC address not found for new device, continuing without");
r = asprintf(&link->state_file, "/run/systemd/netif/links/%d",
link->ifindex);
r = asprintf(&link->state_file, "/run/systemd/netif/links/%d", link->ifindex);
if (r < 0)
return -ENOMEM;
r = asprintf(&link->lease_file, "/run/systemd/netif/leases/%d",
link->ifindex);
r = asprintf(&link->lease_file, "/run/systemd/netif/leases/%d", link->ifindex);
if (r < 0)
return -ENOMEM;
r = asprintf(&link->lldp_file, "/run/systemd/netif/lldp/%d",
link->ifindex);
r = asprintf(&link->lldp_file, "/run/systemd/netif/lldp/%d", link->ifindex);
if (r < 0)
return -ENOMEM;
r = hashmap_ensure_allocated(&manager->links, NULL);
if (r < 0)
return r;

View File

@ -65,6 +65,7 @@ struct Link {
int ifindex;
char *ifname;
unsigned short iftype;
char *state_file;
struct ether_addr mac;
struct in6_addr ipv6ll_address;