]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: check the size of hardware address before setting MAC address
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 12 Jun 2021 20:24:35 +0000 (05:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Jun 2021 11:42:50 +0000 (20:42 +0900)
Also, skip to set MAC address when the current address equals to the
requrested one.

src/network/networkd-setlink.c

index 478591b5bb5d41cebaaa0a90cb5bf62514df5d8a..ec9eac47520c4746dbd1b10283a88b28561fa195 100644 (file)
@@ -680,6 +680,16 @@ int link_request_to_set_mac(Link *link) {
         if (!link->network->mac)
                 return 0;
 
+        if (link->hw_addr.length != sizeof(struct ether_addr)) {
+                /* Note that for now we only support changing hardware addresses on Ethernet. */
+                log_link_debug(link, "Size of the hardware address (%zu) does not match the size of MAC address (%zu), ignoring.",
+                               link->hw_addr.length, sizeof(struct ether_addr));
+                return 0;
+        }
+
+        if (ether_addr_equal(&link->hw_addr.ether, link->network->mac))
+                return 0;
+
         return link_request_set_link(link, SET_LINK_MAC, link_set_mac_handler, NULL);
 }