route->family = AF_UNSPEC;
route->scope = RT_SCOPE_UNIVERSE;
+ route->protocol = RTPROT_STATIC;
route->network = network;
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;
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;
return r;
}
+ link_ref(link);
+
return 0;
}
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;
return r;
}
+ link_ref(link);
+
return 0;
}
return 0;
}
+
+int config_parse_route_priority(const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ unsigned section_line,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+ Network *network = userdata;
+ _cleanup_route_free_ Route *n = NULL;
+ int r;
+
+ assert(filename);
+ assert(section);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ r = route_new_static(network, section_line, &n);
+ if (r < 0)
+ return r;
+
+ r = config_parse_unsigned(unit, filename, line, section,
+ section_line, lvalue, ltype,
+ rvalue, &n->metrics, userdata);
+ if (r < 0)
+ return r;
+
+ n = NULL;
+
+ return 0;
+}