1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 07:51:21 +03:00

ether-addr-util: make hw_addr_is_null() return true also for all zero address

This fixes the following error:
---
systemd-networkd[1449490]: ip6tnl0: Saved hardware address: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
systemd-networkd[1449490]: ip6tnl0: Failed to manage link by its new hardware address, ignoring: File exists
---
This commit is contained in:
Yu Watanabe 2021-11-06 14:12:30 +09:00
parent 1f86a3fe52
commit de0f157984
3 changed files with 4 additions and 3 deletions

View File

@ -37,7 +37,8 @@ static inline bool hw_addr_equal(const struct hw_addr_data *a, const struct hw_a
return hw_addr_compare(a, b) == 0;
}
static inline bool hw_addr_is_null(const struct hw_addr_data *addr) {
return hw_addr_equal(addr, &HW_ADDR_NULL);
assert(addr);
return addr->length == 0 || memeqzero(addr->bytes, addr->length);
}
extern const struct hash_ops hw_addr_hash_ops;

View File

@ -553,7 +553,7 @@ static int decode_link(sd_netlink_message *m, LinkInfo *info, char **patterns, b
info->has_mac_address =
netlink_message_read_hw_addr(m, IFLA_ADDRESS, &info->hw_address) >= 0 &&
!hw_addr_is_null(&info->hw_address);
info->hw_address.length > 0;
info->has_permanent_mac_address =
ethtool_get_permanent_macaddr(NULL, info->name, &info->permanent_mac_address) >= 0 &&

View File

@ -2036,7 +2036,7 @@ static int link_update_hardware_address(Link *link, sd_netlink_message *message)
if (hw_addr_equal(&link->hw_addr, &addr))
return 0;
if (hw_addr_is_null(&link->hw_addr))
if (link->hw_addr.length == 0)
log_link_debug(link, "Saved hardware address: %s", HW_ADDR_TO_STR(&addr));
else {
log_link_debug(link, "Hardware address is changed: %s → %s",