diff options
author | Tom Gundersen <teg@jklm.no> | 2014-03-05 11:53:26 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-03-05 11:53:29 +0100 |
commit | 69629de9c820dd41fffb1bf9b69d6d5b319c19c9 (patch) | |
tree | a53833db7bca9c4ba5723f6e5a85778a33fea382 /src | |
parent | 3b35ade3fd015482a450fe20edb7c7b7ccbbb803 (diff) |
networkd: listen to changes to the MAC address
Bridges will change their MAC address when other devices are enslaved. We need
the correct MAC address to acquire a DHCP lease, so take note of it whenever
it changes.
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-link.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 61e257c1d5..416eb56483 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1345,11 +1345,32 @@ int link_update(Link *link, sd_rtnl_message *m) { } while (sd_rtnl_message_read(m, &type, &data) > 0) { - if (type == IFLA_MTU && link->network->dhcp && - link->network->dhcp_mtu && !link->original_mtu) { - link->original_mtu = *(uint16_t *) data; - log_debug_link(link, "saved original MTU: %" PRIu16, - link->original_mtu); + switch(type) { + case IFLA_MTU: + if (link->network->dhcp && link->network->dhcp_mtu && + !link->original_mtu) { + link->original_mtu = *(uint16_t *) data; + log_debug_link(link, "saved original MTU: %" + PRIu16, link->original_mtu); + } + + break; + case IFLA_ADDRESS: + if (memcmp(&link->mac.ether_addr_octet, &data, + ETH_ALEN)) { + memcpy(&link->mac, data, ETH_ALEN); + + log_debug_link(link, "updated MAC address: " + "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", + link->mac.ether_addr_octet[0], + link->mac.ether_addr_octet[1], + link->mac.ether_addr_octet[2], + link->mac.ether_addr_octet[3], + link->mac.ether_addr_octet[4], + link->mac.ether_addr_octet[5]); + } + + break; } } |