From 497ce2cf51d3e80302e24e5bdf7df566d80b4828 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Fri, 24 Aug 2012 12:31:24 +0000 Subject: Support multiple address pools configured on a peer_cfg --- src/libhydra/attributes/attribute_manager.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/libhydra/attributes/attribute_manager.c') diff --git a/src/libhydra/attributes/attribute_manager.c b/src/libhydra/attributes/attribute_manager.c index 95520531e..250302356 100644 --- a/src/libhydra/attributes/attribute_manager.c +++ b/src/libhydra/attributes/attribute_manager.c @@ -87,7 +87,7 @@ METHOD(attribute_manager_t, acquire_address, host_t*, return host; } -METHOD(attribute_manager_t, release_address, void, +METHOD(attribute_manager_t, release_address, bool, private_attribute_manager_t *this, char *pool, host_t *address, identification_t *id) { @@ -108,10 +108,7 @@ METHOD(attribute_manager_t, release_address, void, enumerator->destroy(enumerator); this->lock->unlock(this->lock); - if (!found) - { - DBG1(DBG_CFG, "releasing address to pool '%s' failed", pool); - } + return found; } /** -- cgit v1.2.3 From feb8550401c85218523c007f0d52a1c9bf006342 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Mon, 27 Aug 2012 14:09:47 +0200 Subject: Pass a list instead of a single virtual IP to attribute enumerators --- src/libhydra/attributes/attribute_manager.c | 46 ++++++++++++++++------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'src/libhydra/attributes/attribute_manager.c') diff --git a/src/libhydra/attributes/attribute_manager.c b/src/libhydra/attributes/attribute_manager.c index 250302356..b1c2c9555 100644 --- a/src/libhydra/attributes/attribute_manager.c +++ b/src/libhydra/attributes/attribute_manager.c @@ -55,8 +55,8 @@ typedef struct { char *pool; /** server/peer identity */ identification_t *id; - /** requesting/assigned virtual IP */ - host_t *vip; + /** requesting/assigned virtual IPs */ + linked_list_t *vips; } enum_data_t; METHOD(attribute_manager_t, acquire_address, host_t*, @@ -118,18 +118,20 @@ static enumerator_t *responder_enum_create(attribute_provider_t *provider, enum_data_t *data) { return provider->create_attribute_enumerator(provider, data->pool, - data->id, data->vip); + data->id, data->vips); } METHOD(attribute_manager_t, create_responder_enumerator, enumerator_t*, private_attribute_manager_t *this, char *pool, identification_t *id, - host_t *vip) + linked_list_t *vips) { - enum_data_t *data = malloc_thing(enum_data_t); + enum_data_t *data; - data->pool = pool; - data->id = id; - data->vip = vip; + INIT(data, + .pool = pool, + .id = id, + .vips = vips, + ); this->lock->read_lock(this->lock); return enumerator_create_cleaner( enumerator_create_nested( @@ -235,8 +237,8 @@ typedef struct { enumerator_t *inner; /** server ID we want attributes for */ identification_t *id; - /** virtual IP we are requesting along with attriubutes */ - host_t *vip; + /** virtual IPs we are requesting along with attriubutes */ + linked_list_t *vips; } initiator_enumerator_t; /** @@ -256,7 +258,7 @@ static bool initiator_enumerate(initiator_enumerator_t *this, } DESTROY_IF(this->inner); this->inner = this->handler->create_attribute_enumerator(this->handler, - this->id, this->vip); + this->id, this->vips); } /* inject the handler as additional attribute */ *handler = this->handler; @@ -275,20 +277,22 @@ static void initiator_destroy(initiator_enumerator_t *this) } METHOD(attribute_manager_t, create_initiator_enumerator, enumerator_t*, - private_attribute_manager_t *this, identification_t *id, host_t *vip) + private_attribute_manager_t *this, identification_t *id, linked_list_t *vips) { - initiator_enumerator_t *enumerator = malloc_thing(initiator_enumerator_t); + initiator_enumerator_t *enumerator; this->lock->read_lock(this->lock); - enumerator->public.enumerate = (void*)initiator_enumerate; - enumerator->public.destroy = (void*)initiator_destroy; - enumerator->this = this; - enumerator->id = id; - enumerator->vip = vip; - enumerator->outer = this->handlers->create_enumerator(this->handlers); - enumerator->inner = NULL; - enumerator->handler = NULL; + INIT(enumerator, + .public = { + .enumerate = (void*)initiator_enumerate, + .destroy = (void*)initiator_destroy, + }, + .this = this, + .id = id, + .vips = vips, + .outer = this->handlers->create_enumerator(this->handlers), + ); return &enumerator->public; } -- cgit v1.2.3 From d55fe264d1dd33a2751aa75a6f814e153f6354d4 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Mon, 27 Aug 2012 14:48:41 +0200 Subject: Pass all configured pool names to attribute provider enumerator --- src/libhydra/attributes/attribute_manager.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/libhydra/attributes/attribute_manager.c') diff --git a/src/libhydra/attributes/attribute_manager.c b/src/libhydra/attributes/attribute_manager.c index b1c2c9555..a2ee773bd 100644 --- a/src/libhydra/attributes/attribute_manager.c +++ b/src/libhydra/attributes/attribute_manager.c @@ -51,8 +51,8 @@ struct private_attribute_manager_t { * Data to pass to enumerator filters */ typedef struct { - /** attribute group pool */ - char *pool; + /** attribute group pools */ + linked_list_t *pools; /** server/peer identity */ identification_t *id; /** requesting/assigned virtual IPs */ @@ -117,18 +117,18 @@ METHOD(attribute_manager_t, release_address, bool, static enumerator_t *responder_enum_create(attribute_provider_t *provider, enum_data_t *data) { - return provider->create_attribute_enumerator(provider, data->pool, + return provider->create_attribute_enumerator(provider, data->pools, data->id, data->vips); } METHOD(attribute_manager_t, create_responder_enumerator, enumerator_t*, - private_attribute_manager_t *this, char *pool, identification_t *id, - linked_list_t *vips) + private_attribute_manager_t *this, linked_list_t *pools, + identification_t *id, linked_list_t *vips) { enum_data_t *data; INIT(data, - .pool = pool, + .pools = pools, .id = id, .vips = vips, ); -- cgit v1.2.3 From 7f52f621c227b412ca497981241e9b91e0951f28 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Mon, 27 Aug 2012 16:31:38 +0200 Subject: Be less verbose if IP allocation for a single pool fails --- src/libhydra/attributes/attribute_manager.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/libhydra/attributes/attribute_manager.c') diff --git a/src/libhydra/attributes/attribute_manager.c b/src/libhydra/attributes/attribute_manager.c index a2ee773bd..64dc9c7c9 100644 --- a/src/libhydra/attributes/attribute_manager.c +++ b/src/libhydra/attributes/attribute_manager.c @@ -80,10 +80,6 @@ METHOD(attribute_manager_t, acquire_address, host_t*, enumerator->destroy(enumerator); this->lock->unlock(this->lock); - if (!host) - { - DBG1(DBG_CFG, "acquiring address from pool '%s' failed", pool); - } return host; } -- cgit v1.2.3