chiark / gitweb /
nspawn: fix getent fallback
[elogind.git] / src / network / networkd-network.c
index 2e68bec2e745a520b24aa105e1ade33092d4efa1..6437ff4230f502a8a4d410971a764bdb5add4068 100644 (file)
@@ -53,10 +53,14 @@ static int network_load_one(Manager *manager, const char *filename) {
         LIST_HEAD_INIT(network->static_addresses);
         LIST_HEAD_INIT(network->static_routes);
 
-        network->vlans = hashmap_new(uint64_hash_func, uint64_compare_func);
+        network->vlans = hashmap_new(string_hash_func, string_compare_func);
         if (!network->vlans)
                 return log_oom();
 
+        network->macvlans = hashmap_new(uint64_hash_func, uint64_compare_func);
+        if (!network->macvlans)
+                return log_oom();
+
         network->addresses_by_section = hashmap_new(uint64_hash_func, uint64_compare_func);
         if (!network->addresses_by_section)
                 return log_oom();
@@ -150,6 +154,8 @@ void network_free(Network *network) {
 
         hashmap_free(network->vlans);
 
+        hashmap_free(network->macvlans);
+
         while ((route = network->static_routes))
                 route_free(route);
 
@@ -181,6 +187,7 @@ int network_get(Manager *manager, struct udev_device *device, Network **ret) {
                                         udev_device_get_sysattr_value(device, "address"),
                                         udev_device_get_property_value(device, "ID_PATH"),
                                         udev_device_get_driver(udev_device_get_parent(device)),
+                                        udev_device_get_property_value(device, "ID_NET_DRIVER"),
                                         udev_device_get_devtype(device),
                                         udev_device_get_sysname(device))) {
                         log_debug("%s: found matching network '%s'",
@@ -201,10 +208,6 @@ int network_apply(Manager *manager, Network *network, Link *link) {
 
         link->network = network;
 
-        r = link_configure(link);
-        if (r < 0)
-                return r;
-
         if (network->dns) {
                 r = manager_update_resolv_conf(manager);
                 if (r < 0)
@@ -329,3 +332,45 @@ int config_parse_vlan(const char *unit,
 
         return 0;
 }
+
+int config_parse_macvlan(const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+        Network *network = userdata;
+        NetDev *netdev;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = netdev_get(network->manager, rvalue, &netdev);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+                           "MACVLAN is invalid, ignoring assignment: %s", rvalue);
+                return 0;
+        }
+
+        if (netdev->kind != NETDEV_KIND_MACVLAN) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+                           "NetDev is not a MACVLAN, ignoring assignment: %s", rvalue);
+                return 0;
+        }
+
+        r = hashmap_put(network->macvlans, netdev->name, netdev);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+                           "Can not add MACVLAN to network: %s", rvalue);
+                return 0;
+        }
+
+        return 0;
+}