chiark / gitweb /
networkd: rewind rtnl message between passing it to functions
authorTom Gundersen <teg@jklm.no>
Mon, 31 Mar 2014 15:17:56 +0000 (17:17 +0200)
committerTom Gundersen <teg@jklm.no>
Mon, 31 Mar 2014 15:17:56 +0000 (17:17 +0200)
This makes updating link status on netdev links work again.

src/network/networkd-link.c
src/network/networkd-manager.c

index 752ecae2543132dde870511b22c73b95154d1162..973755a3e3f8e7caee31198c93c20456cd49641d 100644 (file)
@@ -1364,36 +1364,40 @@ int link_update(Link *link, sd_rtnl_message *m) {
         }
 
         r = sd_rtnl_message_read_ether_addr(m, IFLA_ADDRESS, &mac);
         }
 
         r = sd_rtnl_message_read_ether_addr(m, IFLA_ADDRESS, &mac);
-        if (r >= 0 && memcmp(&link->mac.ether_addr_octet, &mac.ether_addr_octet, ETH_ALEN)) {
+        if (r < 0)
+                log_debug_link(link, "Could not get MAC address: %s", strerror(-r));
+        else {
+                if (memcmp(link->mac.ether_addr_octet, mac.ether_addr_octet, ETH_ALEN)) {
 
 
-                memcpy(&link->mac.ether_addr_octet, &mac.ether_addr_octet, ETH_ALEN);
+                        memcpy(link->mac.ether_addr_octet, mac.ether_addr_octet, ETH_ALEN);
 
 
-                log_debug_link(link, "MAC address: "
-                               "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
-                                mac.ether_addr_octet[0],
-                                mac.ether_addr_octet[1],
-                                mac.ether_addr_octet[2],
-                                mac.ether_addr_octet[3],
-                                mac.ether_addr_octet[4],
-                                mac.ether_addr_octet[5]);
+                        log_debug_link(link, "MAC address: "
+                                       "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
+                                       mac.ether_addr_octet[0],
+                                       mac.ether_addr_octet[1],
+                                       mac.ether_addr_octet[2],
+                                       mac.ether_addr_octet[3],
+                                       mac.ether_addr_octet[4],
+                                       mac.ether_addr_octet[5]);
 
 
-                if (link->ipv4ll) {
-                        r = sd_ipv4ll_set_mac(link->ipv4ll, &link->mac);
-                        if (r < 0) {
-                                log_warning_link(link, "Could not update MAC "
-                                                 "address in IPv4LL client: %s",
-                                                 strerror(-r));
-                                return r;
+                        if (link->ipv4ll) {
+                                r = sd_ipv4ll_set_mac(link->ipv4ll, &link->mac);
+                                if (r < 0) {
+                                        log_warning_link(link, "Could not update MAC "
+                                                         "address in IPv4LL client: %s",
+                                                         strerror(-r));
+                                        return r;
+                                }
                         }
                         }
-                }
 
 
-                if (link->dhcp_client) {
-                        r = sd_dhcp_client_set_mac(link->dhcp_client, &link->mac);
-                        if (r < 0) {
-                                log_warning_link(link, "Could not update MAC "
-                                                 "address in DHCP client: %s",
-                                                 strerror(-r));
-                                return r;
+                        if (link->dhcp_client) {
+                                r = sd_dhcp_client_set_mac(link->dhcp_client, &link->mac);
+                                if (r < 0) {
+                                        log_warning_link(link, "Could not update MAC "
+                                                         "address in DHCP client: %s",
+                                                         strerror(-r));
+                                        return r;
+                                }
                         }
                 }
         }
                         }
                 }
         }
index ddbdabbff903ece3bbecde8fb76b87dbc09c243c..d903d0d60ed4dc02655a7512c4573d90428b759d 100644 (file)
@@ -323,8 +323,14 @@ static int manager_rtnl_process_link(sd_rtnl *rtnl, sd_rtnl_message *message, vo
                 NetDev *netdev;
 
                 r = netdev_get(m, name, &netdev);
                 NetDev *netdev;
 
                 r = netdev_get(m, name, &netdev);
-                if (r >= 0)
+                if (r >= 0) {
                         netdev_set_ifindex(netdev, message);
                         netdev_set_ifindex(netdev, message);
+                        r = sd_rtnl_message_rewind(message);
+                        if (r < 0) {
+                                log_debug("could not rewind rtnl message");
+                                return 0;
+                        }
+                }
         }
 
         r = link_get(m, ifindex, &link);
         }
 
         r = link_get(m, ifindex, &link);