network: delay dropping addresses or so on reloading .network files

When a .network file is updated but its change is not so big, it is not
necessary to first drop all configs and then reassign later again.
This slightly optimize such situation. First foreignize all configs, and
then drop later when it is not requested by the updated .network file.
This commit is contained in:
Yu Watanabe
2021-10-26 08:20:22 +09:00
parent 756f1f5fd0
commit b4564f4e8f
11 changed files with 135 additions and 18 deletions
+21 -3
View File
@@ -1051,6 +1051,17 @@ static int link_drop_config(Link *link) {
return r;
}
static void link_foreignize_config(Link *link) {
assert(link);
assert(link->manager);
link_foreignize_routes(link);
link_foreignize_nexthops(link);
link_foreignize_addresses(link);
link_foreignize_neighbors(link);
link_foreignize_routing_policy_rules(link);
}
static int link_configure(Link *link) {
int r;
@@ -1249,9 +1260,16 @@ static int link_reconfigure_impl(Link *link, bool force) {
link_drop_requests(link);
r = link_drop_config(link);
if (r < 0)
return r;
if (network && !force)
/* When a new/updated .network file is assigned, first make all configs (addresses,
* routes, and so on) foreign, and then drop unnecessary configs later by
* link_drop_foreign_config() in link_configure(). */
link_foreignize_config(link);
else {
r = link_drop_config(link);
if (r < 0)
return r;
}
link_free_carrier_maps(link);
link_free_engines(link);