network: dhcp6-pd: exclude all explicitly specified subnet IDs when searching free IDs

When the upstream link gained a lease, then several downstream links may
not appear yet. Previously, the explicitly specified subnet ID for a
downstream link which appears later may be already assigned to an
interface which does not request specific subnet ID.

To avoid such situation, this makes all specified IDs are excluded when
searching free IDs.

As a side effect, we can avoid the second call of
dhcp6_pd_distribute_prefix().
This commit is contained in:
Yu Watanabe
2021-12-01 20:35:03 +09:00
parent a74229c58e
commit 1a4ca0e2f3
5 changed files with 43 additions and 20 deletions
+27 -1
View File
@@ -643,7 +643,7 @@ int network_reload(Manager *manager) {
ordered_hashmap_free_with_destructor(manager->networks, network_unref);
manager->networks = new_networks;
return 0;
return manager_build_dhcp6_pd_subnet_ids(manager);
failure:
ordered_hashmap_free_with_destructor(new_networks, network_unref);
@@ -651,6 +651,32 @@ failure:
return r;
}
int manager_build_dhcp6_pd_subnet_ids(Manager *manager) {
Network *n;
int r;
assert(manager);
set_clear(manager->dhcp6_pd_subnet_ids);
ORDERED_HASHMAP_FOREACH(n, manager->networks) {
if (n->unmanaged)
continue;
if (!n->dhcp6_pd)
continue;
if (n->dhcp6_pd_subnet_id < 0)
continue;
r = set_ensure_put(&manager->dhcp6_pd_subnet_ids, &uint64_hash_ops, &n->dhcp6_pd_subnet_id);
if (r < 0)
return r;
}
return 0;
}
static Network *network_free(Network *network) {
if (!network)
return NULL;