Parcourir la source

[3965] Removed unused fields from the Lease structures.

Marcin Siodelski il y a 9 ans
Parent
commit
dfd5058a79

+ 0 - 2
src/lib/dhcpsrv/alloc_engine.cc

@@ -932,7 +932,6 @@ AllocEngine::reuseExpiredLease(Lease6Ptr& expired, ClientContext6& ctx,
     expired->t2_ = ctx.subnet_->getT2();
     expired->cltt_ = time(NULL);
     expired->subnet_id_ = ctx.subnet_->getID();
-    expired->fixed_ = false;
     expired->hostname_ = ctx.hostname_;
     expired->fqdn_fwd_ = ctx.fwd_dns_update_;
     expired->fqdn_rev_ = ctx.rev_dns_update_;
@@ -1913,7 +1912,6 @@ AllocEngine::reuseExpiredLease4(Lease4Ptr& expired,
     }
 
     updateLease4Information(expired, ctx);
-    expired->fixed_ = false;
 
     LOG_DEBUG(alloc_engine_logger, ALLOC_ENGINE_DBG_TRACE_DETAIL_DATA,
               ALLOC_ENGINE_V4_REUSE_EXPIRED_LEASE_DATA)

+ 3 - 15
src/lib/dhcpsrv/lease.cc

@@ -35,9 +35,8 @@ Lease::Lease(const isc::asiolink::IOAddress& addr, uint32_t t1, uint32_t t2,
              const bool fqdn_fwd, const bool fqdn_rev,
              const std::string& hostname, const HWAddrPtr& hwaddr)
     :addr_(addr), t1_(t1), t2_(t2), valid_lft_(valid_lft), cltt_(cltt),
-     subnet_id_(subnet_id), fixed_(false), hostname_(hostname),
-     fqdn_fwd_(fqdn_fwd), fqdn_rev_(fqdn_rev), hwaddr_(hwaddr),
-     state_(STATE_DEFAULT) {
+     subnet_id_(subnet_id), hostname_(hostname), fqdn_fwd_(fqdn_fwd),
+    fqdn_rev_(fqdn_rev), hwaddr_(hwaddr), state_(STATE_DEFAULT) {
 }
 
 
@@ -123,9 +122,6 @@ Lease4::Lease4(const Lease4& other)
             other.fqdn_rev_, other.hostname_, other.hwaddr_) {
 
     // Copy over fields derived from Lease.
-    ext_ = other.ext_;
-    comments_ = other.comments_;
-    fixed_ = other.fixed_;
     state_ = other.state_;
 
     // Copy the hardware address if it is defined.
@@ -158,7 +154,7 @@ Lease4::Lease4(const isc::asiolink::IOAddress& address,
 
     : Lease(address, t1, t2, valid_lifetime, subnet_id, cltt, fqdn_fwd,
             fqdn_rev, hostname, hw_address),
-      ext_(0), client_id_(client_id) {
+      client_id_(client_id) {
 }
 
 std::string
@@ -211,12 +207,9 @@ Lease4::operator=(const Lease4& other) {
         valid_lft_ = other.valid_lft_;
         cltt_ = other.cltt_;
         subnet_id_ = other.subnet_id_;
-        fixed_ = other.fixed_;
         hostname_ = other.hostname_;
         fqdn_fwd_ = other.fqdn_fwd_;
         fqdn_rev_ = other.fqdn_rev_;
-        comments_ = other.comments_;
-        ext_ = other.ext_;
         state_ = other.state_;
 
         // Copy the hardware address if it is defined.
@@ -330,17 +323,14 @@ Lease4::operator==(const Lease4& other) const {
     return (nullOrEqualValues(hwaddr_, other.hwaddr_) &&
             nullOrEqualValues(client_id_, other.client_id_) &&
             addr_ == other.addr_ &&
-            ext_ == other.ext_ &&
             subnet_id_ == other.subnet_id_ &&
             t1_ == other.t1_ &&
             t2_ == other.t2_ &&
             valid_lft_ == other.valid_lft_ &&
             cltt_ == other.cltt_ &&
-            fixed_ == other.fixed_ &&
             hostname_ == other.hostname_ &&
             fqdn_fwd_ == other.fqdn_fwd_ &&
             fqdn_rev_ == other.fqdn_rev_ &&
-            comments_ == other.comments_ &&
             state_ == other.state_);
 }
 
@@ -358,11 +348,9 @@ Lease6::operator==(const Lease6& other) const {
             t2_ == other.t2_ &&
             cltt_ == other.cltt_ &&
             subnet_id_ == other.subnet_id_ &&
-            fixed_ == other.fixed_ &&
             hostname_ == other.hostname_ &&
             fqdn_fwd_ == other.fqdn_fwd_ &&
             fqdn_rev_ == other.fqdn_rev_ &&
-            comments_ == other.comments_ &&
             state_ == other.state_);
 }
 

+ 2 - 23
src/lib/dhcpsrv/lease.h

@@ -136,11 +136,6 @@ struct Lease {
     /// Specifies the identification of the subnet to which the lease belongs.
     SubnetID subnet_id_;
 
-    /// @brief Fixed lease?
-    ///
-    /// Fixed leases are kept after they are released/expired.
-    bool fixed_;
-
     /// @brief Client hostname
     ///
     /// This field may be empty
@@ -161,12 +156,6 @@ struct Lease {
     /// This information may not be available in certain cases.
     HWAddrPtr hwaddr_;
 
-    /// @brief Lease comments
-    ///
-    /// Currently not used. It may be used for keeping comments made by the
-    /// system administrator.
-    std::string comments_;
-
     /// @brief Bitfield holding lease state(s).
     ///
     /// This is a bitfield which holds the lease state. Typically, a lease
@@ -223,16 +212,6 @@ struct Lease {
 /// extensively, direct access is warranted.
 struct Lease4 : public Lease {
 
-    /// @brief Address extension
-    ///
-    /// It is envisaged that in some cases IPv4 address will be accompanied
-    /// with some additional data. One example of such use are Address + Port
-    /// solutions (or Port-restricted Addresses), where several clients may get
-    /// the same address, but different port ranges. This feature is not
-    /// expected to be widely used.  Under normal circumstances, the value
-    /// should be 0.
-    uint32_t ext_;
-
     /// @brief Client identifier
     ///
     /// @todo Should this be a pointer to a client ID or the ID itself?
@@ -259,7 +238,7 @@ struct Lease4 : public Lease {
            const bool fqdn_fwd = false, const bool fqdn_rev = false,
            const std::string& hostname = "")
         : Lease(addr, t1, t2, valid_lft, subnet_id, cltt, fqdn_fwd, fqdn_rev,
-                hostname, hwaddr), ext_(0) {
+                hostname, hwaddr) {
         if (clientid_len) {
             client_id_.reset(new ClientId(clientid, clientid_len));
         }
@@ -294,7 +273,7 @@ struct Lease4 : public Lease {
     /// @brief Default constructor
     ///
     /// Initialize fields that don't have a default constructor.
-    Lease4() : Lease(0, 0, 0, 0, 0, 0, false, false, "", HWAddrPtr()), ext_(0)
+    Lease4() : Lease(0, 0, 0, 0, 0, 0, false, false, "", HWAddrPtr())
     {
     }
 

+ 0 - 7
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc

@@ -79,11 +79,8 @@ GenericLeaseMgrTest::initializeLease4(std::string address) {
     lease->addr_ = IOAddress(address);
 
     // Initialize unused fields.
-    lease->ext_ = 0;                            // Not saved
     lease->t1_ = 0;                             // Not saved
     lease->t2_ = 0;                             // Not saved
-    lease->fixed_ = false;                      // Unused
-    lease->comments_ = std::string("");         // Unused
 
     // Set other parameters.  For historical reasons, address 0 is not used.
     if (address == straddress4_[0]) {
@@ -199,8 +196,6 @@ GenericLeaseMgrTest::initializeLease6(std::string address) {
     // Initialize unused fields.
     lease->t1_ = 0;                             // Not saved
     lease->t2_ = 0;                             // Not saved
-    lease->fixed_ = false;                      // Unused
-    lease->comments_ = std::string("");         // Unused
 
     // Set other parameters.  For historical reasons, address 0 is not used.
     if (address == straddress6_[0]) {
@@ -1304,8 +1299,6 @@ GenericLeaseMgrTest::testLease6LeaseTypeCheck() {
     // Initialize unused fields.
     empty_lease->t1_ = 0;                             // Not saved
     empty_lease->t2_ = 0;                             // Not saved
-    empty_lease->fixed_ = false;                      // Unused
-    empty_lease->comments_ = std::string("");         // Unused
     empty_lease->iaid_ = 142;
     empty_lease->duid_ = DuidPtr(new DUID(*duid));
     empty_lease->subnet_id_ = 23;

+ 1 - 39
src/lib/dhcpsrv/tests/lease_unittest.cc

@@ -96,7 +96,6 @@ TEST_F(Lease4Test, constructor) {
                      "hostname.example.com.");
 
         EXPECT_EQ(ADDRESS[i], static_cast<uint32_t>(lease.addr_));
-        EXPECT_EQ(0, lease.ext_);
         EXPECT_TRUE(util::equalValues(hwaddr_, lease.hwaddr_));
         EXPECT_TRUE(util::equalValues(clientid_, lease.client_id_));
         EXPECT_EQ(0, lease.t1_);
@@ -104,11 +103,9 @@ TEST_F(Lease4Test, constructor) {
         EXPECT_EQ(VALID_LIFETIME, lease.valid_lft_);
         EXPECT_EQ(current_time, lease.cltt_);
         EXPECT_EQ(SUBNET_ID, lease.subnet_id_);
-        EXPECT_FALSE(lease.fixed_);
         EXPECT_EQ("hostname.example.com.", lease.hostname_);
         EXPECT_TRUE(lease.fqdn_fwd_);
         EXPECT_TRUE(lease.fqdn_rev_);
-        EXPECT_TRUE(lease.comments_.empty());
         EXPECT_EQ(Lease::STATE_DEFAULT, lease.state_);
     }
 }
@@ -295,13 +292,6 @@ TEST_F(Lease4Test, operatorEquals) {
     EXPECT_TRUE(lease1 == lease2);  // Check that the reversion has made the
     EXPECT_FALSE(lease1 != lease2); // ... leases equal
 
-    ++lease1.ext_;
-    EXPECT_FALSE(lease1 == lease2);
-    EXPECT_TRUE(lease1 != lease2);
-    lease1.ext_ = lease2.ext_;
-    EXPECT_TRUE(lease1 == lease2);  // Check that the reversion has made the
-    EXPECT_FALSE(lease1 != lease2); // ... leases equal
-
     ++lease1.hwaddr_->hwaddr_[0];
     EXPECT_FALSE(lease1 == lease2);
     EXPECT_TRUE(lease1 != lease2);
@@ -354,13 +344,6 @@ TEST_F(Lease4Test, operatorEquals) {
     EXPECT_TRUE(lease1 == lease2);  // Check that the reversion has made the
     EXPECT_FALSE(lease1 != lease2); // ... leases equal
 
-    lease1.fixed_ = !lease1.fixed_;
-    EXPECT_FALSE(lease1 == lease2);
-    EXPECT_TRUE(lease1 != lease2);
-    lease1.fixed_ = lease2.fixed_;
-    EXPECT_TRUE(lease1 == lease2);  // Check that the reversion has made the
-    EXPECT_FALSE(lease1 != lease2); // ... leases equal
-
     lease1.hostname_ += std::string("Something random");
     EXPECT_FALSE(lease1 == lease2);
     EXPECT_TRUE(lease1 != lease2);
@@ -382,13 +365,6 @@ TEST_F(Lease4Test, operatorEquals) {
     EXPECT_TRUE(lease1 == lease2);  // Check that the reversion has made the
     EXPECT_FALSE(lease1 != lease2); // ... leases equal
 
-    lease1.comments_ += std::string("Something random");
-    EXPECT_FALSE(lease1 == lease2);
-    EXPECT_TRUE(lease1 != lease2);
-    lease1.comments_ = lease2.comments_;
-    EXPECT_TRUE(lease1 == lease2);  // Check that the reversion has made the
-    EXPECT_FALSE(lease1 != lease2); // ... leases equal
-
     lease1.state_  += 1;
     EXPECT_FALSE(lease1 == lease2);
     EXPECT_TRUE(lease1 != lease2);
@@ -595,7 +571,7 @@ TEST(Lease6Test, Lease6ConstructorWithFQDN) {
 /// Checks that the operator==() correctly compares two leases for equality.
 /// As operator!=() is also defined for this class, every check on operator==()
 /// is followed by the reverse check on operator!=().
-TEST(Lease6Test, OperatorEquals) {
+TEST(Lease6Test, operatorEquals) {
 
     // check a variety of addresses with different bits set.
     const IOAddress addr("2001:db8:1::456");
@@ -697,13 +673,6 @@ TEST(Lease6Test, OperatorEquals) {
     EXPECT_TRUE(lease1 == lease2);  // Check that the reversion has made the
     EXPECT_FALSE(lease1 != lease2); // ... leases equal
 
-    lease1.fixed_ = !lease1.fixed_;
-    EXPECT_FALSE(lease1 == lease2);
-    EXPECT_TRUE(lease1 != lease2);
-    lease1.fixed_ = lease2.fixed_;
-    EXPECT_TRUE(lease1 == lease2);  // Check that the reversion has made the
-    EXPECT_FALSE(lease1 != lease2); // ... leases equal
-
     lease1.hostname_ += std::string("Something random");
     EXPECT_FALSE(lease1 == lease2);
     EXPECT_TRUE(lease1 != lease2);
@@ -725,13 +694,6 @@ TEST(Lease6Test, OperatorEquals) {
     EXPECT_TRUE(lease1 == lease2);  // Check that the reversion has made the
     EXPECT_FALSE(lease1 != lease2); // ... leases equal
 
-    lease1.comments_ += std::string("Something random");
-    EXPECT_FALSE(lease1 == lease2);
-    EXPECT_TRUE(lease1 != lease2);
-    lease1.comments_ = lease2.comments_;
-    EXPECT_TRUE(lease1 == lease2);  // Check that the reversion has made the
-    EXPECT_FALSE(lease1 != lease2); // ... leases equal
-
     lease1.state_  += 1;
     EXPECT_FALSE(lease1 == lease2);
     EXPECT_TRUE(lease1 != lease2);