mirror of
https://github.com/systemd/systemd
synced 2024-07-24 11:44:41 +00:00
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.
This commit is contained in:
parent
279082ed49
commit
5388e103ea
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue