summaryrefslogtreecommitdiff
path: root/src/network/networkd-route.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-01-01 15:16:10 +0100
committerTom Gundersen <teg@jklm.no>2014-01-01 16:23:00 +0100
commitf048a16b464295a4e0a4f4c1210f06343ad31231 (patch)
tree93441872fc06bbc74d6528e0f52ee42715f84172 /src/network/networkd-route.c
parent407fe036a24834203aca6c1eec7d74d9ad3e9ee0 (diff)
networkd: distinguish between static and dynamic addresses/routes
Static addresses/routes are associated with a network. Dynamic addresses/routes are associtade with links (as the corresponding network may be shared by several links).
Diffstat (limited to 'src/network/networkd-route.c')
-rw-r--r--src/network/networkd-route.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 3eaefa2cc7..488d3f5013 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -28,7 +28,7 @@
#include "conf-parser.h"
#include "net-util.h"
-int route_new(Network *network, unsigned section, Route **ret) {
+int route_new_static(Network *network, unsigned section, Route **ret) {
_cleanup_route_free_ Route *route = NULL;
if (section) {
@@ -49,7 +49,7 @@ int route_new(Network *network, unsigned section, Route **ret) {
route->network = network;
- LIST_PREPEND(routes, network->routes, route);
+ LIST_PREPEND(static_routes, network->static_routes, route);
if (section) {
route->section = section;
@@ -62,15 +62,30 @@ int route_new(Network *network, unsigned section, Route **ret) {
return 0;
}
+int route_new_dynamic(Route **ret) {
+ _cleanup_route_free_ Route *route = NULL;
+
+ route = new0(Route, 1);
+ if (!route)
+ return -ENOMEM;
+
+ *ret = route;
+ route = NULL;
+
+ return 0;
+}
+
void route_free(Route *route) {
if (!route)
return;
- LIST_REMOVE(routes, route->network->routes, route);
+ if (route->network) {
+ LIST_REMOVE(static_routes, route->network->static_routes, route);
- if (route->section)
- hashmap_remove(route->network->routes_by_section,
- &route->section);
+ if (route->section)
+ hashmap_remove(route->network->routes_by_section,
+ &route->section);
+ }
free(route);
}
@@ -160,7 +175,7 @@ int config_parse_gateway(const char *unit,
section_line = 0;
}
- r = route_new(network, section_line, &n);
+ r = route_new_static(network, section_line, &n);
if (r < 0)
return r;
@@ -198,7 +213,7 @@ int config_parse_destination(const char *unit,
assert(rvalue);
assert(data);
- r = route_new(network, section_line, &n);
+ r = route_new_static(network, section_line, &n);
if (r < 0)
return r;