summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-setlink.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-06-12 22:24:35 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-06-14 13:42:50 +0200
commit5388e103eaf2a31c0020ff8b8d9442426aee40ab (patch)
tree3300a096c24e567414cbfb1b92f5d7f2914dd51b /src/network/networkd-setlink.c
parentAdd a network timeout option to journal-upload (diff)
downloadsystemd-5388e103eaf2a31c0020ff8b8d9442426aee40ab.tar.xz
systemd-5388e103eaf2a31c0020ff8b8d9442426aee40ab.zip
network: check the size of hardware address before setting MAC address
Also, skip to set MAC address when the current address equals to the requrested one.
Diffstat (limited to '')
-rw-r--r--src/network/networkd-setlink.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/network/networkd-setlink.c b/src/network/networkd-setlink.c
index 478591b5bb..ec9eac4752 100644
--- a/src/network/networkd-setlink.c
+++ b/src/network/networkd-setlink.c
@@ -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);
}