[systemd-commits] src/network

Tom Gundersen tomegun at kemper.freedesktop.org
Thu Nov 21 12:02:25 PST 2013


 src/network/networkd-link.c    |   19 ++++++++-----------
 src/network/networkd-network.c |    4 ++--
 2 files changed, 10 insertions(+), 13 deletions(-)

New commits:
commit 5a3eb5a77d7c491a31818c4dfdcf8fd7dcaaadb2
Author: Tom Gundersen <teg at jklm.no>
Date:   Thu Nov 21 21:04:04 2013 +0100

    networkd: make sure Network and Link can always be freed
    
    Also, don't fail a link just because we can't find its MAC address.

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index c034722..b93df63 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -39,22 +39,19 @@ int link_new(Manager *manager, struct udev_device *device, Link **ret) {
         if (!link)
                 return -ENOMEM;
 
+        link->manager = manager;
+        link->state = _LINK_STATE_INVALID;
+
         link->ifindex = udev_device_get_ifindex(device);
         if (link->ifindex <= 0)
                 return -EINVAL;
 
         mac = udev_device_get_sysattr_value(device, "address");
-        if (!mac)
-                return -EINVAL;
-
-        mac_addr = ether_aton(mac);
-        if (!mac_addr)
-                return -EINVAL;
-
-        memcpy(&link->mac, mac_addr, sizeof(struct ether_addr));
-
-        link->manager = manager;
-        link->state = _LINK_STATE_INVALID;
+        if (mac) {
+                mac_addr = ether_aton(mac);
+                if (mac_addr)
+                        memcpy(&link->mac, mac_addr, sizeof(struct ether_addr));
+        }
 
         r = hashmap_put(manager->links, &link->ifindex, link);
         if (r < 0)
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index d4239ab..7be9645 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -42,6 +42,8 @@ static int network_load_one(Manager *manager, const char *filename) {
         if (!network)
                 return log_oom();
 
+        network->manager = manager;
+
         LIST_HEAD_INIT(network->addresses);
 
         r = config_parse(NULL, filename, file, "Match\0Network\0", config_item_perf_lookup,
@@ -56,8 +58,6 @@ static int network_load_one(Manager *manager, const char *filename) {
         if (!network->filename)
                 return log_oom();
 
-        network->manager = manager;
-
         LIST_PREPEND(networks, manager->networks, network);
         network = NULL;
 



More information about the systemd-commits mailing list