mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-06 13:17:44 +03:00
network: read permanent hardware address from netlink message
The attribute was introduced by f74877a5457d34d604dba6dbbb13c4c05bac8b93 (v5.6), so, fallback to ethtool if failed.
This commit is contained in:
parent
ed9fa69f1c
commit
4fea97a61d
@ -2400,9 +2400,18 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
|
||||
if (r < 0)
|
||||
return log_link_debug_errno(link, r, "Failed to manage link by its interface name: %m");
|
||||
|
||||
r = ethtool_get_permanent_hw_addr(&manager->ethtool_fd, link->ifname, &link->permanent_hw_addr);
|
||||
if (r < 0)
|
||||
log_link_debug_errno(link, r, "Permanent hardware address not found, continuing without: %m");
|
||||
r = netlink_message_read_hw_addr(message, IFLA_PERM_ADDRESS, &link->permanent_hw_addr);
|
||||
if (r < 0) {
|
||||
if (r != -ENODATA)
|
||||
log_link_debug_errno(link, r, "Failed to read IFLA_PERM_ADDRESS attribute, ignoring: %m");
|
||||
|
||||
if (netlink_message_read_hw_addr(message, IFLA_ADDRESS, NULL) >= 0) {
|
||||
/* Fallback to ethtool, if the link has a hardware address. */
|
||||
r = ethtool_get_permanent_hw_addr(&manager->ethtool_fd, link->ifname, &link->permanent_hw_addr);
|
||||
if (r < 0)
|
||||
log_link_debug_errno(link, r, "Permanent hardware address not found, continuing without: %m");
|
||||
}
|
||||
}
|
||||
|
||||
r = ethtool_get_driver(&manager->ethtool_fd, link->ifname, &link->driver);
|
||||
if (r < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user