summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-03-07 17:34:38 +0100
committerTom Gundersen <teg@jklm.no>2014-03-07 17:39:04 +0100
commit9842de0d93dc895800a43ccf1d04e5174f0ffea8 (patch)
tree000f3188e7ca409c917f103a128772562dde0cac /src
parent4e9e7f1836b0c8f612f2beb3447d6144f9244d26 (diff)
networkd: use new rtnl_message_read() API
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-link.c46
1 files changed, 17 insertions, 29 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 416eb56483..785e8d5c9b 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1328,8 +1328,6 @@ int link_configure(Link *link) {
int link_update(Link *link, sd_rtnl_message *m) {
unsigned flags;
- void *data;
- uint16_t type;
int r;
assert(link);
@@ -1344,34 +1342,24 @@ int link_update(Link *link, sd_rtnl_message *m) {
return r;
}
- while (sd_rtnl_message_read(m, &type, &data) > 0) {
- 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]);
- }
+ if (link->network->dhcp && link->network->dhcp_mtu &&
+ !link->original_mtu) {
+ r = sd_rtnl_message_read_u16(m, IFLA_MTU, &link->original_mtu);
+ if (r >= 0)
+ log_debug_link(link, "saved original MTU: %"
+ PRIu16, link->original_mtu);
+ }
- break;
- }
+ r = sd_rtnl_message_read_ether_addr(m, IFLA_ADDRESS, &link->mac);
+ if (r >= 0) {
+ log_debug_link(link, "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]);
}
return link_update_flags(link, flags);