summaryrefslogtreecommitdiff
path: root/src/network/networkd-route.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/networkd-route.c')
-rw-r--r--src/network/networkd-route.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index bde26a42d4..81a065dd27 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -77,15 +77,20 @@ int route_new(Route **ret) {
return 0;
}
-int route_new_static(Network *network, unsigned section, Route **ret) {
+int route_new_static(Network *network, const char *filename, unsigned section_line, Route **ret) {
+ _cleanup_network_config_section_free_ NetworkConfigSection *n = NULL;
_cleanup_route_free_ Route *route = NULL;
int r;
assert(network);
assert(ret);
- if (section) {
- route = hashmap_get(network->routes_by_section, UINT_TO_PTR(section));
+ if (section_line > 0) {
+ r = network_config_section_new(filename, section_line, &n);
+ if (r < 0)
+ return r;
+
+ route = hashmap_get(network->routes_by_section, n);
if (route) {
*ret = route;
route = NULL;
@@ -103,10 +108,10 @@ int route_new_static(Network *network, unsigned section, Route **ret) {
route->protocol = RTPROT_STATIC;
- if (section) {
- route->section = section;
+ if (section_line > 0) {
+ route->section = n;
- r = hashmap_put(network->routes_by_section, UINT_TO_PTR(route->section), route);
+ r = hashmap_put(network->routes_by_section, n, route);
if (r < 0)
return r;
}
@@ -117,6 +122,7 @@ int route_new_static(Network *network, unsigned section, Route **ret) {
*ret = route;
route = NULL;
+ n = NULL;
return 0;
}
@@ -131,8 +137,10 @@ void route_free(Route *route) {
assert(route->network->n_static_routes > 0);
route->network->n_static_routes--;
- if (route->section)
- hashmap_remove(route->network->routes_by_section, UINT_TO_PTR(route->section));
+ if (route->section) {
+ hashmap_remove(route->network->routes_by_section, route->section);
+ network_config_section_free(route->section);
+ }
}
if (route->link) {
@@ -673,10 +681,10 @@ int config_parse_gateway(const char *unit,
if (streq(section, "Network")) {
/* we are not in an Route section, so treat
* this as the special '0' section */
- section_line = 0;
- }
+ r = route_new_static(network, NULL, 0, &n);
+ } else
+ r = route_new_static(network, filename, section_line, &n);
- r = route_new_static(network, section_line, &n);
if (r < 0)
return r;
@@ -715,7 +723,7 @@ int config_parse_preferred_src(const char *unit,
assert(rvalue);
assert(data);
- r = route_new_static(network, section_line, &n);
+ r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
@@ -757,7 +765,7 @@ int config_parse_destination(const char *unit,
assert(rvalue);
assert(data);
- r = route_new_static(network, section_line, &n);
+ r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
@@ -835,7 +843,7 @@ int config_parse_route_priority(const char *unit,
assert(rvalue);
assert(data);
- r = route_new_static(network, section_line, &n);
+ r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
@@ -872,7 +880,7 @@ int config_parse_route_scope(const char *unit,
assert(rvalue);
assert(data);
- r = route_new_static(network, section_line, &n);
+ r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
@@ -913,7 +921,7 @@ int config_parse_route_table(const char *unit,
assert(rvalue);
assert(data);
- r = route_new_static(network, section_line, &n);
+ r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;