summaryrefslogtreecommitdiff
path: root/src/network/networkd-network.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-02-10 18:41:54 +0100
committerTom Gundersen <teg@jklm.no>2014-02-10 19:00:17 +0100
commit672682a6b9d6fb6a3722c3fea1a93b4831747b54 (patch)
tree8d7956ff4c9171faad0702afe01b9ac2656d3322 /src/network/networkd-network.c
parent3831838ae7b3ac145711bb84a71cb86cdd829975 (diff)
networkd: VLAN - allow multiple vlans to be created on a link
Also limit the range of vlan ids. Other implementations and documentation use the ranges {0,1}-{4094,4095}, but we use the one accepted by the kernel: 0-4094. Reported-by: Oleksii Shevchuk <alxchk@gmail.com>
Diffstat (limited to 'src/network/networkd-network.c')
-rw-r--r--src/network/networkd-network.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 5d930235b3..48131c1f09 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -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();
@@ -144,6 +148,8 @@ void network_free(Network *network) {
address_free(network->dns);
+ hashmap_free(network->vlans);
+
while ((route = network->static_routes))
route_free(route);
@@ -312,7 +318,12 @@ int config_parse_vlan(const char *unit,
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;
}