network: do not set invalid MAC address for non-ethernet interface
This commit is contained in:
@@ -2192,7 +2192,7 @@ static int link_update_hardware_address(Link *link, sd_netlink_message *message)
|
||||
if (r < 0)
|
||||
return log_link_debug_errno(link, r, "Could not update MAC address for Router Advertisement: %m");
|
||||
|
||||
if (link->ndisc) {
|
||||
if (link->ndisc && link->hw_addr.length == ETH_ALEN) {
|
||||
r = sd_ndisc_set_mac(link->ndisc, &link->hw_addr.ether);
|
||||
if (r < 0)
|
||||
return log_link_debug_errno(link, r, "Could not update MAC for NDisc: %m");
|
||||
|
||||
@@ -1054,9 +1054,11 @@ static int ndisc_configure(Link *link) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_ndisc_set_mac(link->ndisc, &link->hw_addr.ether);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (link->hw_addr.length == ETH_ALEN) {
|
||||
r = sd_ndisc_set_mac(link->ndisc, &link->hw_addr.ether);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = sd_ndisc_set_ifindex(link->ndisc, link->ifindex);
|
||||
if (r < 0)
|
||||
|
||||
@@ -458,9 +458,11 @@ static int radv_configure(Link *link) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_radv_set_mac(link->radv, &link->hw_addr.ether);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (link->hw_addr.length == ETH_ALEN) {
|
||||
r = sd_radv_set_mac(link->radv, &link->hw_addr.ether);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = sd_radv_set_ifindex(link->radv, link->ifindex);
|
||||
if (r < 0)
|
||||
@@ -518,6 +520,9 @@ int radv_update_mac(Link *link) {
|
||||
if (!link->radv)
|
||||
return 0;
|
||||
|
||||
if (link->hw_addr.length != ETH_ALEN)
|
||||
return 0;
|
||||
|
||||
restart = sd_radv_is_running(link->radv);
|
||||
|
||||
r = sd_radv_stop(link->radv);
|
||||
|
||||
Reference in New Issue
Block a user