X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fnetwork%2Fnetworkd-route.c;h=29ee1045da55ed7c6b067b180c980faf960a53eb;hb=deb678f15a6faf9feb29e18954553f5051788056;hp=3eaefa2cc741ffa42e84da99acdd2065d2be1613;hpb=ae4c67a7c6bb4efb858822838efe81008c965a98;p=elogind.git diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 3eaefa2cc..29ee1045d 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) { @@ -47,9 +47,11 @@ int route_new(Network *network, unsigned section, Route **ret) { if (!route) return -ENOMEM; + route->family = AF_UNSPEC; + route->network = network; - LIST_PREPEND(routes, network->routes, route); + LIST_PREPEND(static_routes, network->static_routes, route); if (section) { route->section = section; @@ -62,15 +64,32 @@ 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; + + route->family = AF_UNSPEC; + + *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 +179,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 +217,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;