]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ether-addr-util: make hw_addr_is_null() return true also for all zero address 21271/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 6 Nov 2021 05:12:30 +0000 (14:12 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 8 Nov 2021 23:20:51 +0000 (08:20 +0900)
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
---

src/basic/ether-addr-util.h
src/network/networkctl.c
src/network/networkd-link.c

index a7f42ccd1af1e908d924091133ce6daa328289e1..c5cfdb4233f62fa56daf60208f93316008a4c81e 100644 (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;
index 6dd05145c95c609624d4fb1dc699f29dcb5a376b..bb6e0f6b5b71d03ec77a12dd53f9b24de4d4fd69 100644 (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 &&
index ab2d42a4820cbf6cc431bd1ae49d6ecafd034dd0..5136a8820e3be7c7251cf8352fb459926c866dd2 100644 (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",