mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
network: introduce link_serialize_routes()
This commit is contained in:
parent
731ff05b32
commit
565194127a
@ -3975,7 +3975,6 @@ int link_save(Link *link) {
|
|||||||
const char *admin_state, *oper_state, *carrier_state, *address_state;
|
const char *admin_state, *oper_state, *carrier_state, *address_state;
|
||||||
_cleanup_free_ char *temp_path = NULL;
|
_cleanup_free_ char *temp_path = NULL;
|
||||||
_cleanup_fclose_ FILE *f = NULL;
|
_cleanup_fclose_ FILE *f = NULL;
|
||||||
Route *route;
|
|
||||||
Address *a;
|
Address *a;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -4210,22 +4209,9 @@ int link_save(Link *link) {
|
|||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
|
|
||||||
fputs("ROUTES=", f);
|
r = link_serialize_routes(link, f);
|
||||||
space = false;
|
|
||||||
SET_FOREACH(route, link->routes) {
|
|
||||||
_cleanup_free_ char *route_str = NULL;
|
|
||||||
|
|
||||||
r = in_addr_to_string(route->family, &route->dst, &route_str);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
fprintf(f, "%s%s/%hhu/%hhu/%"PRIu32"/%"PRIu32"/"USEC_FMT,
|
|
||||||
space ? " " : "", route_str,
|
|
||||||
route->dst_prefixlen, route->tos, route->priority, route->table, route->lifetime);
|
|
||||||
space = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
fputc('\n', f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print_link_hashmap(f, "CARRIER_BOUND_TO=", link->bound_to_links);
|
print_link_hashmap(f, "CARRIER_BOUND_TO=", link->bound_to_links);
|
||||||
|
@ -1234,6 +1234,31 @@ int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Ma
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int link_serialize_routes(Link *link, FILE *f) {
|
||||||
|
bool space = false;
|
||||||
|
Route *route;
|
||||||
|
|
||||||
|
assert(link);
|
||||||
|
assert(link->network);
|
||||||
|
assert(f);
|
||||||
|
|
||||||
|
fputs("ROUTES=", f);
|
||||||
|
SET_FOREACH(route, link->routes) {
|
||||||
|
_cleanup_free_ char *route_str = NULL;
|
||||||
|
|
||||||
|
if (in_addr_to_string(route->family, &route->dst, &route_str) < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fprintf(f, "%s%s/%hhu/%hhu/%"PRIu32"/%"PRIu32"/"USEC_FMT,
|
||||||
|
space ? " " : "", route_str,
|
||||||
|
route->dst_prefixlen, route->tos, route->priority, route->table, route->lifetime);
|
||||||
|
space = true;
|
||||||
|
}
|
||||||
|
fputc('\n', f);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int link_deserialize_routes(Link *link, const char *routes) {
|
int link_deserialize_routes(Link *link, const char *routes) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ int route_remove(Route *route, Link *link, link_netlink_message_handler_t callba
|
|||||||
int link_set_routes(Link *link);
|
int link_set_routes(Link *link);
|
||||||
int link_drop_routes(Link *link);
|
int link_drop_routes(Link *link);
|
||||||
int link_drop_foreign_routes(Link *link);
|
int link_drop_foreign_routes(Link *link);
|
||||||
|
int link_serialize_routes(Link *link, FILE *f);
|
||||||
int link_deserialize_routes(Link *link, const char *routes);
|
int link_deserialize_routes(Link *link, const char *routes);
|
||||||
|
|
||||||
int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
|
int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user