X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fnetwork%2Fnetworkd-route.c;h=f451b975a701bb9b7ed1ecb337a8c55939f078b5;hb=70b34f5de86809991d6753ba486b88481ceab817;hp=9e6295f8c828f0e1deb1c7e972272529053b9ca2;hpb=5d8e593dce074bff966fc0a46579c61b4f3bc33a;p=elogind.git diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 9e6295f8c..f451b975a 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -32,9 +32,8 @@ int route_new_static(Network *network, unsigned section, Route **ret) { _cleanup_route_free_ Route *route = NULL; if (section) { - uint64_t key = section; - - route = hashmap_get(network->routes_by_section, &key); + route = hashmap_get(network->routes_by_section, + UINT_TO_PTR(section)); if (route) { *ret = route; route = NULL; @@ -49,6 +48,7 @@ int route_new_static(Network *network, unsigned section, Route **ret) { route->family = AF_UNSPEC; route->scope = RT_SCOPE_UNIVERSE; + route->protocol = RTPROT_STATIC; route->network = network; @@ -56,7 +56,8 @@ int route_new_static(Network *network, unsigned section, Route **ret) { if (section) { route->section = section; - hashmap_put(network->routes_by_section, &route->section, route); + hashmap_put(network->routes_by_section, + UINT_TO_PTR(route->section), route); } *ret = route; @@ -65,7 +66,7 @@ int route_new_static(Network *network, unsigned section, Route **ret) { return 0; } -int route_new_dynamic(Route **ret) { +int route_new_dynamic(Route **ret, unsigned char rtm_protocol) { _cleanup_route_free_ Route *route = NULL; route = new0(Route, 1); @@ -74,6 +75,7 @@ int route_new_dynamic(Route **ret) { route->family = AF_UNSPEC; route->scope = RT_SCOPE_UNIVERSE; + route->protocol = rtm_protocol; *ret = route; route = NULL; @@ -90,7 +92,7 @@ void route_free(Route *route) { if (route->section) hashmap_remove(route->network->routes_by_section, - &route->section); + UINT_TO_PTR(route->section)); } free(route); @@ -108,7 +110,8 @@ int route_drop(Route *route, Link *link, assert(route->family == AF_INET || route->family == AF_INET6); r = sd_rtnl_message_new_route(link->manager->rtnl, &req, - RTM_DELROUTE, route->family); + RTM_DELROUTE, route->family, + route->protocol); if (r < 0) { log_error("Could not create RTM_DELROUTE message: %s", strerror(-r)); return r; @@ -181,7 +184,8 @@ int route_configure(Route *route, Link *link, assert(route->family == AF_INET || route->family == AF_INET6); r = sd_rtnl_message_new_route(link->manager->rtnl, &req, - RTM_NEWROUTE, route->family); + RTM_NEWROUTE, route->family, + route->protocol); if (r < 0) { log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r)); return r; @@ -373,7 +377,6 @@ int config_parse_route_priority(const char *unit, void *userdata) { Network *network = userdata; _cleanup_route_free_ Route *n = NULL; - _cleanup_free_ char *route = NULL; int r; assert(filename);