diff options
author | Tom Gundersen <teg@jklm.no> | 2015-09-21 15:53:40 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-10-11 14:21:41 +0200 |
commit | f0213e3796b4dd66e546e2de4d677db319f9171b (patch) | |
tree | a7c41b70eb2b3e31e760c64afae75702fe1eb00d /src/network/networkd-route.c | |
parent | e930d14ac87cbd9280719a30c9ae549821f3adaa (diff) |
networkd: route/address - simplify and unify creators
Rename new_dynamic() to simply _new() and reuse that from new_static().
Diffstat (limited to 'src/network/networkd-route.c')
-rw-r--r-- | src/network/networkd-route.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index ee1ddd81fe..28ce126849 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -26,8 +26,26 @@ #include "networkd.h" #include "networkd-route.h" +int route_new(Route **ret, unsigned char rtm_protocol) { + _cleanup_route_free_ Route *route = NULL; + + route = new0(Route, 1); + if (!route) + return -ENOMEM; + + route->family = AF_UNSPEC; + route->scope = RT_SCOPE_UNIVERSE; + route->protocol = rtm_protocol; + + *ret = route; + route = NULL; + + return 0; +} + int route_new_static(Network *network, unsigned section, Route **ret) { _cleanup_route_free_ Route *route = NULL; + int r; if (section) { route = hashmap_get(network->routes_by_section, @@ -40,13 +58,9 @@ int route_new_static(Network *network, unsigned section, Route **ret) { } } - route = new0(Route, 1); - if (!route) - return -ENOMEM; - - route->family = AF_UNSPEC; - route->scope = RT_SCOPE_UNIVERSE; - route->protocol = RTPROT_STATIC; + r = route_new(&route, RTPROT_STATIC); + if (r < 0) + return r; route->network = network; @@ -64,23 +78,6 @@ int route_new_static(Network *network, unsigned section, Route **ret) { return 0; } -int route_new_dynamic(Route **ret, unsigned char rtm_protocol) { - _cleanup_route_free_ Route *route = NULL; - - route = new0(Route, 1); - if (!route) - return -ENOMEM; - - route->family = AF_UNSPEC; - route->scope = RT_SCOPE_UNIVERSE; - route->protocol = rtm_protocol; - - *ret = route; - route = NULL; - - return 0; -} - void route_free(Route *route) { if (!route) return; |