chiark / gitweb /
networkd: VLAN - allow multiple vlans to be created on a link
[elogind.git] / src / network / networkd-network.c
index 2a720349a07fd5395fa2c491ca52df251c69fe43..48131c1f090c1ea7af793a6c158d347771fb4aba 100644 (file)
@@ -53,6 +53,10 @@ 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);
+        if (!network->vlans)
+                return log_oom();
+
         network->addresses_by_section = hashmap_new(uint64_hash_func, uint64_compare_func);
         if (!network->addresses_by_section)
                 return log_oom();
@@ -84,12 +88,6 @@ static int network_load_one(Manager *manager, const char *filename) {
                                     "Ignoring", filename);
                         return 0;
                 }
-
-                if (route->dst_family && route->family != route->dst_family) {
-                        log_warning("Route section with conflicting Gateway and Destination address "
-                                    "family configured in %s. Ignoring", filename);
-                        return 0;
-                }
         }
 
         LIST_FOREACH(static_addresses, address, network->static_addresses) {
@@ -150,6 +148,8 @@ void network_free(Network *network) {
 
         address_free(network->dns);
 
+        hashmap_free(network->vlans);
+
         while ((route = network->static_routes))
                 route_free(route);
 
@@ -223,7 +223,7 @@ int config_parse_bridge(const char *unit,
                 void *data,
                 void *userdata) {
         Network *network = userdata;
-        Netdev *netdev;
+        NetDev *netdev;
         int r;
 
         assert(filename);
@@ -240,7 +240,7 @@ int config_parse_bridge(const char *unit,
 
         if (netdev->kind != NETDEV_KIND_BRIDGE) {
                 log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                           "Netdev is not a bridge, ignoring assignment: %s", rvalue);
+                           "NetDev is not a bridge, ignoring assignment: %s", rvalue);
                 return 0;
         }
 
@@ -260,7 +260,7 @@ int config_parse_bond(const char *unit,
                 void *data,
                 void *userdata) {
         Network *network = userdata;
-        Netdev *netdev;
+        NetDev *netdev;
         int r;
 
         assert(filename);
@@ -277,7 +277,7 @@ int config_parse_bond(const char *unit,
 
         if (netdev->kind != NETDEV_KIND_BOND) {
                 log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                           "Netdev is not a bond, ignoring assignment: %s", rvalue);
+                           "NetDev is not a bond, ignoring assignment: %s", rvalue);
                 return 0;
         }
 
@@ -297,7 +297,7 @@ int config_parse_vlan(const char *unit,
                 void *data,
                 void *userdata) {
         Network *network = userdata;
-        Netdev *netdev;
+        NetDev *netdev;
         int r;
 
         assert(filename);
@@ -314,11 +314,16 @@ int config_parse_vlan(const char *unit,
 
         if (netdev->kind != NETDEV_KIND_VLAN) {
                 log_syntax(unit, LOG_ERR, filename, line, EINVAL,
-                           "Netdev is not a VLAN, ignoring assignment: %s", rvalue);
+                           "NetDev is not a VLAN, ignoring assignment: %s", rvalue);
                 return 0;
         }
 
-        network->vlan = netdev;
+        r = hashmap_put(network->vlans, &netdev->vlanid, netdev);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+                           "Can not add VLAN to network: %s", rvalue);
+                return 0;
+        }
 
         return 0;
 }