]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[github24] Removed pool pointer from client context.
authorMarcin Siodelski <marcin@isc.org>
Wed, 12 Oct 2016 19:18:27 +0000 (21:18 +0200)
committerMarcin Siodelski <marcin@isc.org>
Wed, 12 Oct 2016 19:18:27 +0000 (21:18 +0200)
src/bin/dhcp6/dhcp6_srv.cc
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/alloc_engine.h

index 05b6e8bdf2b342351e998dd1dd4b325d2d142b8d..4041f3b5e1ea0f2707c146faf181d9145cf755b4 100644 (file)
@@ -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_,
index 61543ab8cb07c24ae789e871f16b0f8a52f6f882..b57198471c8dcd1fbbfe74d9a4afac59b43b557d 100644 (file)
@@ -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<Pool6>(
+            pool = boost::dynamic_pointer_cast<Pool6>(
                 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_,
index 82708c4e5c230a22f5ae5116bf1760c2325c74a5..439c4eaa149e60db543b49121b2cb77dbd628b92 100644 (file)
@@ -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.