From: Marcin Siodelski Date: Wed, 12 Oct 2016 19:18:27 +0000 (+0200) Subject: [github24] Removed pool pointer from client context. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44bb83796748aaaf1d7faac2e4972d570cabeaac;p=thirdparty%2Fkea.git [github24] Removed pool pointer from client context. --- diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 05b6e8bdf2..4041f3b5e1 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -1559,7 +1559,8 @@ Dhcpv6Srv::assignIA_PD(const Pkt6Ptr& query, const Pkt6Ptr& answer, if (ctx.pd_exclude_requested_) { // PD exclude option has been requested via ORO, thus we need to // include it if the pool configuration specifies this option. - Pool6Ptr pool = ctx.currentIA().pool_; + Pool6Ptr pool = boost::dynamic_pointer_cast< + Pool6>(subnet->getPool(Lease::TYPE_PD, (*l)->addr_)); if (pool && pool->getExcludedPrefixLength() > 0) { OptionPtr opt(new Option6PDExclude((*l)->addr_, (*l)->prefixlen_, @@ -1847,7 +1848,9 @@ Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query, if (ctx.pd_exclude_requested_) { // PD exclude option has been requested via ORO, thus we need to // include it if the pool configuration specifies this option. - Pool6Ptr pool = ctx.currentIA().pool_; + Pool6Ptr pool = boost::dynamic_pointer_cast< + Pool6>(subnet->getPool(Lease::TYPE_PD, (*l)->addr_)); + if (pool && pool->getExcludedPrefixLength() > 0) { OptionPtr opt(new Option6PDExclude((*l)->addr_, (*l)->prefixlen_, diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 61543ab8cb..b57198471c 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -360,7 +360,7 @@ AllocEngine::ClientContext6::ClientContext6(const Subnet6Ptr& subnet, AllocEngine::ClientContext6::IAContext::IAContext() : iaid_(0), type_(Lease::TYPE_NA), hints_(), old_leases_(), - changed_leases_(), ia_rsp_(), pool_() { + changed_leases_(), ia_rsp_() { } void @@ -583,10 +583,10 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) { // check if the hint is in pool and is available // This is equivalent of subnet->inPool(hint), but returns the pool - ctx.currentIA().pool_ = boost::dynamic_pointer_cast< + Pool6Ptr pool = boost::dynamic_pointer_cast< Pool6>(ctx.subnet_->getPool(ctx.currentIA().type_, hint, false)); - if (ctx.currentIA().pool_) { + if (pool) { /// @todo: We support only one hint for now Lease6Ptr lease = @@ -608,7 +608,7 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) { // The hint is valid and not currently used, let's create a // lease for it - lease = createLease6(ctx, hint, ctx.currentIA().pool_->getLength()); + lease = createLease6(ctx, hint, pool->getLength()); // It can happen that the lease allocation failed (we could // have lost the race condition. That means that the hint is @@ -647,8 +647,7 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) { ctx.currentIA().old_leases_.push_back(old_lease); /// We found a lease and it is expired, so we can reuse it - lease = reuseExpiredLease(lease, ctx, - ctx.currentIA().pool_->getLength()); + lease = reuseExpiredLease(lease, ctx, pool->getLength()); /// @todo: We support only one lease per ia for now leases.push_back(lease); @@ -664,8 +663,6 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) { } } - ctx.currentIA().pool_.reset(); - // The hint was useless (it was not provided at all, was used by someone else, // was out of pool or reserved for someone else). Search the pool until first // of the following occurs: @@ -692,10 +689,10 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) { // non-PD leases. uint8_t prefix_len = 128; if (ctx.currentIA().type_ == Lease::TYPE_PD) { - ctx.currentIA().pool_ = boost::dynamic_pointer_cast( + pool = boost::dynamic_pointer_cast( ctx.subnet_->getPool(ctx.currentIA().type_, candidate, false)); /// @todo: verify that the pool is non-null - prefix_len = ctx.currentIA().pool_->getLength(); + prefix_len = pool->getLength(); } Lease6Ptr existing = LeaseMgrFactory::instance().getLease6(ctx.currentIA().type_, diff --git a/src/lib/dhcpsrv/alloc_engine.h b/src/lib/dhcpsrv/alloc_engine.h index 82708c4e5c..439c4eaa14 100644 --- a/src/lib/dhcpsrv/alloc_engine.h +++ b/src/lib/dhcpsrv/alloc_engine.h @@ -381,10 +381,6 @@ public: /// response Option6IAPtr ia_rsp_; - /// @brief A pointer to a pool from which an address or prefix has - /// been assigned in this IA. - Pool6Ptr pool_; - /// @brief Default constructor. /// /// Initializes @ref type_ to @c Lease::TYPE_NA and @ref iaid_ to 0.