diff options
author | Tom Gundersen <teg@jklm.no> | 2014-01-28 20:00:47 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-01-30 14:30:39 +0100 |
commit | 801bd9e859d7f3f127617172910786929776472b (patch) | |
tree | 5c0d67fdf25bb222bcbdc977db96a7fc1e1e21d9 /src/network | |
parent | eb27aeca247a4cf8816fffc4c0dbcab55ead3864 (diff) |
net-util: verify the address family
Error out if the address family is already set to something incompatible with the
address being parsed.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-address.c | 4 | ||||
-rw-r--r-- | src/network/networkd-network.c | 6 | ||||
-rw-r--r-- | src/network/networkd-route.c | 8 | ||||
-rw-r--r-- | src/network/networkd.h | 1 |
4 files changed, 10 insertions, 9 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 3f787948f9..de5566dfdb 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -46,6 +46,8 @@ int address_new_static(Network *network, unsigned section, Address **ret) { if (!address) return -ENOMEM; + address->family = AF_UNSPEC; + address->network = network; LIST_PREPEND(static_addresses, network->static_addresses, address); @@ -68,6 +70,8 @@ int address_new_dynamic(Address **ret) { if (!address) return -ENOMEM; + address->family = AF_UNSPEC; + *ret = address; address = NULL; diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 2a720349a0..94138cd558 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -84,12 +84,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) { diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 83dad655db..29ee1045da 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -47,6 +47,8 @@ int route_new_static(Network *network, unsigned section, Route **ret) { if (!route) return -ENOMEM; + route->family = AF_UNSPEC; + route->network = network; LIST_PREPEND(static_routes, network->static_routes, route); @@ -69,6 +71,8 @@ int route_new_dynamic(Route **ret) { if (!route) return -ENOMEM; + route->family = AF_UNSPEC; + *ret = route; route = NULL; @@ -231,7 +235,7 @@ int config_parse_destination(const char *unit, return log_oom(); } - r = net_parse_inaddr(address, &n->dst_family, &n->dst_addr); + r = net_parse_inaddr(address, &n->family, &n->dst_addr); if (r < 0) { log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Destination is invalid, ignoring assignment: %s", address); @@ -252,7 +256,7 @@ int config_parse_destination(const char *unit, n->dst_prefixlen = (unsigned char) i; } else { - switch (n->dst_family) { + switch (n->family) { case AF_INET: n->dst_prefixlen = 32; break; diff --git a/src/network/networkd.h b/src/network/networkd.h index 968edf6a70..f174abbf59 100644 --- a/src/network/networkd.h +++ b/src/network/networkd.h @@ -138,7 +138,6 @@ struct Route { uint64_t section; unsigned char family; - unsigned char dst_family; unsigned char dst_prefixlen; union { |