networkd: enable LLDP only on ethernet
This commit is contained in:
parent
1c4a6088ed
commit
b710e6b68d
|
@ -89,9 +89,14 @@ bool link_ipv6ll_enabled(Link *link) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool link_lldp_enabled(Link *link) {
|
bool link_lldp_enabled(Link *link) {
|
||||||
|
assert(link);
|
||||||
|
|
||||||
if (link->flags & IFF_LOOPBACK)
|
if (link->flags & IFF_LOOPBACK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (link->iftype != ARPHRD_ETHER)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!link->network)
|
if (!link->network)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -300,6 +305,7 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
|
||||||
uint16_t type;
|
uint16_t type;
|
||||||
const char *ifname;
|
const char *ifname;
|
||||||
int r, ifindex;
|
int r, ifindex;
|
||||||
|
unsigned short iftype;
|
||||||
|
|
||||||
assert(manager);
|
assert(manager);
|
||||||
assert(message);
|
assert(message);
|
||||||
|
@ -317,6 +323,10 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
|
||||||
else if (ifindex <= 0)
|
else if (ifindex <= 0)
|
||||||
return -EINVAL;
|
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);
|
r = sd_netlink_message_read_string(message, IFLA_IFNAME, &ifname);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
@ -330,6 +340,7 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
|
||||||
link->state = LINK_STATE_PENDING;
|
link->state = LINK_STATE_PENDING;
|
||||||
link->rtnl_extended_attrs = true;
|
link->rtnl_extended_attrs = true;
|
||||||
link->ifindex = ifindex;
|
link->ifindex = ifindex;
|
||||||
|
link->iftype = iftype;
|
||||||
link->ifname = strdup(ifname);
|
link->ifname = strdup(ifname);
|
||||||
if (!link->ifname)
|
if (!link->ifname)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -338,22 +349,18 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_link_debug(link, "MAC address not found for new device, continuing without");
|
log_link_debug(link, "MAC address not found for new device, continuing without");
|
||||||
|
|
||||||
r = asprintf(&link->state_file, "/run/systemd/netif/links/%d",
|
r = asprintf(&link->state_file, "/run/systemd/netif/links/%d", link->ifindex);
|
||||||
link->ifindex);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = asprintf(&link->lease_file, "/run/systemd/netif/leases/%d",
|
r = asprintf(&link->lease_file, "/run/systemd/netif/leases/%d", link->ifindex);
|
||||||
link->ifindex);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
r = asprintf(&link->lldp_file, "/run/systemd/netif/lldp/%d",
|
r = asprintf(&link->lldp_file, "/run/systemd/netif/lldp/%d", link->ifindex);
|
||||||
link->ifindex);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
||||||
r = hashmap_ensure_allocated(&manager->links, NULL);
|
r = hashmap_ensure_allocated(&manager->links, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -65,6 +65,7 @@ struct Link {
|
||||||
|
|
||||||
int ifindex;
|
int ifindex;
|
||||||
char *ifname;
|
char *ifname;
|
||||||
|
unsigned short iftype;
|
||||||
char *state_file;
|
char *state_file;
|
||||||
struct ether_addr mac;
|
struct ether_addr mac;
|
||||||
struct in6_addr ipv6ll_address;
|
struct in6_addr ipv6ll_address;
|
||||||
|
|
Loading…
Reference in New Issue