aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins/ha/ha_attribute.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2012-09-11 10:41:11 +0200
committerMartin Willi <martin@revosec.ch>2012-09-11 16:18:28 +0200
commit594c58e1118e496eadd284647755b16b74665337 (patch)
tree743e0f33a01beffab57e363fe1e154944c63dd01 /src/libcharon/plugins/ha/ha_attribute.c
parentdc7b79d8a5c8104001bba4c52a8b3716a0cf6d88 (diff)
downloadstrongswan-594c58e1118e496eadd284647755b16b74665337.tar.bz2
strongswan-594c58e1118e496eadd284647755b16b74665337.tar.xz
Pass the full list of pools to acquire_address, enumerate in providers
If the provider has access to the full pool list, it can enumerate them twice, for example to search for existing leases first, and only search for new leases in a second step. Fixes lease enumeration in attr-sql using multiple pools.
Diffstat (limited to 'src/libcharon/plugins/ha/ha_attribute.c')
-rw-r--r--src/libcharon/plugins/ha/ha_attribute.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/libcharon/plugins/ha/ha_attribute.c b/src/libcharon/plugins/ha/ha_attribute.c
index f18c58b6a..d9f460ade 100644
--- a/src/libcharon/plugins/ha/ha_attribute.c
+++ b/src/libcharon/plugins/ha/ha_attribute.c
@@ -170,22 +170,28 @@ static bool responsible_for(private_ha_attribute_t *this, int bit)
}
METHOD(attribute_provider_t, acquire_address, host_t*,
- private_ha_attribute_t *this, char *name, identification_t *id,
+ private_ha_attribute_t *this, linked_list_t *pools, identification_t *id,
host_t *requested)
{
+ enumerator_t *enumerator;
pool_t *pool;
int offset = -1, byte, bit;
host_t *address;
+ char *name;
+ enumerator = pools->create_enumerator(pools);
this->mutex->lock(this->mutex);
- pool = get_pool(this, name);
- if (pool)
+ while (enumerator->enumerate(enumerator, &name))
{
+ pool = get_pool(this, name);
+ if (!pool)
+ {
+ continue;
+ }
if (pool->base->get_family(pool->base) !=
requested->get_family(requested))
{
- this->mutex->unlock(this->mutex);
- return NULL;
+ continue;
}
for (byte = 0; byte < pool->size / 8; byte++)
{
@@ -214,6 +220,8 @@ METHOD(attribute_provider_t, acquire_address, host_t*,
}
}
this->mutex->unlock(this->mutex);
+ enumerator->destroy(enumerator);
+
if (offset != -1)
{
address = offset2host(pool, offset);