_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;
route->family = AF_UNSPEC;
route->scope = RT_SCOPE_UNIVERSE;
+ route->protocol = RTPROT_STATIC;
route->network = network;
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;
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);
route->family = AF_UNSPEC;
route->scope = RT_SCOPE_UNIVERSE;
+ route->protocol = rtm_protocol;
*ret = route;
route = NULL;
if (route->section)
hashmap_remove(route->network->routes_by_section,
- &route->section);
+ UINT_TO_PTR(route->section));
}
free(route);
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;
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;
void *userdata) {
Network *network = userdata;
_cleanup_route_free_ Route *n = NULL;
- _cleanup_free_ char *route = NULL;
int r;
assert(filename);