From: Francis Dupont Date: Tue, 4 Jun 2019 16:43:24 +0000 (+0200) Subject: [567-remove-lease-t1_-and-t2_-members] Removed t1/t2 from leases X-Git-Tag: Kea-1.6.0-beta2~271 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7088f78b02ef81887ba6d26e90b66287f5e28178;p=thirdparty%2Fkea.git [567-remove-lease-t1_-and-t2_-members] Removed t1/t2 from leases --- diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index fb19c8805a..b76e8616e1 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -537,11 +537,11 @@ TEST_F(CtrlChannelDhcpv4SrvTest, controlLeasesReclaim) { // (valid lifetime = 60, cltt = now - 100). HWAddrPtr hwaddr0(new HWAddr(HWAddr::fromText("00:01:02:03:04:05"))); Lease4Ptr lease0(new Lease4(IOAddress("10.0.0.1"), hwaddr0, - ClientIdPtr(), 60, 10, 20, + ClientIdPtr(), 60, time(NULL) - 100, SubnetID(1))); HWAddrPtr hwaddr1(new HWAddr(HWAddr::fromText("01:02:03:04:05:06"))); Lease4Ptr lease1(new Lease4(IOAddress("10.0.0.2"), hwaddr1, - ClientIdPtr(), 60, 10, 20, + ClientIdPtr(), 60, time(NULL) - 100, SubnetID(1))); // Add leases to the database. @@ -614,11 +614,11 @@ TEST_F(CtrlChannelDhcpv4SrvTest, controlLeasesReclaimRemove) { // (valid lifetime = 60, cltt = now - 100). HWAddrPtr hwaddr0(new HWAddr(HWAddr::fromText("00:01:02:03:04:05"))); Lease4Ptr lease0(new Lease4(IOAddress("10.0.0.1"), hwaddr0, - ClientIdPtr(), 60, 10, 20, + ClientIdPtr(), 60, time(NULL) - 100, SubnetID(1))); HWAddrPtr hwaddr1(new HWAddr(HWAddr::fromText("01:02:03:04:05:06"))); Lease4Ptr lease1(new Lease4(IOAddress("10.0.0.2"), hwaddr1, - ClientIdPtr(), 60, 10, 20, + ClientIdPtr(), 60, time(NULL) - 100, SubnetID(1))); // Add leases to the database. diff --git a/src/bin/dhcp4/tests/dhcp4_client.cc b/src/bin/dhcp4/tests/dhcp4_client.cc index d02e82df73..b7e861d99e 100644 --- a/src/bin/dhcp4/tests/dhcp4_client.cc +++ b/src/bin/dhcp4/tests/dhcp4_client.cc @@ -207,7 +207,7 @@ Dhcp4Client::applyConfiguration() { /// @todo Set the valid lifetime, t1, t2 etc. config_.lease_ = Lease4(IOAddress(context_.response_->getYiaddr()), context_.response_->getHWAddr(), - 0, 0, 0, 0, 0, time(NULL), 0, false, false, + 0, 0, 0, time(NULL), 0, false, false, ""); } } @@ -215,7 +215,7 @@ Dhcp4Client::applyConfiguration() { void Dhcp4Client::createLease(const asiolink::IOAddress& addr, const uint32_t valid_lft) { - Lease4 lease(addr, hwaddr_, 0, 0, valid_lft, valid_lft / 2, valid_lft, + Lease4 lease(addr, hwaddr_, 0, 0, valid_lft, time(NULL), 0, false, false, ""); config_.lease_ = lease; } diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc index 638aefca65..e838a2607c 100644 --- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc @@ -1302,8 +1302,6 @@ TEST_F(Dhcpv4SrvTest, RenewBasic) { ASSERT_NO_THROW(srv.reset(new NakedDhcpv4Srv(0))); const IOAddress addr("192.0.2.106"); - const uint32_t temp_t1 = 50; - const uint32_t temp_t2 = 75; const uint32_t temp_valid = 100; const time_t temp_timestamp = time(NULL) - 10; @@ -1318,18 +1316,15 @@ TEST_F(Dhcpv4SrvTest, RenewBasic) { HWAddrPtr hwaddr2(new HWAddr(hwaddr2_data, sizeof(hwaddr2_data), HTYPE_ETHER)); Lease4Ptr used(new Lease4(IOAddress("192.0.2.106"), hwaddr2, &client_id_->getDuid()[0], client_id_->getDuid().size(), - temp_valid, temp_t1, temp_t2, temp_timestamp, - subnet_->getID())); + temp_valid, temp_timestamp, subnet_->getID())); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used)); // Check that the lease is really in the database Lease4Ptr l = LeaseMgrFactory::instance().getLease4(addr); ASSERT_TRUE(l); - // Check that T1, T2, preferred, valid and cltt really set. + // Check that preferred, valid and cltt really set. // Constructed lease looks as if it was assigned 10 seconds ago - // EXPECT_EQ(l->t1_, temp_t1); - // EXPECT_EQ(l->t2_, temp_t2); EXPECT_EQ(l->valid_lft_, temp_valid); EXPECT_EQ(l->cltt_, temp_timestamp); @@ -1363,9 +1358,7 @@ TEST_F(Dhcpv4SrvTest, RenewBasic) { l = checkLease(ack, clientid, req->getHWAddr(), addr); ASSERT_TRUE(l); - // Check that T1, T2, preferred, valid and cltt were really updated - EXPECT_EQ(l->t1_, subnet_->getT1()); - EXPECT_EQ(l->t2_, subnet_->getT2()); + // Check that preferred, valid and cltt were really updated EXPECT_EQ(l->valid_lft_, subnet_->getValid()); // Checking for CLTT is a bit tricky if we want to avoid off by 1 errors diff --git a/src/bin/dhcp4/tests/fqdn_unittest.cc b/src/bin/dhcp4/tests/fqdn_unittest.cc index b208430a34..3ad0baa153 100644 --- a/src/bin/dhcp4/tests/fqdn_unittest.cc +++ b/src/bin/dhcp4/tests/fqdn_unittest.cc @@ -316,7 +316,7 @@ public: Lease4Ptr lease(new Lease4(addr, hwaddr, &generateClientId()->getData()[0], generateClientId()->getData().size(), - 100, 50, 75, time(NULL), subnet_->getID())); + 100, time(NULL), subnet_->getID())); // @todo Set this through the Lease4 constructor. lease->hostname_ = hostname; lease->fqdn_fwd_ = fqdn_fwd; diff --git a/src/bin/dhcp4/tests/hooks_unittest.cc b/src/bin/dhcp4/tests/hooks_unittest.cc index f14af29397..dab8ece172 100644 --- a/src/bin/dhcp4/tests/hooks_unittest.cc +++ b/src/bin/dhcp4/tests/hooks_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -1748,8 +1748,6 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSimple) { IfaceMgr::instance().openSockets4(); const IOAddress addr("192.0.2.106"); - const uint32_t temp_t1 = 50; - const uint32_t temp_t2 = 75; const uint32_t temp_valid = 100; const time_t temp_timestamp = time(NULL) - 10; @@ -1768,8 +1766,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSimple) { HWAddrPtr hwaddr2(new HWAddr(hwaddr2_data, sizeof(hwaddr2_data), HTYPE_ETHER)); Lease4Ptr used(new Lease4(IOAddress("192.0.2.106"), hwaddr2, &client_id_->getDuid()[0], client_id_->getDuid().size(), - temp_valid, temp_t1, temp_t2, temp_timestamp, - subnet_->getID())); + temp_valid, temp_timestamp, subnet_->getID())); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used)); // Check that the lease is really in the database @@ -1797,9 +1794,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSimple) { l = checkLease(ack, clientid, req->getHWAddr(), addr); ASSERT_TRUE(l); - // Check that T1, T2, preferred, valid and cltt were really updated - EXPECT_EQ(l->t1_, subnet_->getT1()); - EXPECT_EQ(l->t2_, subnet_->getT2()); + // Check that preferred, valid and cltt were really updated EXPECT_EQ(l->valid_lft_, subnet_->getValid()); // Check that the callback called is indeed the one we installed @@ -1848,8 +1843,6 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSkip) { IfaceMgr::instance().openSockets4(); const IOAddress addr("192.0.2.106"); - const uint32_t temp_t1 = 50; - const uint32_t temp_t2 = 75; const uint32_t temp_valid = 100; const time_t temp_timestamp = time(NULL) - 10; @@ -1868,18 +1861,15 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSkip) { HWAddrPtr hwaddr2(new HWAddr(hwaddr2_data, sizeof(hwaddr2_data), HTYPE_ETHER)); Lease4Ptr used(new Lease4(IOAddress("192.0.2.106"), hwaddr2, &client_id_->getDuid()[0], client_id_->getDuid().size(), - temp_valid, temp_t1, temp_t2, temp_timestamp, - subnet_->getID())); + temp_valid, temp_timestamp, subnet_->getID())); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used)); // Check that the lease is really in the database Lease4Ptr l = LeaseMgrFactory::instance().getLease4(addr); ASSERT_TRUE(l); - // Check that T1, T2, preferred, valid and cltt really set. + // Check that preferred, valid and cltt really set. // Constructed lease looks as if it was assigned 10 seconds ago - // EXPECT_EQ(l->t1_, temp_t1); - // EXPECT_EQ(l->t2_, temp_t2); EXPECT_EQ(l->valid_lft_, temp_valid); EXPECT_EQ(l->cltt_, temp_timestamp); @@ -1902,9 +1892,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSkip) { l = checkLease(ack, clientid, req->getHWAddr(), addr); ASSERT_TRUE(l); - // Check that T1, T2, valid and cltt were NOT updated - EXPECT_EQ(temp_t1, l->t1_); - EXPECT_EQ(temp_t2, l->t2_); + // Check that valid and cltt were NOT updated EXPECT_EQ(temp_valid, l->valid_lft_); EXPECT_EQ(temp_timestamp, l->cltt_); @@ -2121,8 +2109,6 @@ TEST_F(HooksDhcpv4SrvTest, lease4ReleaseSimple) { IfaceMgr::instance().openSockets4(); const IOAddress addr("192.0.2.106"); - const uint32_t temp_t1 = 50; - const uint32_t temp_t2 = 75; const uint32_t temp_valid = 100; const time_t temp_timestamp = time(NULL) - 10; @@ -2141,8 +2127,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4ReleaseSimple) { HWAddrPtr hw(new HWAddr(mac_addr, sizeof(mac_addr), HTYPE_ETHER)); Lease4Ptr used(new Lease4(addr, hw, &client_id_->getDuid()[0], client_id_->getDuid().size(), - temp_valid, temp_t1, temp_t2, temp_timestamp, - subnet_->getID())); + temp_valid, temp_timestamp, subnet_->getID())); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used)); // Check that the lease is really in the database @@ -2214,8 +2199,6 @@ TEST_F(HooksDhcpv4SrvTest, lease4ReleaseSkip) { IfaceMgr::instance().openSockets4(); const IOAddress addr("192.0.2.106"); - const uint32_t temp_t1 = 50; - const uint32_t temp_t2 = 75; const uint32_t temp_valid = 100; const time_t temp_timestamp = time(NULL) - 10; @@ -2234,8 +2217,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4ReleaseSkip) { HWAddrPtr hw(new HWAddr(mac_addr, sizeof(mac_addr), HTYPE_ETHER)); Lease4Ptr used(new Lease4(addr, hw, &client_id_->getDuid()[0], client_id_->getDuid().size(), - temp_valid, temp_t1, temp_t2, temp_timestamp, - subnet_->getID())); + temp_valid, temp_timestamp, subnet_->getID())); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used)); // Check that the lease is really in the database @@ -2329,8 +2311,6 @@ TEST_F(HooksDhcpv4SrvTest, lease4ReleaseDrop) { IfaceMgr::instance().openSockets4(); const IOAddress addr("192.0.2.106"); - const uint32_t temp_t1 = 50; - const uint32_t temp_t2 = 75; const uint32_t temp_valid = 100; const time_t temp_timestamp = time(NULL) - 10; @@ -2349,8 +2329,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4ReleaseDrop) { HWAddrPtr hw(new HWAddr(mac_addr, sizeof(mac_addr), HTYPE_ETHER)); Lease4Ptr used(new Lease4(addr, hw, &client_id_->getDuid()[0], client_id_->getDuid().size(), - temp_valid, temp_t1, temp_t2, temp_timestamp, - subnet_->getID())); + temp_valid, temp_timestamp, subnet_->getID())); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used)); // Check that the lease is really in the database diff --git a/src/bin/dhcp4/tests/kea_controller_unittest.cc b/src/bin/dhcp4/tests/kea_controller_unittest.cc index 0c069cc4dd..dec6e7cd55 100644 --- a/src/bin/dhcp4/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp4/tests/kea_controller_unittest.cc @@ -769,7 +769,7 @@ TEST_F(JSONFileBackendTest, timers) { // current configuration. HWAddrPtr hwaddr_expired(new HWAddr(HWAddr::fromText("00:01:02:03:04:05"))); Lease4Ptr lease_expired(new Lease4(IOAddress("10.0.0.1"), hwaddr_expired, - ClientIdPtr(), 60, 10, 20, + ClientIdPtr(), 60, time(NULL) - 100, SubnetID(1))); // Create expired-reclaimed lease. The lease has expired 1000 - 60 seconds @@ -777,7 +777,7 @@ TEST_F(JSONFileBackendTest, timers) { // goes off. HWAddrPtr hwaddr_reclaimed(new HWAddr(HWAddr::fromText("01:02:03:04:05:06"))); Lease4Ptr lease_reclaimed(new Lease4(IOAddress("10.0.0.2"), hwaddr_reclaimed, - ClientIdPtr(), 60, 10, 20, + ClientIdPtr(), 60, time(NULL) - 1000, SubnetID(1))); lease_reclaimed->state_ = Lease4::STATE_EXPIRED_RECLAIMED; diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc index e4dfcca91a..e8742cfd0e 100644 --- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc @@ -862,11 +862,11 @@ TEST_F(CtrlChannelDhcpv6SrvTest, controlLeasesReclaim) { // (valid lifetime = 60, cltt = now - 100). DuidPtr duid0(new DUID(DUID::fromText("00:01:02:03:04:05:06").getDuid())); Lease6Ptr lease0(new Lease6(Lease::TYPE_NA, IOAddress("3000::1"), - duid0, 1, 50, 60, 10, 20, SubnetID(1))); + duid0, 1, 50, 60, SubnetID(1))); lease0->cltt_ = time(NULL) - 100; DuidPtr duid1(new DUID(DUID::fromText("01:02:03:04:05:06:07").getDuid())); Lease6Ptr lease1(new Lease6(Lease::TYPE_NA, IOAddress("3000::2"), - duid1, 1, 50, 60, 10, 20, SubnetID(1))); + duid1, 1, 50, 60, SubnetID(1))); lease1->cltt_ = time(NULL) - 100; // Add leases to the database. @@ -924,11 +924,11 @@ TEST_F(CtrlChannelDhcpv6SrvTest, controlLeasesReclaimRemove) { // (valid lifetime = 60, cltt = now - 100). DuidPtr duid0(new DUID(DUID::fromText("00:01:02:03:04:05:06").getDuid())); Lease6Ptr lease0(new Lease6(Lease::TYPE_NA, IOAddress("3000::1"), - duid0, 1, 50, 60, 10, 20, SubnetID(1))); + duid0, 1, 50, 60, SubnetID(1))); lease0->cltt_ = time(NULL) - 100; DuidPtr duid1(new DUID(DUID::fromText("01:02:03:04:05:06:07").getDuid())); Lease6Ptr lease1(new Lease6(Lease::TYPE_NA, IOAddress("3000::2"), - duid1, 1, 50, 60, 10, 20, SubnetID(1))); + duid1, 1, 50, 60, SubnetID(1))); lease1->cltt_ = time(NULL) - 100; // Add leases to the database. diff --git a/src/bin/dhcp6/tests/dhcp6_client.cc b/src/bin/dhcp6/tests/dhcp6_client.cc index fa23d7acbc..a8b34c05d8 100644 --- a/src/bin/dhcp6/tests/dhcp6_client.cc +++ b/src/bin/dhcp6/tests/dhcp6_client.cc @@ -169,8 +169,7 @@ Dhcp6Client::applyRcvdConfiguration(const Pkt6Ptr& reply, uint32_t state) { iaaddr->getAddress(), duid_, ia->getIAID(), iaaddr->getPreferred(), - iaaddr->getValid(), - ia->getT1(), ia->getT2(), 0, + iaaddr->getValid(), 0, hwaddr); lease.cltt_ = time(NULL); lease.state_ = state; @@ -189,8 +188,7 @@ Dhcp6Client::applyRcvdConfiguration(const Pkt6Ptr& reply, uint32_t state) { iaprefix->getAddress(), duid_, ia->getIAID(), iaprefix->getPreferred(), - iaprefix->getValid(), - ia->getT1(), ia->getT2(), 0, + iaprefix->getValid(), 0, hwaddr, iaprefix->getLength()); lease.cltt_ = time(NULL); @@ -361,8 +359,6 @@ Dhcp6Client::copyIAsFromLeases(const Pkt6Ptr& dest) const { } Option6IAPtr opt(new Option6IA(leases[0].type_ == Lease::TYPE_NA ? D6O_IA_NA : D6O_IA_PD, *iaid)); - opt->setT1(leases[0].t1_); - opt->setT2(leases[0].t2_); for (std::vector::const_iterator lease = leases.begin(); lease != leases.end(); ++lease) { if ((lease->preferred_lft_ != 0) && (lease->valid_lft_ != 0)) { @@ -874,15 +870,11 @@ bool Dhcp6Client::getTeeTimes(const uint32_t iaid, uint32_t& t1, uint32_t& t2) const { auto leases = getLeasesByIAID(iaid); - if (leases.empty()) { + if (leases.empty()) { // No aquired leases so punt. return (false); } - // All leases for a given iaid should have the same values for T1 - // and T2, so using them from the first one should be fine. - t1 = leases[0].t1_; - t2 = leases[0].t2_; return (true); } diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.cc b/src/bin/dhcp6/tests/dhcp6_test_utils.cc index 3891f2aef5..040aa823f5 100644 --- a/src/bin/dhcp6/tests/dhcp6_test_utils.cc +++ b/src/bin/dhcp6/tests/dhcp6_test_utils.cc @@ -261,7 +261,7 @@ Dhcpv6SrvTest::testRenewBasic(Lease::Type type, const std::string& existing_addr if (insert_before_renew) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during RENEW. - Lease6Ptr lease(new Lease6(type, existing, duid_, iaid, 501, 502, 503, 504, + Lease6Ptr lease(new Lease6(type, existing, duid_, iaid, 501, 502, subnet_->getID(), HWAddrPtr(), prefix_len)); lease->cltt_ = 1234; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -270,10 +270,8 @@ Dhcpv6SrvTest::testRenewBasic(Lease::Type type, const std::string& existing_addr l = LeaseMgrFactory::instance().getLease6(type, existing); ASSERT_TRUE(l); - // Check that T1, T2, preferred, valid and cltt really set and not using + // Check that preferred, valid and cltt really set and not using // previous (500, 501, etc.) values - EXPECT_NE(l->t1_, subnet_->getT1()); - EXPECT_NE(l->t2_, subnet_->getT2()); EXPECT_NE(l->preferred_lft_, subnet_->getPreferred()); EXPECT_NE(l->valid_lft_, subnet_->getValid()); EXPECT_NE(l->cltt_, time(NULL)); @@ -331,9 +329,7 @@ Dhcpv6SrvTest::testRenewBasic(Lease::Type type, const std::string& existing_addr isc_throw(BadValue, "Invalid lease type"); } - // Check that T1, T2, preferred, valid and cltt were really updated - EXPECT_EQ(subnet_->getT1(), l->t1_); - EXPECT_EQ(subnet_->getT2(), l->t2_); + // Check that preferred, valid and cltt were really updated EXPECT_EQ(subnet_->getPreferred(), l->preferred_lft_); EXPECT_EQ(subnet_->getValid(), l->valid_lft_); @@ -370,7 +366,7 @@ Dhcpv6SrvTest::testRenewWrongIAID(Lease::Type type, const IOAddress& addr) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during RENEW. Lease6Ptr lease(new Lease6(type, addr, duid_, valid_iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), prefix_len)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -419,7 +415,7 @@ Dhcpv6SrvTest::testRenewSomeoneElsesLease(Lease::Type type, const IOAddress& add // Let's create a lease. Lease6Ptr lease(new Lease6(type, addr, duid_, valid_iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), prefix_len)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -481,7 +477,7 @@ Dhcpv6SrvTest::testReleaseBasic(Lease::Type type, const IOAddress& existing, // Let's prepopulate the database Lease6Ptr lease(new Lease6(type, existing, duid_, iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), prefix_len)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -609,8 +605,8 @@ Dhcpv6SrvTest::testReleaseReject(Lease::Type type, const IOAddress& addr) { // CASE 2: Lease is known and belongs to this client, but to a different IAID SCOPED_TRACE("CASE 2: Lease is known and belongs to this client, but to a different IAID"); - Lease6Ptr lease(new Lease6(type, addr, duid_, valid_iaid, 501, 502, 503, - 504, subnet_->getID(), HWAddrPtr(), prefix_len)); + Lease6Ptr lease(new Lease6(type, addr, duid_, valid_iaid, 501, 502, + subnet_->getID(), HWAddrPtr(), prefix_len)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); // Let's create a different RELEASE, with a bogus iaid diff --git a/src/bin/dhcp6/tests/fqdn_unittest.cc b/src/bin/dhcp6/tests/fqdn_unittest.cc index c5b4083add..cb34d62ddd 100644 --- a/src/bin/dhcp6/tests/fqdn_unittest.cc +++ b/src/bin/dhcp6/tests/fqdn_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -85,8 +85,8 @@ public: // generateClientId assigns DUID to duid_. generateClientId(); lease_.reset(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"), - duid_, 1234, 501, 502, 503, - 504, 1, HWAddrPtr(), 0)); + duid_, 1234, 501, 502, + 1, HWAddrPtr(), 0)); // Config DDNS to be enabled, all controls off enableD2(); } diff --git a/src/bin/dhcp6/tests/hooks_unittest.cc b/src/bin/dhcp6/tests/hooks_unittest.cc index e28c00baf9..6fc034e340 100644 --- a/src/bin/dhcp6/tests/hooks_unittest.cc +++ b/src/bin/dhcp6/tests/hooks_unittest.cc @@ -2682,7 +2682,7 @@ TEST_F(HooksDhcpv6SrvTest, basicLease6Renew) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during RENEW. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = 1234; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -2785,7 +2785,7 @@ TEST_F(HooksDhcpv6SrvTest, leaseUpdateLease6Renew) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during RENEW. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = 1234; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -2885,7 +2885,7 @@ TEST_F(HooksDhcpv6SrvTest, skipLease6Renew) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during RENEW. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = 1234; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -3311,7 +3311,7 @@ TEST_F(HooksDhcpv6SrvTest, basicLease6Release) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during RENEW. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = 1234; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -3392,7 +3392,7 @@ TEST_F(HooksDhcpv6SrvTest, basicLease6ReleasePD) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during RENEW. Lease6Ptr lease(new Lease6(Lease::TYPE_PD, prefix, duid_, iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 80)); lease->cltt_ = 1234; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -3474,7 +3474,7 @@ TEST_F(HooksDhcpv6SrvTest, skipLease6Release) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during RENEW. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = 1234; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -3541,7 +3541,7 @@ TEST_F(HooksDhcpv6SrvTest, dropLease6Release) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during RENEW. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = 1234; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -3808,7 +3808,7 @@ TEST_F(HooksDhcpv6SrvTest, basicLease6Rebind) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during REBIND. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = 1234; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -3906,7 +3906,7 @@ TEST_F(HooksDhcpv6SrvTest, leaseUpdateLease6Rebind) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during REBIND. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = 1234; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -4004,7 +4004,7 @@ TEST_F(HooksDhcpv6SrvTest, skipLease6Rebind) { // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // value on purpose. They should be updated during REBIND. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = 1234; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); diff --git a/src/bin/dhcp6/tests/kea_controller_unittest.cc b/src/bin/dhcp6/tests/kea_controller_unittest.cc index fb58c802a1..b9d6749460 100644 --- a/src/bin/dhcp6/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp6/tests/kea_controller_unittest.cc @@ -716,7 +716,7 @@ TEST_F(JSONFileBackendTest, timers) { // current configuration. DuidPtr duid_expired(new DUID(DUID::fromText("00:01:02:03:04:05:06").getDuid())); Lease6Ptr lease_expired(new Lease6(Lease::TYPE_NA, IOAddress("3000::1"), - duid_expired, 1, 50, 60, 10, 20, SubnetID(1))); + duid_expired, 1, 50, 60, SubnetID(1))); lease_expired->cltt_ = time(NULL) - 100; @@ -725,7 +725,7 @@ TEST_F(JSONFileBackendTest, timers) { // goes off. DuidPtr duid_reclaimed(new DUID(DUID::fromText("01:02:03:04:05:06:07").getDuid())); Lease6Ptr lease_reclaimed(new Lease6(Lease::TYPE_NA, IOAddress("3000::2"), - duid_reclaimed, 1, 50, 60, 10, 20, SubnetID(1))); + duid_reclaimed, 1, 50, 60, SubnetID(1))); lease_reclaimed->cltt_ = time(NULL) - 1000; lease_reclaimed->state_ = Lease6::STATE_EXPIRED_RECLAIMED; diff --git a/src/hooks/dhcp/high_availability/tests/command_creator_unittest.cc b/src/hooks/dhcp/high_availability/tests/command_creator_unittest.cc index da9e19ea71..d44070ed31 100644 --- a/src/hooks/dhcp/high_availability/tests/command_creator_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/command_creator_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -35,7 +35,7 @@ Lease4Ptr createLease4() { HWAddrPtr hwaddr(new HWAddr(std::vector(6, 11), HTYPE_ETHER)); Lease4Ptr lease4(new Lease4(IOAddress("192.1.2.3"), hwaddr, static_cast(0), 0, - 60, 30, 40, 0, 1)); + 60, 0, 1)); return (lease4); } @@ -48,7 +48,7 @@ Lease4Ptr createLease4() { Lease6Ptr createLease6() { DuidPtr duid(new DUID(std::vector(8, 02))); Lease6Ptr lease6(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::cafe"), - duid, 1234, 50, 60, 30, 40, 1)); + duid, 1234, 50, 60, 1)); return (lease6); } diff --git a/src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc b/src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc index f1be7c121a..36f2ad1f47 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_impl_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -351,7 +351,7 @@ TEST_F(HAImplTest, leases4Committed) { HWAddrPtr hwaddr(new HWAddr(std::vector(6, 1), HTYPE_ETHER)); Lease4Ptr lease4(new Lease4(IOAddress("192.1.2.3"), hwaddr, static_cast(0), 0, - 60, 30, 40, 0, 1)); + 60, 0, 1)); leases4->push_back(lease4); callout_handle->setArgument("leases4", leases4); @@ -417,7 +417,7 @@ TEST_F(HAImplTest, leases6Committed) { // updates. DuidPtr duid(new DUID(std::vector(8, 2))); Lease6Ptr lease6(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::cafe"), duid, - 1234, 50, 60, 30, 40, 1)); + 1234, 50, 60, 1)); leases6->push_back(lease6); callout_handle->setArgument("leases6", leases6); diff --git a/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc b/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc index 2feacd6aa1..c0c796b3be 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc @@ -79,7 +79,7 @@ void generateTestLeases(std::vector& leases) { Lease4Ptr lease(new Lease4(IOAddress(lease_address), HWAddrPtr(new HWAddr(hwaddr, HTYPE_ETHER)), ClientIdPtr(), - 60, 30, 40, + 60, static_cast(1000 + i), SubnetID(i))); leases.push_back(lease); @@ -96,7 +96,7 @@ void generateTestLeases(std::vector& leases) { address_bytes[6] += i; Lease6Ptr lease(new Lease6(Lease::TYPE_NA, IOAddress::fromBytes(AF_INET6, &address_bytes[0]), - duid, 1, 50, 60, 30, 40, SubnetID(i))); + duid, 1, 50, 60, SubnetID(i))); leases.push_back(lease); } } @@ -673,14 +673,14 @@ public: HWAddrPtr hwaddr(new HWAddr(std::vector(6, 1), HTYPE_ETHER)); Lease4Ptr lease4(new Lease4(IOAddress("192.1.2.3"), hwaddr, static_cast(0), 0, - 60, 30, 40, 0, 1)); + 60, 0, 1)); leases4->push_back(lease4); // Create deleted leases collection and put the lease there too. Lease4CollectionPtr deleted_leases4(new Lease4Collection()); Lease4Ptr deleted_lease4(new Lease4(IOAddress("192.2.3.4"), hwaddr, static_cast(0), 0, - 60, 30, 40, 0, 1)); + 60, 0, 1)); deleted_leases4->push_back(deleted_lease4); // The communication state is the member of the HAServce object. We have to @@ -760,13 +760,13 @@ public: Lease6CollectionPtr leases6(new Lease6Collection()); DuidPtr duid(new DUID(std::vector(8, 2))); Lease6Ptr lease6(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::cafe"), duid, - 1234, 50, 60, 30, 40, 1)); + 1234, 50, 60, 1)); leases6->push_back(lease6); // Create deleted leases collection and put the lease there too. Lease6CollectionPtr deleted_leases6(new Lease6Collection()); Lease6Ptr deleted_lease6(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::efac"), - duid, 1234, 50, 60, 30, 40, 1)); + duid, 1234, 50, 60, 1)); deleted_leases6->push_back(deleted_lease6); // The communication state is the member of the HAServce object. We have to diff --git a/src/hooks/dhcp/lease_cmds/lease_parser.cc b/src/hooks/dhcp/lease_cmds/lease_parser.cc index 24b252ba2d..0d5348b115 100644 --- a/src/hooks/dhcp/lease_cmds/lease_parser.cc +++ b/src/hooks/dhcp/lease_cmds/lease_parser.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -162,10 +162,8 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg, } // Let's fabricate some data and we're ready to go. - uint32_t t1 = subnet->getT1(); - uint32_t t2 = subnet->getT2(); - Lease4Ptr l(new Lease4(addr, hwaddr_ptr, client_id, valid_lft, t1, t2, + Lease4Ptr l(new Lease4(addr, hwaddr_ptr, client_id, valid_lft, cltt, subnet_id, fqdn_fwd, fqdn_rev, hostname)); l->state_ = state; @@ -358,10 +356,8 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg, } // Let's fabricate some data and we're ready to go. - uint32_t t1 = subnet->getT1(); - uint32_t t2 = subnet->getT2(); - Lease6Ptr l(new Lease6(type, addr, duid_ptr, iaid, pref_lft, valid_lft, t1, t2, + Lease6Ptr l(new Lease6(type, addr, duid_ptr, iaid, pref_lft, valid_lft, subnet_id, fqdn_fwd, fqdn_rev, hostname, hwaddr_ptr, prefix_len)); l->cltt_ = cltt; diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc index 26a03ac2c0..75e4fe4f7b 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -314,10 +314,6 @@ public: lease->addr_ = IOAddress(ip_address); - // Initialize unused fields. - lease->t1_ = 0; // Not saved - lease->t2_ = 0; // Not saved - // Set other parameters. For historical reasons, address 0 is not used. lease->hwaddr_.reset(new HWAddr(vector(6, hw_address_pattern), HTYPE_ETHER)); lease->client_id_ = ClientIdPtr(new ClientId(vector(8, client_id_pattern))); diff --git a/src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc b/src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc index 46d1e54595..ae31773602 100644 --- a/src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc +++ b/src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -506,11 +506,6 @@ public: lease->addr_ = IOAddress(ip_address); - // Initialize unused fields. - lease->t1_ = 0; // Not saved - lease->t2_ = 0; // Not saved - - ++hwaddr_[5]; // Set other parameters. For historical reasons, address 0 is not used. diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 4895aee795..5cfff72812 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -1599,8 +1599,6 @@ AllocEngine::reuseExpiredLease(Lease6Ptr& expired, ClientContext6& ctx, expired->duid_ = ctx.duid_; expired->preferred_lft_ = ctx.subnet_->getPreferred(); expired->valid_lft_ = ctx.subnet_->getValid(); - expired->t1_ = ctx.subnet_->getT1(); - expired->t2_ = ctx.subnet_->getT2(); expired->cltt_ = time(NULL); expired->subnet_id_ = ctx.subnet_->getID(); expired->hostname_ = ctx.hostname_; @@ -1698,8 +1696,7 @@ Lease6Ptr AllocEngine::createLease6(ClientContext6& ctx, Lease6Ptr lease(new Lease6(ctx.currentIA().type_, addr, ctx.duid_, ctx.currentIA().iaid_, ctx.subnet_->getPreferred(), - ctx.subnet_->getValid(), ctx.subnet_->getT1(), - ctx.subnet_->getT2(), ctx.subnet_->getID(), + ctx.subnet_->getValid(), ctx.subnet_->getID(), ctx.hwaddr_, prefix_len)); lease->fqdn_fwd_ = ctx.fwd_dns_update_; @@ -1941,8 +1938,6 @@ AllocEngine::extendLease6(ClientContext6& ctx, Lease6Ptr lease) { lease->preferred_lft_ = ctx.subnet_->getPreferred(); lease->valid_lft_ = ctx.subnet_->getValid(); - lease->t1_ = ctx.subnet_->getT1(); - lease->t2_ = ctx.subnet_->getT2(); lease->hostname_ = ctx.hostname_; lease->fqdn_fwd_ = ctx.fwd_dns_update_; lease->fqdn_rev_ = ctx.rev_dns_update_; @@ -3452,8 +3447,7 @@ AllocEngine::createLease4(const ClientContext4& ctx, const IOAddress& addr, const uint8_t* local_copy0 = local_copy.empty() ? 0 : &local_copy[0]; Lease4Ptr lease(new Lease4(addr, ctx.hwaddr_, local_copy0, local_copy.size(), - ctx.subnet_->getValid(), ctx.subnet_->getT1(), - ctx.subnet_->getT2(), + ctx.subnet_->getValid(), now, ctx.subnet_->getID())); // Set FQDN specific lease parameters. @@ -3858,8 +3852,6 @@ AllocEngine::updateLease4Information(const Lease4Ptr& lease, lease->hwaddr_ = ctx.hwaddr_; lease->client_id_ = ctx.subnet_->getMatchClientId() ? ctx.clientid_ : ClientIdPtr(); lease->cltt_ = time(NULL); - lease->t1_ = ctx.subnet_->getT1(); - lease->t2_ = ctx.subnet_->getT2(); lease->valid_lft_ = ctx.subnet_->getValid(); lease->fqdn_fwd_ = ctx.fwd_dns_update_; lease->fqdn_rev_ = ctx.rev_dns_update_; diff --git a/src/lib/dhcpsrv/cql_lease_mgr.cc b/src/lib/dhcpsrv/cql_lease_mgr.cc index a80d3f2dee..3bea54355b 100644 --- a/src/lib/dhcpsrv/cql_lease_mgr.cc +++ b/src/lib/dhcpsrv/cql_lease_mgr.cc @@ -712,7 +712,7 @@ CqlLease4Exchange::retrieve() { } Lease4Ptr result(new Lease4(addr4, hwaddr, client_id_.data(), - client_id_.size(), valid_lifetime_, 0, 0, + client_id_.size(), valid_lifetime_, cltt, subnet_id_, fqdn_fwd_, fqdn_rev_, hostname_)); @@ -1501,7 +1501,7 @@ CqlLease6Exchange::retrieve() { // expire time retrieved from the database). Lease6Ptr result( new Lease6(static_cast(lease_type_), addr, duid, iaid_, - pref_lifetime_, valid_lifetime_, 0, 0, subnet_id_, + pref_lifetime_, valid_lifetime_, subnet_id_, fqdn_fwd_, fqdn_rev_, hostname_, hwaddr, prefix_len_)); time_t cltt = 0; diff --git a/src/lib/dhcpsrv/csv_lease_file4.cc b/src/lib/dhcpsrv/csv_lease_file4.cc index e9ca5a76a6..646da9f25d 100644 --- a/src/lib/dhcpsrv/csv_lease_file4.cc +++ b/src/lib/dhcpsrv/csv_lease_file4.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -117,7 +117,6 @@ CSVLeaseFile4::next(Lease4Ptr& lease) { client_id_vec.empty() ? NULL : &client_id_vec[0], client_id_len, readValid(row), - 0, 0, // t1, t2 = 0 readCltt(row), readSubnetID(row), readFqdnFwd(row), diff --git a/src/lib/dhcpsrv/csv_lease_file6.cc b/src/lib/dhcpsrv/csv_lease_file6.cc index e3b4ff435e..3e70c7c6ec 100644 --- a/src/lib/dhcpsrv/csv_lease_file6.cc +++ b/src/lib/dhcpsrv/csv_lease_file6.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -91,7 +91,7 @@ CSVLeaseFile6::next(Lease6Ptr& lease) { lease.reset(new Lease6(readType(row), readAddress(row), readDUID(row), readIAID(row), readPreferred(row), - readValid(row), 0, 0, // t1, t2 = 0 + readValid(row), readSubnetID(row), readHWAddr(row), readPrefixLen(row))); diff --git a/src/lib/dhcpsrv/lease.cc b/src/lib/dhcpsrv/lease.cc index b6a05b2330..4b1f0bd6b5 100644 --- a/src/lib/dhcpsrv/lease.cc +++ b/src/lib/dhcpsrv/lease.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -25,11 +25,11 @@ const uint32_t Lease::STATE_DEFAULT = 0x0; const uint32_t Lease::STATE_DECLINED = 0x1; const uint32_t Lease::STATE_EXPIRED_RECLAIMED = 0x2; -Lease::Lease(const isc::asiolink::IOAddress& addr, uint32_t t1, uint32_t t2, +Lease::Lease(const isc::asiolink::IOAddress& addr, uint32_t valid_lft, SubnetID subnet_id, time_t cltt, 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), + :addr_(addr), valid_lft_(valid_lft), cltt_(cltt), subnet_id_(subnet_id), hostname_(hostname), fqdn_fwd_(fqdn_fwd), fqdn_rev_(fqdn_rev), hwaddr_(hwaddr), state_(STATE_DEFAULT) { } @@ -264,7 +264,7 @@ Lease::fromElementCommon(const LeasePtr& lease, const data::ConstElementPtr& ele } Lease4::Lease4(const Lease4& other) - : Lease(other.addr_, other.t1_, other.t2_, other.valid_lft_, + : Lease(other.addr_, other.valid_lft_, other.subnet_id_, other.cltt_, other.fqdn_fwd_, other.fqdn_rev_, other.hostname_, other.hwaddr_) { @@ -295,15 +295,13 @@ Lease4::Lease4(const isc::asiolink::IOAddress& address, const HWAddrPtr& hw_address, const ClientIdPtr& client_id, const uint32_t valid_lifetime, - const uint32_t t1, - const uint32_t t2, const time_t cltt, const SubnetID subnet_id, const bool fqdn_fwd, const bool fqdn_rev, const std::string& hostname) - : Lease(address, t1, t2, valid_lifetime, subnet_id, cltt, fqdn_fwd, + : Lease(address, valid_lifetime, subnet_id, cltt, fqdn_fwd, fqdn_rev, hostname, hw_address), client_id_(client_id) { } @@ -353,8 +351,6 @@ void Lease4::decline(uint32_t probation_period) { hwaddr_.reset(new HWAddr()); client_id_.reset(); - t1_ = 0; - t2_ = 0; cltt_ = time(NULL); hostname_ = string(""); fqdn_fwd_ = false; @@ -367,8 +363,6 @@ Lease4& Lease4::operator=(const Lease4& other) { if (this != &other) { addr_ = other.addr_; - t1_ = other.t1_; - t2_ = other.t2_; valid_lft_ = other.valid_lft_; cltt_ = other.cltt_; subnet_id_ = other.subnet_id_; @@ -462,9 +456,8 @@ Lease4::fromElement(const ConstElementPtr& element) { Lease6::Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr, DuidPtr duid, uint32_t iaid, uint32_t preferred, uint32_t valid, - uint32_t t1, uint32_t t2, SubnetID subnet_id, - const HWAddrPtr& hwaddr, uint8_t prefixlen) - : Lease(addr, t1, t2, valid, subnet_id, 0/*cltt*/, false, false, "", hwaddr), + SubnetID subnet_id, const HWAddrPtr& hwaddr, uint8_t prefixlen) + : Lease(addr, valid, subnet_id, 0/*cltt*/, false, false, "", hwaddr), type_(type), prefixlen_(prefixlen), iaid_(iaid), duid_(duid), preferred_lft_(preferred) { if (!duid) { @@ -476,11 +469,10 @@ Lease6::Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr, Lease6::Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr, DuidPtr duid, uint32_t iaid, uint32_t preferred, uint32_t valid, - uint32_t t1, uint32_t t2, SubnetID subnet_id, - const bool fqdn_fwd, const bool fqdn_rev, + SubnetID subnet_id, const bool fqdn_fwd, const bool fqdn_rev, const std::string& hostname, const HWAddrPtr& hwaddr, uint8_t prefixlen) - : Lease(addr, t1, t2, valid, subnet_id, 0/*cltt*/, + : Lease(addr, valid, subnet_id, 0/*cltt*/, fqdn_fwd, fqdn_rev, hostname, hwaddr), type_(type), prefixlen_(prefixlen), iaid_(iaid), duid_(duid), preferred_lft_(preferred) { @@ -492,7 +484,7 @@ Lease6::Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr, } Lease6::Lease6() - : Lease(isc::asiolink::IOAddress("::"), 0, 0, 0, 0, 0, false, false, "", + : Lease(isc::asiolink::IOAddress("::"), 0, 0, 0, false, false, "", HWAddrPtr()), type_(TYPE_NA), prefixlen_(0), iaid_(0), duid_(DuidPtr()), preferred_lft_(0) { } @@ -516,8 +508,6 @@ void Lease6::decline(uint32_t probation_period) { hwaddr_.reset(); duid_.reset(new DUID(DUID::EMPTY())); - t1_ = 0; - t2_ = 0; preferred_lft_ = 0; valid_lft_ = probation_period; cltt_ = time(NULL); @@ -558,8 +548,6 @@ Lease4::toText() const { stream << "Address: " << addr_ << "\n" << "Valid life: " << valid_lft_ << "\n" - << "T1: " << t1_ << "\n" - << "T2: " << t2_ << "\n" << "Cltt: " << cltt_ << "\n" << "Hardware addr: " << (hwaddr_ ? hwaddr_->toText(false) : "(none)") << "\n" << "Client id: " << (client_id_ ? client_id_->toText() : "(none)") << "\n" @@ -580,8 +568,6 @@ Lease4::operator==(const Lease4& other) const { nullOrEqualValues(client_id_, other.client_id_) && addr_ == other.addr_ && subnet_id_ == other.subnet_id_ && - t1_ == other.t1_ && - t2_ == other.t2_ && valid_lft_ == other.valid_lft_ && cltt_ == other.cltt_ && hostname_ == other.hostname_ && @@ -601,8 +587,6 @@ Lease6::operator==(const Lease6& other) const { iaid_ == other.iaid_ && preferred_lft_ == other.preferred_lft_ && valid_lft_ == other.valid_lft_ && - t1_ == other.t1_ && - t2_ == other.t2_ && cltt_ == other.cltt_ && subnet_id_ == other.subnet_id_ && hostname_ == other.hostname_ && diff --git a/src/lib/dhcpsrv/lease.h b/src/lib/dhcpsrv/lease.h index fbac2cf35c..2f661daa5b 100644 --- a/src/lib/dhcpsrv/lease.h +++ b/src/lib/dhcpsrv/lease.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -78,8 +78,6 @@ struct Lease : public isc::data::UserContext, public isc::data::CfgToElement { /// @brief Constructor /// /// @param addr IP address - /// @param t1 renewal time - /// @param t2 rebinding time /// @param valid_lft Lifetime of the lease /// @param subnet_id Subnet identification /// @param cltt Client last transmission time @@ -87,7 +85,7 @@ struct Lease : public isc::data::UserContext, public isc::data::CfgToElement { /// @param fqdn_rev If true, reverse DNS update is performed for a lease. /// @param hostname FQDN of the client which gets the lease. /// @param hwaddr Hardware/MAC address - Lease(const isc::asiolink::IOAddress& addr, uint32_t t1, uint32_t t2, + Lease(const isc::asiolink::IOAddress& addr, uint32_t valid_lft, SubnetID subnet_id, time_t cltt, const bool fqdn_fwd, const bool fqdn_rev, const std::string& hostname, @@ -101,24 +99,6 @@ struct Lease : public isc::data::UserContext, public isc::data::CfgToElement { /// IPv4, IPv6 address or, in the case of a prefix delegation, the prefix. isc::asiolink::IOAddress addr_; - /// @brief Renewal timer - /// - /// Specifies renewal time. Although technically it is a property of the - /// IA container and not the address itself, since our data model does not - /// define a separate IA entity, we are keeping it in the lease. In the - /// case of multiple addresses/prefixes for the same IA, each must have - /// consistent T1 and T2 values. This is specified in seconds since cltt. - uint32_t t1_; - - /// @brief Rebinding timer - /// - /// Specifies rebinding time. Although technically it is a property of the - /// IA container and not the address itself, since our data model does not - /// define a separate IA entity, we are keeping it in the lease. In the - /// case of multiple addresses/prefixes for the same IA, each must have - /// consistent T1 and T2 values. This is specified in seconds since cltt. - uint32_t t2_; - /// @brief Valid lifetime /// /// Expressed as number of seconds since cltt. @@ -215,9 +195,9 @@ struct Lease : public isc::data::UserContext, public isc::data::CfgToElement { /// @brief Sets lease to DECLINED state. /// /// All client identifying parameters will be stripped off (HWaddr, - /// client_id, hostname), timers set to 0 (t1, t2), cltt will be set - /// to current time and valid_lft to parameter specified as probation - /// period. Note that This method only sets fields in the structure. + /// client_id, hostname), cltt will be set to current time and + /// valid_lft to parameter specified as probation period. + /// Note that This method only sets fields in the structure. /// It is caller's responsibility to clean up DDNS, bump up stats, /// log, call hooks ets. /// @@ -268,8 +248,6 @@ struct Lease4 : public Lease { /// @param clientid Client identification buffer /// @param clientid_len Length of client identification buffer /// @param valid_lft Lifetime of the lease - /// @param t1 renewal time - /// @param t2 rebinding time /// @param cltt Client last transmission time /// @param subnet_id Subnet identification /// @param fqdn_fwd If true, forward DNS update is performed for a lease. @@ -277,10 +255,10 @@ struct Lease4 : public Lease { /// @param hostname FQDN of the client which gets the lease. Lease4(const isc::asiolink::IOAddress& addr, const HWAddrPtr& hwaddr, const uint8_t* clientid, size_t clientid_len, uint32_t valid_lft, - uint32_t t1, uint32_t t2, time_t cltt, uint32_t subnet_id, + time_t cltt, uint32_t subnet_id, 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, + : Lease(addr, valid_lft, subnet_id, cltt, fqdn_fwd, fqdn_rev, hostname, hwaddr) { if (clientid_len) { client_id_.reset(new ClientId(clientid, clientid_len)); @@ -293,8 +271,6 @@ struct Lease4 : public Lease { /// @param hw_address Pointer to client's HW addresss. /// @param client_id pointer to the client id structure. /// @param valid_lifetime Valid lifetime value. - /// @param t1 Renew timer. - /// @param t2 Rebind timer. /// @param cltt Timestamp when the lease is acquired, renewed. /// @param subnet_id Subnet identifier. /// @param fqdn_fwd Forward DNS update performed. @@ -304,8 +280,6 @@ struct Lease4 : public Lease { const HWAddrPtr& hw_address, const ClientIdPtr& client_id, const uint32_t valid_lifetime, - const uint32_t t1, - const uint32_t t2, const time_t cltt, const SubnetID subnet_id, const bool fqdn_fwd = false, @@ -316,7 +290,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()) + Lease4() : Lease(0, 0, 0, 0, false, false, "", HWAddrPtr()) { } @@ -505,14 +479,12 @@ struct Lease6 : public Lease { /// @param iaid IAID. /// @param preferred Preferred lifetime. /// @param valid Valid lifetime. - /// @param t1 A value of the T1 timer. - /// @param t2 A value of the T2 timer. /// @param subnet_id A Subnet identifier. /// @param hwaddr hardware/MAC address (optional) /// @param prefixlen An address prefix length (optional, defaults to 128) Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr, DuidPtr duid, - uint32_t iaid, uint32_t preferred, uint32_t valid, uint32_t t1, - uint32_t t2, SubnetID subnet_id, const HWAddrPtr& hwaddr = HWAddrPtr(), + uint32_t iaid, uint32_t preferred, uint32_t valid, + SubnetID subnet_id, const HWAddrPtr& hwaddr = HWAddrPtr(), uint8_t prefixlen = 128); /// @brief Constructor, including FQDN data. @@ -523,8 +495,6 @@ struct Lease6 : public Lease { /// @param iaid IAID. /// @param preferred Preferred lifetime. /// @param valid Valid lifetime. - /// @param t1 A value of the T1 timer. - /// @param t2 A value of the T2 timer. /// @param subnet_id A Subnet identifier. /// @param fqdn_fwd If true, forward DNS update is performed for a lease. /// @param fqdn_rev If true, reverse DNS update is performed for a lease. @@ -532,8 +502,8 @@ struct Lease6 : public Lease { /// @param hwaddr hardware address (MAC), may be NULL /// @param prefixlen An address prefix length (optional, defaults to 128) Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr, DuidPtr duid, - uint32_t iaid, uint32_t preferred, uint32_t valid, uint32_t t1, - uint32_t t2, SubnetID subnet_id, const bool fqdn_fwd, + uint32_t iaid, uint32_t preferred, uint32_t valid, + SubnetID subnet_id, const bool fqdn_fwd, const bool fqdn_rev, const std::string& hostname, const HWAddrPtr& hwaddr = HWAddrPtr(), uint8_t prefixlen = 128); diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc index 8d73ea643b..8d741fa085 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.cc +++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc @@ -779,10 +779,9 @@ public: } } - // note that T1 and T2 are not stored Lease4Ptr lease(new Lease4(addr4_, hwaddr, client_id_buffer_, client_id_length_, - valid_lifetime_, 0, 0, cltt, subnet_id_, + valid_lifetime_, cltt, subnet_id_, fqdn_fwd_, fqdn_rev_, hostname)); // Set state. @@ -1381,7 +1380,7 @@ public: // Create the lease and set the cltt (after converting from the // expire time retrieved from the database). Lease6Ptr result(new Lease6(type, addr, duid_ptr, iaid_, - pref_lifetime_, valid_lifetime_, 0, 0, + pref_lifetime_, valid_lifetime_, subnet_id_, fqdn_fwd_, fqdn_rev_, hostname, hwaddr, prefixlen_)); time_t cltt = 0; diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index 3878f7d589..f49f6f4360 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -550,7 +550,7 @@ public: Lease4Ptr result(new Lease4(addr4_, hwaddr, client_id_buffer_, client_id_length_, - valid_lifetime_, 0, 0, cltt_, + valid_lifetime_, cltt_, subnet_id_, fqdn_fwd_, fqdn_rev_, hostname_)); @@ -830,7 +830,7 @@ public: Lease6Ptr result(new Lease6(lease_type_, addr, duid_ptr, iaid_u_.uval_, pref_lifetime_, - valid_lifetime_, 0, 0, + valid_lifetime_, subnet_id_, fqdn_fwd_, fqdn_rev_, hostname_, hwaddr, prefix_len_)); result->cltt_ = cltt_; diff --git a/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc index 76b498f32b..fb59021308 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc @@ -212,7 +212,7 @@ TEST_F(AllocEngine4Test, allocWithUsedHint4) { uint8_t clientid2[] = { 8, 7, 6, 5, 4, 3, 2, 1 }; time_t now = time(NULL); Lease4Ptr used(new Lease4(IOAddress("192.0.2.106"), hwaddr2, - clientid2, sizeof(clientid2), 1, 2, 3, now, subnet_->getID())); + clientid2, sizeof(clientid2), 1, now, subnet_->getID())); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used)); // Another client comes in and request an address that is in pool, but @@ -529,7 +529,7 @@ TEST_F(AllocEngine4Test, outOfAddresses4) { uint8_t clientid2[] = { 8, 7, 6, 5, 4, 3, 2, 1 }; time_t now = time(NULL); Lease4Ptr lease(new Lease4(addr, hwaddr2, clientid2, - sizeof(clientid2), 501, 502, 503, now, + sizeof(clientid2), 501, now, subnet_->getID())); lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -592,7 +592,7 @@ public: Lease4Ptr insertLease(std::string addr, SubnetID subnet_id) { Lease4Ptr lease(new Lease4(IOAddress(addr), hwaddr2_, ClientIdPtr(), - 501, 502, 503, time(NULL), subnet_id)); + 501, time(NULL), subnet_id)); lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago if (!LeaseMgrFactory::instance().addLease(lease)) { ADD_FAILURE() << "Attempt to add a lease for IP " << addr @@ -832,7 +832,7 @@ TEST_F(SharedNetworkAlloc4Test, discoverSharedNetworkReservations) { // Let's create a lease for the client to make sure the lease is not // renewed but a reserved lease is offerred. Lease4Ptr lease2(new Lease4(IOAddress("192.0.2.17"), hwaddr_, ClientIdPtr(), - 501, 502, 503, time(NULL), subnet1_->getID())); + 501, time(NULL), subnet1_->getID())); lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease2)); ctx.subnet_ = subnet1_; @@ -875,7 +875,7 @@ TEST_F(SharedNetworkAlloc4Test, discoverSharedNetworkReservationsNoColl) { // Let's create a lease for the client to make sure the lease is not // renewed but a reserved lease is offerred. Lease4Ptr lease2(new Lease4(IOAddress("192.0.2.17"), hwaddr_, ClientIdPtr(), - 501, 502, 503, time(NULL), subnet1_->getID())); + 501, time(NULL), subnet1_->getID())); lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease2)); ctx.subnet_ = subnet1_; @@ -1136,7 +1136,7 @@ TEST_F(SharedNetworkAlloc4Test, requestSharedNetworkReservations) { // Let's create a lease for the client to make sure the lease is not // renewed but a reserved lease is allocated again. Lease4Ptr lease2(new Lease4(IOAddress("192.0.2.17"), hwaddr_, ClientIdPtr(), - 501, 502, 503, time(NULL), subnet1_->getID())); + 501, time(NULL), subnet1_->getID())); lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease2)); ctx.subnet_ = subnet1_; @@ -1182,7 +1182,7 @@ TEST_F(SharedNetworkAlloc4Test, requestSharedNetworkReservationsNoColl) { // Let's create a lease for the client to make sure the lease is not // renewed but a reserved lease is allocated again. Lease4Ptr lease2(new Lease4(IOAddress("192.0.2.17"), hwaddr_, ClientIdPtr(), - 501, 502, 503, time(NULL), subnet1_->getID())); + 501, time(NULL), subnet1_->getID())); lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease2)); ctx.subnet_ = subnet1_; @@ -1217,7 +1217,7 @@ TEST_F(AllocEngine4Test, discoverReuseExpiredLease4) { uint8_t clientid2[] = { 8, 7, 6, 5, 4, 3, 2, 1 }; time_t now = time(NULL) - 500; // Allocated 500 seconds ago Lease4Ptr lease(new Lease4(addr, hwaddr2, clientid2, sizeof(clientid2), - 495, 100, 200, now, subnet_->getID())); + 495, now, subnet_->getID())); // Copy the lease, so as it can be compared with the old lease returned // by the allocation engine. Lease4 original_lease(*lease); @@ -1282,7 +1282,7 @@ TEST_F(AllocEngine4Test, requestReuseExpiredLease4) { time_t now = time(NULL) - 500; // Allocated 500 seconds ago Lease4Ptr lease(new Lease4(addr, hwaddr2, clientid2, sizeof(clientid2), - 495, 100, 200, now, subnet_->getID())); + 495, now, subnet_->getID())); // Make a copy of the lease, so as we can compare that with the old lease // instance returned by the allocation engine. Lease4 original_lease(*lease); @@ -1476,7 +1476,7 @@ TEST_F(AllocEngine4Test, requestReuseDeclinedLease4Stats) { // identifier and HW address. TEST_F(AllocEngine4Test, identifyClientLease) { Lease4Ptr lease(new Lease4(IOAddress("192.0.2.101"), hwaddr_, clientid_, - 100, 30, 60, time(NULL), subnet_->getID())); + 100, time(NULL), subnet_->getID())); LeaseMgrFactory::instance().addLease(lease); AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); @@ -1544,7 +1544,7 @@ TEST_F(AllocEngine4Test, requestOtherClientLease) { Lease4Ptr lease(new Lease4(IOAddress("192.0.2.101"), hwaddr_, &clientid_->getClientId()[0], clientid_->getClientId().size(), - 100, 30, 60, time(NULL), subnet_->getID(), + 100, time(NULL), subnet_->getID(), false, false, "")); // Create the second lease. Note that we use the same client id here and // we expect that the allocation engine will figure out that the hardware @@ -1552,7 +1552,7 @@ TEST_F(AllocEngine4Test, requestOtherClientLease) { Lease4Ptr lease2(new Lease4(IOAddress("192.0.2.102"), hwaddr2_, &clientid_->getClientId()[0], clientid_->getClientId().size(), - 100, 30, 60, time(NULL), subnet_->getID(), + 100, time(NULL), subnet_->getID(), false, false, "")); // Add leases for both clients to the Lease Manager. LeaseMgrFactory::instance().addLease(lease); @@ -1769,7 +1769,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLease) { Lease4Ptr lease(new Lease4(IOAddress("192.0.2.101"), hwaddr_, &clientid_->getClientId()[0], clientid_->getClientId().size(), - 100, 30, 60, time(NULL), subnet_->getID(), + 100, time(NULL), subnet_->getID(), false, false, "")); LeaseMgrFactory::instance().addLease(lease); @@ -1818,7 +1818,7 @@ TEST_F(AllocEngine4Test, reservedAddressHijacked) { // Allocate a lease for the client A for the same address as reserved // for the client B. Lease4Ptr lease(new Lease4(IOAddress("192.0.2.123"), hwaddr2_, 0, 0, - 100, 30, 60, time(NULL), subnet_->getID(), + 100, time(NULL), subnet_->getID(), false, false, "")); LeaseMgrFactory::instance().addLease(lease); @@ -1875,7 +1875,7 @@ TEST_F(AllocEngine4Test, reservedAddressHijackedFakeAllocation) { // Create a lease for the client A. Lease4Ptr lease(new Lease4(IOAddress("192.0.2.123"), hwaddr2_, 0, 0, - 100, 30, 60, time(NULL), subnet_->getID(), + 100, time(NULL), subnet_->getID(), false, false, "")); LeaseMgrFactory::instance().addLease(lease); @@ -1935,7 +1935,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLeaseInvalidHint) { // Create a lease for the client for a different address than reserved. Lease4Ptr lease(new Lease4(IOAddress("192.0.2.101"), hwaddr_, ClientIdPtr(), - 100, 30, 60, time(NULL), subnet_->getID(), + 100, time(NULL), subnet_->getID(), false, false, "")); LeaseMgrFactory::instance().addLease(lease); @@ -1991,7 +1991,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLeaseFakeAllocation) { Lease4Ptr lease(new Lease4(IOAddress("192.0.2.101"), hwaddr_, &clientid_->getClientId()[0], clientid_->getClientId().size(), - 100, 30, 60, time(NULL), subnet_->getID(), + 100, time(NULL), subnet_->getID(), false, false, "")); LeaseMgrFactory::instance().addLease(lease); @@ -2056,7 +2056,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLeaseNoHint) { Lease4Ptr lease(new Lease4(IOAddress("192.0.2.101"), hwaddr_, &clientid_->getClientId()[0], clientid_->getClientId().size(), - 100, 30, 60, time(NULL), subnet_->getID(), + 100, time(NULL), subnet_->getID(), false, false, "")); LeaseMgrFactory::instance().addLease(lease); @@ -2108,7 +2108,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLeaseNoHintFakeAllocation) { Lease4Ptr lease(new Lease4(IOAddress("192.0.2.101"), hwaddr_, &clientid_->getClientId()[0], clientid_->getClientId().size(), - 100, 30, 60, time(NULL), subnet_->getID(), + 100, time(NULL), subnet_->getID(), false, false, "")); LeaseMgrFactory::instance().addLease(lease); @@ -2172,7 +2172,7 @@ TEST_F(AllocEngine4Test, reservedAddressConflictResolution) { Lease4Ptr lease(new Lease4(IOAddress("192.0.2.101"), hwaddr_, &clientid_->getClientId()[0], clientid_->getClientId().size(), - 100, 30, 60, time(NULL), subnet_->getID(), + 100, time(NULL), subnet_->getID(), false, false, "")); LeaseMgrFactory::instance().addLease(lease); @@ -2547,7 +2547,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLeaseStat) { Lease4Ptr lease(new Lease4(IOAddress("192.0.2.101"), hwaddr_, &clientid_->getClientId()[0], clientid_->getClientId().size(), - 100, 30, 60, time(NULL), subnet_->getID(), + 100, time(NULL), subnet_->getID(), false, false, "")); LeaseMgrFactory::instance().addLease(lease); diff --git a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc index 698a5a3700..39ef215470 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc @@ -807,7 +807,7 @@ TEST_F(AllocEngine6Test, outOfAddresses6) { DuidPtr other_duid = DuidPtr(new DUID(vector(12, 0xff))); const uint32_t other_iaid = 3568; Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, other_duid, other_iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); @@ -849,7 +849,7 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) { DuidPtr other_duid = DuidPtr(new DUID(vector(12, 0xff))); const uint32_t other_iaid = 3568; Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, other_duid, other_iaid, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = time(NULL) - 500; // Allocated 500 seconds ago lease->valid_lft_ = 495; // Lease was valid for 495 seconds @@ -912,7 +912,7 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) { const SubnetID other_subnetid = 999; Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, other_duid, other_iaid, - 501, 502, 503, 504, other_subnetid, HWAddrPtr(), + 501, 502, other_subnetid, HWAddrPtr(), 0)); lease->cltt_ = time(NULL) - 500; // Allocated 500 seconds ago @@ -968,7 +968,7 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) { TEST_F(AllocEngine6Test, requestExtendLeaseLifetime) { // Create a lease for the client. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::15"), - duid_, iaid_, 300, 400, 100, 200, + duid_, iaid_, 300, 400, subnet_->getID(), HWAddrPtr(), 128)); // Allocated 200 seconds ago - half of the lifetime. @@ -995,7 +995,7 @@ TEST_F(AllocEngine6Test, requestExtendLeaseLifetimeForReservation) { // Create a lease for the client. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1c"), - duid_, iaid_, 300, 400, 100, 200, + duid_, iaid_, 300, 400, subnet_->getID(), HWAddrPtr(), 128)); // Allocated 200 seconds ago - half of the lifetime. @@ -1018,7 +1018,7 @@ TEST_F(AllocEngine6Test, requestExtendLeaseLifetimeForReservation) { TEST_F(AllocEngine6Test, renewExtendLeaseLifetime) { // Create a lease for the client. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::15"), - duid_, iaid_, 300, 400, 100, 200, + duid_, iaid_, 300, 400, subnet_->getID(), HWAddrPtr(), 128)); // Allocated 200 seconds ago - half of the lifetime. @@ -1051,7 +1051,7 @@ TEST_F(AllocEngine6Test, renewExtendLeaseLifetimeForReservation) { // Create a lease for the client. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::15"), - duid_, iaid_, 300, 400, 100, 200, + duid_, iaid_, 300, 400, subnet_->getID(), HWAddrPtr(), 128)); // Allocated 200 seconds ago - half of the lifetime. @@ -2074,7 +2074,7 @@ TEST_F(AllocEngine6Test, largeAllocationAttemptsOverride) { // Allocate the lease. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, IOAddress(address.str()), - duid, iaid, 501, 502, 503, 504, subnet_->getID(), + duid, iaid, 501, 502, subnet_->getID(), HWAddrPtr(), 0)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); } @@ -2272,7 +2272,7 @@ TEST_F(AllocEngine6Test, reuseReclaimedExpiredViaRequest) { // Let's create an expired lease Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid_, - 501, 502, 503, 504, subnet_->getID(), HWAddrPtr(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = time(NULL) - 500; // Allocated 500 seconds ago lease->valid_lft_ = 495; // Lease was valid for 495 seconds @@ -2343,7 +2343,7 @@ public: Lease6Ptr insertLease(std::string addr, SubnetID subnet_id) { Lease6Ptr lease(new Lease6(Lease::TYPE_NA, IOAddress(addr), duid_, iaid_, - 501, 502, 503, 504, subnet_->getID(), + 501, 502, subnet_->getID(), HWAddrPtr(), 0)); lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago if (!LeaseMgrFactory::instance().addLease(lease)) { @@ -2416,7 +2416,7 @@ TEST_F(SharedNetworkAlloc6Test, solicitSharedNetworkOutOfAddresses) { DuidPtr other_duid(new DUID(vector(12, 0xff))); const uint32_t other_iaid = 3568; Lease6Ptr lease(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"), - other_duid, other_iaid, 501, 502, 503, 504, + other_duid, other_iaid, 501, 502, subnet1_->getID(), HWAddrPtr(), 0)); lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago @@ -2702,7 +2702,7 @@ TEST_F(SharedNetworkAlloc6Test, requestSharedNetworkExistingLeases) { // reclaimed state initially to allow for checking whether the lease // gets renewed. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:2::1"), - duid_, iaid_, 501, 502, 503, 504, + duid_, iaid_, 501, 502, subnet2_->getID(), HWAddrPtr(), 128)); lease->state_ = Lease::STATE_EXPIRED_RECLAIMED; ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); diff --git a/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc index ba416fcdbd..ab44236f12 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc @@ -1270,8 +1270,8 @@ ExpirationAllocEngine6Test::createLeases() { IOAddress address(address_s.str()); // Create lease. - Lease6Ptr lease(new Lease6(Lease::TYPE_NA, address, duid, 1, 50, 60, 10, - 20, SubnetID(1), true, true, + Lease6Ptr lease(new Lease6(Lease::TYPE_NA, address, duid, 1, 50, 60, + SubnetID(1), true, true, generateHostnameForLeaseIndex(i))); leases_.push_back(lease); // Copy the lease before adding it to the lease manager. We want to @@ -1832,7 +1832,7 @@ ExpirationAllocEngine4Test::createLeases() { IOAddress address(address_s.str()); // Create lease. - Lease4Ptr lease(new Lease4(address, hwaddr, ClientIdPtr(), 60, 10, 20, + Lease4Ptr lease(new Lease4(address, hwaddr, ClientIdPtr(), 60, time(NULL), SubnetID(1), true, true, generateHostnameForLeaseIndex(i))); leases_.push_back(lease); diff --git a/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc index 7d4bb39212..df3948b3fa 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -99,8 +99,6 @@ public: callout_handle.getArgument("lease6", lease); callback_addr_updated_ = addr_override_; lease->addr_ = callback_addr_updated_; - lease->t1_ = t1_override_; - lease->t2_ = t2_override_; lease->preferred_lft_ = pref_override_; lease->valid_lft_ = valid_override_; @@ -124,8 +122,6 @@ public: // Values to be used in callout to override lease6 content static const IOAddress addr_override_; - static const uint32_t t1_override_; - static const uint32_t t2_override_; static const uint32_t pref_override_; static const uint32_t valid_override_; @@ -150,8 +146,6 @@ public: // linker complains about undefined references if they are defined within // the class declaration. const IOAddress HookAllocEngine6Test::addr_override_("2001:db8::abcd"); -const uint32_t HookAllocEngine6Test::t1_override_ = 6000; -const uint32_t HookAllocEngine6Test::t2_override_ = 7000; const uint32_t HookAllocEngine6Test::pref_override_ = 8000; const uint32_t HookAllocEngine6Test::valid_override_ = 9000; @@ -253,8 +247,6 @@ TEST_F(HookAllocEngine6Test, change_lease6_select) { // Make sure that the overridden values are different than the ones from // subnet originally used to create the lease - ASSERT_NE(t1_override_, subnet_->getT1()); - ASSERT_NE(t2_override_, subnet_->getT2()); ASSERT_NE(pref_override_, subnet_->getPreferred()); ASSERT_NE(valid_override_, subnet_->getValid()); ASSERT_FALSE(subnet_->inRange(addr_override_)); @@ -284,8 +276,6 @@ TEST_F(HookAllocEngine6Test, change_lease6_select) { // See if the values overridden by callout are there EXPECT_TRUE(lease->addr_.equals(addr_override_)); - EXPECT_EQ(t1_override_, lease->t1_); - EXPECT_EQ(t2_override_, lease->t2_); EXPECT_EQ(pref_override_, lease->preferred_lft_); EXPECT_EQ(valid_override_, lease->valid_lft_); @@ -296,8 +286,6 @@ TEST_F(HookAllocEngine6Test, change_lease6_select) { // Check if values in the database are overridden EXPECT_TRUE(from_mgr->addr_.equals(addr_override_)); - EXPECT_EQ(t1_override_, from_mgr->t1_); - EXPECT_EQ(t2_override_, from_mgr->t2_); EXPECT_EQ(pref_override_, from_mgr->preferred_lft_); EXPECT_EQ(valid_override_, from_mgr->valid_lft_); @@ -422,8 +410,6 @@ public: callout_handle.getArgument("lease4", lease); callback_addr_updated_ = addr_override_; lease->addr_ = callback_addr_updated_; - lease->t1_ = t1_override_; - lease->t2_ = t2_override_; lease->valid_lft_ = valid_override_; return (0); @@ -446,8 +432,6 @@ public: // Values to be used in callout to override lease4 content static const IOAddress addr_override_; - static const uint32_t t1_override_; - static const uint32_t t2_override_; static const uint32_t valid_override_; // Callback will store original and overridden values here @@ -471,8 +455,6 @@ public: // linker complains about undefined references if they are defined within // the class declaration. const IOAddress HookAllocEngine4Test::addr_override_("192.0.3.1"); -const uint32_t HookAllocEngine4Test::t1_override_ = 4000; -const uint32_t HookAllocEngine4Test::t2_override_ = 7000; const uint32_t HookAllocEngine4Test::valid_override_ = 9000; IOAddress HookAllocEngine4Test::callback_addr_original_("::"); @@ -572,8 +554,6 @@ TEST_F(HookAllocEngine4Test, change_lease4_select) { // Make sure that the overridden values are different than the ones from // subnet originally used to create the lease - ASSERT_NE(t1_override_, subnet_->getT1()); - ASSERT_NE(t2_override_, subnet_->getT2()); ASSERT_NE(valid_override_, subnet_->getValid()); ASSERT_FALSE(subnet_->inRange(addr_override_)); @@ -609,8 +589,6 @@ TEST_F(HookAllocEngine4Test, change_lease4_select) { // See if the values overridden by callout are there EXPECT_TRUE(lease->addr_.equals(addr_override_)); - EXPECT_EQ(t1_override_, lease->t1_); - EXPECT_EQ(t2_override_, lease->t2_); EXPECT_EQ(valid_override_, lease->valid_lft_); // Now check if the lease is in the database @@ -619,8 +597,6 @@ TEST_F(HookAllocEngine4Test, change_lease4_select) { // Check if values in the database are overridden EXPECT_TRUE(from_mgr->addr_.equals(addr_override_)); - EXPECT_EQ(t1_override_, from_mgr->t1_); - EXPECT_EQ(t2_override_, from_mgr->t2_); EXPECT_EQ(valid_override_, from_mgr->valid_lft_); // Check if the callout handle state was reset after the callout. diff --git a/src/lib/dhcpsrv/tests/alloc_engine_utils.cc b/src/lib/dhcpsrv/tests/alloc_engine_utils.cc index a85b42d76a..2e4960684f 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_utils.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine_utils.cc @@ -119,7 +119,7 @@ AllocEngine4Test::generateDeclinedLease(const std::string& addr, HWAddrPtr hwaddr(new HWAddr()); time_t now = time(NULL); Lease4Ptr declined(new Lease4(addr, hwaddr, ClientIdPtr(), 495, - 100, 200, now, subnet_->getID())); + now, subnet_->getID())); declined->decline(probation_period); declined->cltt_ = now - probation_period + expired; return (declined); @@ -392,7 +392,7 @@ AllocEngine6Test::allocWithUsedHintTest(Lease::Type type, IOAddress used_addr, DuidPtr duid2 = boost::shared_ptr(new DUID(vector(8, 0xff))); time_t now = time(NULL); Lease6Ptr used(new Lease6(type, used_addr, - duid2, 1, 2, 3, 4, now, subnet_->getID())); + duid2, 1, 2, now, subnet_->getID())); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used)); // Another client comes in and request an address that is in pool, but @@ -520,7 +520,7 @@ AllocEngine6Test::generateDeclinedLease(const std::string& addr, time_t probation_period, int32_t expired) { Lease6Ptr declined(new Lease6(Lease::TYPE_NA, IOAddress(addr), - duid_, iaid_, 100, 100, 100, 100, subnet_->getID())); + duid_, iaid_, 100, 100, subnet_->getID())); time_t now = time(NULL); declined->decline(probation_period); diff --git a/src/lib/dhcpsrv/tests/alloc_engine_utils.h b/src/lib/dhcpsrv/tests/alloc_engine_utils.h index cd23b1c06a..80e33cd197 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_utils.h +++ b/src/lib/dhcpsrv/tests/alloc_engine_utils.h @@ -196,8 +196,6 @@ public: EXPECT_EQ(iaid_, lease->iaid_); EXPECT_EQ(subnet_->getValid(), lease->valid_lft_); EXPECT_EQ(subnet_->getPreferred(), lease->preferred_lft_); - EXPECT_EQ(subnet_->getT1(), lease->t1_); - EXPECT_EQ(subnet_->getT2(), lease->t2_); EXPECT_EQ(exp_pd_len, lease->prefixlen_); EXPECT_EQ(fqdn_fwd_, lease->fqdn_fwd_); EXPECT_EQ(fqdn_rev_, lease->fqdn_rev_); @@ -462,8 +460,6 @@ public: // Check that it has proper parameters EXPECT_EQ(subnet_->getValid(), lease->valid_lft_); - EXPECT_EQ(subnet_->getT1(), lease->t1_); - EXPECT_EQ(subnet_->getT2(), lease->t2_); if (lease->client_id_ && !clientid_) { ADD_FAILURE() << "Lease4 has a client-id, while it should have none."; } else diff --git a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc index 0c5e946eac..b3ee6623d4 100644 --- a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc @@ -632,7 +632,7 @@ TEST_F(CqlLeaseMgrTest, deleteExpiredReclaimedLeases4) { // Test checks whether simple add, get and delete operations are possible // on Lease6 TEST_F(CqlLeaseMgrTest, testAddGetDelete6) { - testAddGetDelete6(false); + testAddGetDelete6(); } /// @brief Basic Lease6 Checks diff --git a/src/lib/dhcpsrv/tests/csv_lease_file4_unittest.cc b/src/lib/dhcpsrv/tests/csv_lease_file4_unittest.cc index f46906016c..23bfce4ed4 100644 --- a/src/lib/dhcpsrv/tests/csv_lease_file4_unittest.cc +++ b/src/lib/dhcpsrv/tests/csv_lease_file4_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -212,7 +212,7 @@ TEST_F(CSVLeaseFile4Test, recreate) { Lease4Ptr lease(new Lease4(IOAddress("192.0.3.2"), hwaddr0_, NULL, 0, - 200, 50, 80, 0, 8, true, true, + 200, 0, 8, true, true, "host.example.com")); lease->state_ = Lease::STATE_EXPIRED_RECLAIMED; { @@ -225,7 +225,7 @@ TEST_F(CSVLeaseFile4Test, recreate) { lease.reset(new Lease4(IOAddress("192.0.3.10"), hwaddr1_, CLIENTID, sizeof(CLIENTID), - 100, 60, 90, 0, 7)); + 100, 0, 7)); lease->setContext(Element::fromJSON("{ \"foobar\": true }")); { SCOPED_TRACE("Second write"); @@ -439,7 +439,7 @@ TEST_F(CSVLeaseFile4Test, highLeaseLifetime) { Lease4Ptr lease(new Lease4(IOAddress("192.0.3.2"), hwaddr0_, NULL, 0, - 0xFFFFFFFF, 50, 80, time(0), + 0xFFFFFFFF, time(0), 8, true, true, "host.example.com")); // Write this lease out to the lease file. diff --git a/src/lib/dhcpsrv/tests/csv_lease_file6_unittest.cc b/src/lib/dhcpsrv/tests/csv_lease_file6_unittest.cc index fd9a03491b..49ae14bf9a 100644 --- a/src/lib/dhcpsrv/tests/csv_lease_file6_unittest.cc +++ b/src/lib/dhcpsrv/tests/csv_lease_file6_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -244,7 +244,7 @@ TEST_F(CSVLeaseFile6Test, recreate) { Lease6Ptr lease(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"), makeDUID(DUID0, sizeof(DUID0)), - 7, 100, 200, 50, 80, 8, true, true, + 7, 100, 200, 8, true, true, "host.example.com")); lease->cltt_ = 0; { @@ -255,7 +255,7 @@ TEST_F(CSVLeaseFile6Test, recreate) { lease.reset(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:2::10"), makeDUID(DUID1, sizeof(DUID1)), - 8, 150, 300, 40, 70, 6, false, false, + 8, 150, 300, 6, false, false, "", HWAddrPtr(), 128)); lease->cltt_ = 0; { @@ -266,7 +266,7 @@ TEST_F(CSVLeaseFile6Test, recreate) { lease.reset(new Lease6(Lease::TYPE_PD, IOAddress("3000:1:1::"), makeDUID(DUID0, sizeof(DUID0)), - 7, 150, 300, 40, 70, 10, false, false, + 7, 150, 300, 10, false, false, "", HWAddrPtr(), 64)); lease->cltt_ = 0; lease->setContext(Element::fromJSON("{ \"foobar\": true }")); @@ -551,7 +551,7 @@ TEST_F(CSVLeaseFile6Test, highLeaseLifetime) { // Write lease with very high lease lifetime and current time. Lease6Ptr lease(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"), makeDUID(DUID0, sizeof(DUID0)), - 7, 100, 0xFFFFFFFF, 50, 80, 8, true, true, + 7, 100, 0xFFFFFFFF, 8, true, true, "host.example.com")); // Write this lease out to the lease file. diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc index cb213c2ecb..30c0c6a3dc 100644 --- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -86,10 +86,6 @@ GenericLeaseMgrTest::initializeLease4(std::string address) { // Set the address of the lease lease->addr_ = IOAddress(address); - // Initialize unused fields. - lease->t1_ = 0; // Not saved - lease->t2_ = 0; // Not saved - // Set other parameters. For historical reasons, address 0 is not used. if (address == straddress4_[0]) { lease->hwaddr_.reset(new HWAddr(vector(6, 0x08), HTYPE_ETHER)); @@ -204,10 +200,6 @@ GenericLeaseMgrTest::initializeLease6(std::string address) { // Set the address of the lease lease->addr_ = IOAddress(address); - // Initialize unused fields. - lease->t1_ = 0; // Not saved - lease->t2_ = 0; // Not saved - // Set other parameters. For historical reasons, address 0 is not used. if (address == straddress6_[0]) { lease->type_ = leasetype6_[0]; @@ -619,7 +611,7 @@ GenericLeaseMgrTest::testGetLease4ClientIdHWAddrSubnetId() { } void -GenericLeaseMgrTest::testAddGetDelete6(bool check_t1_t2) { +GenericLeaseMgrTest::testAddGetDelete6() { const std::string addr234("2001:db8:1::234"); const std::string addr456("2001:db8:1::456"); const std::string addr789("2001:db8:1::789"); @@ -632,8 +624,8 @@ GenericLeaseMgrTest::testAddGetDelete6(bool check_t1_t2) { SubnetID subnet_id = 8; // just another number - Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid, iaid, 100, 200, 50, - 80, subnet_id)); + Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid, iaid, 100, 200, + subnet_id)); EXPECT_TRUE(lmptr_->addLease(lease)); @@ -656,15 +648,6 @@ GenericLeaseMgrTest::testAddGetDelete6(bool check_t1_t2) { EXPECT_EQ(Lease::TYPE_NA, x->type_); EXPECT_EQ(100, x->preferred_lft_); EXPECT_EQ(200, x->valid_lft_); - if (check_t1_t2) { - // Backend supports T1,T2 storage: check the values - EXPECT_EQ(50, x->t1_); - EXPECT_EQ(80, x->t2_); - } else { - // Backend does not support storing, check that it returns 0s. - EXPECT_EQ(0, x->t1_); - EXPECT_EQ(0, x->t2_); - } // Test getLease6(duid, iaid, subnet_id) - positive case Lease6Ptr y = lmptr_->getLease6(Lease::TYPE_NA, *duid, iaid, subnet_id); @@ -1421,7 +1404,6 @@ GenericLeaseMgrTest::testGetLeases6Paged() { // Only IPv6 address can be used. EXPECT_THROW(lmptr_->getLeases6(IOAddress("192.0.2.0"), LeasePageSize(3)), InvalidAddressFamily); - } void @@ -1504,9 +1486,6 @@ GenericLeaseMgrTest::testLease6LeaseTypeCheck() { DuidPtr duid(new DUID(vector(8, 0x77))); - // Initialize unused fields. - empty_lease->t1_ = 0; // Not saved - empty_lease->t2_ = 0; // Not saved empty_lease->iaid_ = 142; empty_lease->duid_ = DuidPtr(new DUID(*duid)); empty_lease->subnet_id_ = 23; @@ -1639,40 +1618,40 @@ GenericLeaseMgrTest::testGetLeases6Duid() { SubnetID subnet_id = 8; // radom number - Lease6Ptr lease1(new Lease6(Lease::TYPE_NA, addr1, duid1, iaid, 100, 200, 50, - 80, subnet_id)); - Lease6Ptr lease2(new Lease6(Lease::TYPE_NA, addr2, duid2, iaid, 100, 200, 50, - 80, subnet_id)); - Lease6Ptr lease3(new Lease6(Lease::TYPE_PD, addr3, duid3, iaid, 100, 200, 50, - 80, subnet_id, HWAddrPtr(), 64)); + Lease6Ptr lease1(new Lease6(Lease::TYPE_NA, addr1, duid1, iaid, 100, 200, + subnet_id)); + Lease6Ptr lease2(new Lease6(Lease::TYPE_NA, addr2, duid2, iaid, 100, 200, + subnet_id)); + Lease6Ptr lease3(new Lease6(Lease::TYPE_PD, addr3, duid3, iaid, 100, 200, + subnet_id, HWAddrPtr(), 64)); EXPECT_TRUE(lmptr_->addLease(lease1)); EXPECT_TRUE(lmptr_->addLease(lease2)); EXPECT_TRUE(lmptr_->addLease(lease3)); - + Lease6Collection returned1 = lmptr_->getLeases6(*(lease1->duid_)); Lease6Collection returned2 = lmptr_->getLeases6(*(lease2->duid_)); Lease6Collection returned3 = lmptr_->getLeases6(*(lease3->duid_)); - - //verify if the returned lease mathces + + //verify if the returned lease mathces EXPECT_EQ(returned1.size(), 1); EXPECT_EQ(returned2.size(), 1); EXPECT_EQ(returned3.size(), 1); //verify that the returned lease are same - EXPECT_TRUE(returned1[0]->addr_ == lease1->addr_); + EXPECT_TRUE(returned1[0]->addr_ == lease1->addr_); EXPECT_TRUE(returned2[0]->addr_ == lease2->addr_); EXPECT_TRUE(returned3[0]->addr_ == lease3->addr_); - + //now verify we return empty for a lease that has not been stored returned3 = lmptr_->getLeases6(*duid4); EXPECT_TRUE(returned3.empty()); - + //clean up (void) lmptr_->deleteLease(addr1); (void) lmptr_->deleteLease(addr2); (void) lmptr_->deleteLease(addr3); - + //now verify we return empty for a lease that has not been stored returned3 = lmptr_->getLeases6(*duid4); EXPECT_TRUE(returned3.empty()); @@ -2728,7 +2707,7 @@ GenericLeaseMgrTest::makeLease6(const Lease::Type& type, bytes.push_back(prefix_len); Lease6Ptr lease(new Lease6(type, addr, DuidPtr(new DUID(bytes)), 77, - 16000, 24000, 0, 0, subnet_id, HWAddrPtr(), + 16000, 24000, subnet_id, HWAddrPtr(), prefix_len)); lease->state_ = state; ASSERT_TRUE(lmptr_->addLease(lease)); diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h index b60691fb39..d9228c367b 100644 --- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h +++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h @@ -248,14 +248,7 @@ public: void testLease6HWTypeAndSource(); /// @brief Test that IPv6 lease can be added, retrieved and deleted. - /// - /// This method checks basic IPv6 lease operations. There's check_t1_t2 - /// parameter that controls whether the backend supports storing T1, T2 - /// parameters. memfile supports it, while MySQL doesn't. If T1,T2 - /// storage is not supported, the expected values are 0. - /// - /// @param check_t1_t2 controls whether T1,T2 timers should be checked - void testAddGetDelete6(bool check_t1_t2); + void testAddGetDelete6(); /// @brief Check GetLease6 methods - access by DUID/IAID /// diff --git a/src/lib/dhcpsrv/tests/lease_unittest.cc b/src/lib/dhcpsrv/tests/lease_unittest.cc index 39858e23e2..0763c0ce78 100644 --- a/src/lib/dhcpsrv/tests/lease_unittest.cc +++ b/src/lib/dhcpsrv/tests/lease_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -124,15 +124,13 @@ TEST_F(Lease4Test, constructor) { for (int i = 0; i < sizeof(ADDRESS) / sizeof(ADDRESS[0]); ++i) { // Create the lease - Lease4 lease(ADDRESS[i], hwaddr_, clientid_, VALID_LIFETIME, 0, 0, + Lease4 lease(ADDRESS[i], hwaddr_, clientid_, VALID_LIFETIME, current_time, SUBNET_ID, true, true, "hostname.example.com."); EXPECT_EQ(ADDRESS[i], lease.addr_.toUint32()); EXPECT_TRUE(util::equalValues(hwaddr_, lease.hwaddr_)); EXPECT_TRUE(util::equalValues(clientid_, lease.client_id_)); - EXPECT_EQ(0, lease.t1_); - EXPECT_EQ(0, lease.t2_); EXPECT_EQ(VALID_LIFETIME, lease.valid_lft_); EXPECT_EQ(current_time, lease.cltt_); EXPECT_EQ(SUBNET_ID, lease.subnet_id_); @@ -151,7 +149,7 @@ TEST_F(Lease4Test, copyConstructor) { const time_t current_time = time(NULL); // Create the lease - Lease4 lease(0xffffffff, hwaddr_, clientid_, VALID_LIFETIME, 0, 0, current_time, + Lease4 lease(0xffffffff, hwaddr_, clientid_, VALID_LIFETIME, current_time, SUBNET_ID); // Declined is a non-default state. We'll see if the state will be copied @@ -196,7 +194,7 @@ TEST_F(Lease4Test, operatorAssign) { const time_t current_time = time(NULL); // Create the lease - Lease4 lease(0xffffffff, hwaddr_, clientid_, VALID_LIFETIME, 0, 0, current_time, + Lease4 lease(0xffffffff, hwaddr_, clientid_, VALID_LIFETIME, current_time, SUBNET_ID); // Declined is a non-default state. We'll see if the state will be copied @@ -309,8 +307,8 @@ TEST_F(Lease4Test, operatorEquals) { const time_t current_time = time(NULL); // Check when the leases are equal. - Lease4 lease1(ADDRESS, hwaddr_, clientid_, VALID_LIFETIME, current_time, 0, - 0, SUBNET_ID); + Lease4 lease1(ADDRESS, hwaddr_, clientid_, VALID_LIFETIME, current_time, + SUBNET_ID); lease1.setContext(Element::fromJSON("{ \"foobar\": 1234 }")); // We need to make an explicit copy. Otherwise the second lease will just @@ -320,7 +318,7 @@ TEST_F(Lease4Test, operatorEquals) { ClientIdPtr clientid_copy(new ClientId(*clientid_)); Lease4 lease2(ADDRESS, hwcopy, clientid_copy, VALID_LIFETIME, current_time, - 0, 0, SUBNET_ID); + SUBNET_ID); lease2.setContext(Element::fromJSON("{ \"foobar\": 1234 }")); EXPECT_TRUE(lease1 == lease2); EXPECT_FALSE(lease1 != lease2); @@ -351,20 +349,6 @@ TEST_F(Lease4Test, operatorEquals) { EXPECT_TRUE(lease1 == lease2); // Check that the reversion has made the EXPECT_FALSE(lease1 != lease2); // ... leases equal - ++lease1.t1_; - EXPECT_FALSE(lease1 == lease2); - EXPECT_TRUE(lease1 != lease2); - lease1.t1_ = lease2.t1_; - EXPECT_TRUE(lease1 == lease2); // Check that the reversion has made the - EXPECT_FALSE(lease1 != lease2); // ... leases equal - - ++lease1.t2_; - EXPECT_FALSE(lease1 == lease2); - EXPECT_TRUE(lease1 != lease2); - lease1.t2_ = lease2.t2_; - EXPECT_TRUE(lease1 == lease2); // Check that the reversion has made the - EXPECT_FALSE(lease1 != lease2); // ... leases equal - ++lease1.valid_lft_; EXPECT_FALSE(lease1 == lease2); EXPECT_TRUE(lease1 != lease2); @@ -472,15 +456,13 @@ TEST_F(Lease4Test, hasIdenticalFqdn) { TEST_F(Lease4Test, toText) { const time_t current_time = 12345678; - Lease4 lease(IOAddress("192.0.2.3"), hwaddr_, clientid_, 3600, 123, - 456, current_time, 789); + Lease4 lease(IOAddress("192.0.2.3"), hwaddr_, clientid_, 3600, + current_time, 789); lease.setContext(Element::fromJSON("{ \"foobar\": 1234 }")); std::stringstream expected; expected << "Address: 192.0.2.3\n" << "Valid life: 3600\n" - << "T1: 123\n" - << "T2: 456\n" << "Cltt: 12345678\n" << "Hardware addr: " << hwaddr_->toText(false) << "\n" << "Client id: " << clientid_->toText() << "\n" @@ -498,8 +480,6 @@ TEST_F(Lease4Test, toText) { expected.str(""); expected << "Address: 192.0.2.3\n" << "Valid life: 3600\n" - << "T1: 123\n" - << "T2: 456\n" << "Cltt: 12345678\n" << "Hardware addr: (none)\n" << "Client id: (none)\n" @@ -512,8 +492,8 @@ TEST_F(Lease4Test, toText) { TEST_F(Lease4Test, toElement) { const time_t current_time = 12345678; - Lease4 lease(IOAddress("192.0.2.3"), hwaddr_, clientid_, 3600, 123, - 456, current_time, 789, true, true, "urania.example.org"); + Lease4 lease(IOAddress("192.0.2.3"), hwaddr_, clientid_, 3600, + current_time, 789, true, true, "urania.example.org"); lease.setContext(Element::fromJSON("{ \"foobar\": 1234 }")); std::string expected = "{" @@ -652,8 +632,8 @@ TEST_F(Lease4Test, fromElementInvalidValues) { TEST_F(Lease4Test, decline) { const time_t current_time = 12345678; - Lease4 lease(IOAddress("192.0.2.3"), hwaddr_, clientid_, 3600, 123, - 456, current_time, 789); + Lease4 lease(IOAddress("192.0.2.3"), hwaddr_, clientid_, 3600, + current_time, 789); lease.hostname_="foo.example.org"; lease.fqdn_fwd_ = true; lease.fqdn_rev_ = true; @@ -665,8 +645,6 @@ TEST_F(Lease4Test, decline) { ASSERT_TRUE(lease.hwaddr_); EXPECT_EQ("", lease.hwaddr_->toText(false)); EXPECT_FALSE(lease.client_id_); - EXPECT_EQ(0, lease.t1_); - EXPECT_EQ(0, lease.t2_); EXPECT_TRUE(now <= lease.cltt_); EXPECT_TRUE(lease.cltt_ <= now + 1); @@ -722,7 +700,7 @@ TEST(Lease6Test, Lease6ConstructorDefault) { for (int i = 0; i < sizeof(ADDRESS) / sizeof(ADDRESS[0]); ++i) { IOAddress addr(ADDRESS[i]); Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, - duid, iaid, 100, 200, 50, 80, + duid, iaid, 100, 200, subnet_id)); EXPECT_TRUE(lease->addr_ == addr); @@ -732,8 +710,6 @@ TEST(Lease6Test, Lease6ConstructorDefault) { EXPECT_TRUE(lease->type_ == Lease::TYPE_NA); EXPECT_TRUE(lease->preferred_lft_ == 100); EXPECT_TRUE(lease->valid_lft_ == 200); - EXPECT_TRUE(lease->t1_ == 50); - EXPECT_TRUE(lease->t2_ == 80); EXPECT_FALSE(lease->fqdn_fwd_); EXPECT_FALSE(lease->fqdn_rev_); EXPECT_TRUE(lease->hostname_.empty()); @@ -744,7 +720,7 @@ TEST(Lease6Test, Lease6ConstructorDefault) { IOAddress addr(ADDRESS[0]); Lease6Ptr lease2; EXPECT_THROW(lease2.reset(new Lease6(Lease::TYPE_NA, addr, - DuidPtr(), iaid, 100, 200, 50, 80, + DuidPtr(), iaid, 100, 200, subnet_id)), InvalidOperation); } @@ -769,7 +745,7 @@ TEST(Lease6Test, Lease6ConstructorWithFQDN) { for (int i = 0; i < sizeof(ADDRESS) / sizeof(ADDRESS[0]); ++i) { IOAddress addr(ADDRESS[i]); Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, - duid, iaid, 100, 200, 50, 80, subnet_id, + duid, iaid, 100, 200, subnet_id, true, true, "host.example.com.")); EXPECT_TRUE(lease->addr_ == addr); @@ -779,8 +755,6 @@ TEST(Lease6Test, Lease6ConstructorWithFQDN) { EXPECT_TRUE(lease->type_ == Lease::TYPE_NA); EXPECT_TRUE(lease->preferred_lft_ == 100); EXPECT_TRUE(lease->valid_lft_ == 200); - EXPECT_TRUE(lease->t1_ == 50); - EXPECT_TRUE(lease->t2_ == 80); EXPECT_TRUE(lease->fqdn_fwd_); EXPECT_TRUE(lease->fqdn_rev_); EXPECT_EQ("host.example.com.", lease->hostname_); @@ -790,7 +764,7 @@ TEST(Lease6Test, Lease6ConstructorWithFQDN) { IOAddress addr(ADDRESS[0]); Lease6Ptr lease2; EXPECT_THROW(lease2.reset(new Lease6(Lease::TYPE_NA, addr, - DuidPtr(), iaid, 100, 200, 50, 80, + DuidPtr(), iaid, 100, 200, subnet_id)), InvalidOperation); } @@ -809,10 +783,8 @@ TEST(Lease6Test, operatorEquals) { SubnetID subnet_id = 8; // just another number // Check for equality. - Lease6 lease1(Lease::TYPE_NA, addr, duid, iaid, 100, 200, 50, 80, - subnet_id); - Lease6 lease2(Lease::TYPE_NA, addr, duid, iaid, 100, 200, 50, 80, - subnet_id); + Lease6 lease1(Lease::TYPE_NA, addr, duid, iaid, 100, 200, subnet_id); + Lease6 lease2(Lease::TYPE_NA, addr, duid, iaid, 100, 200, subnet_id); lease1.setContext(Element::fromJSON("{ \"foobar\": 1234 }")); lease2.setContext(Element::fromJSON("{ \"foobar\": 1234 }")); @@ -876,20 +848,6 @@ TEST(Lease6Test, operatorEquals) { EXPECT_TRUE(lease1 == lease2); // Check that the reversion has made the EXPECT_FALSE(lease1 != lease2); // ... leases equal - ++lease1.t1_; - EXPECT_FALSE(lease1 == lease2); - EXPECT_TRUE(lease1 != lease2); - lease1.t1_ = lease2.t1_; - EXPECT_TRUE(lease1 == lease2); // Check that the reversion has made the - EXPECT_FALSE(lease1 != lease2); // ... leases equal - - ++lease1.t2_; - EXPECT_FALSE(lease1 == lease2); - EXPECT_TRUE(lease1 != lease2); - lease1.t2_ = lease2.t2_; - EXPECT_TRUE(lease1 == lease2); // Check that the reversion has made the - EXPECT_FALSE(lease1 != lease2); // ... leases equal - ++lease1.cltt_; EXPECT_FALSE(lease1 == lease2); EXPECT_TRUE(lease1 != lease2); @@ -954,8 +912,7 @@ TEST(Lease6Test, Lease6Expired) { const DuidPtr duid(new DUID(duid_array, sizeof(duid_array))); const uint32_t iaid = IAID; // Just a number const SubnetID subnet_id = 8; // Just another number - Lease6 lease(Lease::TYPE_NA, addr, duid, iaid, 100, 200, 50, 80, - subnet_id); + Lease6 lease(Lease::TYPE_NA, addr, duid, iaid, 100, 200, subnet_id); // Case 1: a second before expiration lease.cltt_ = time(NULL) - 100; @@ -1000,9 +957,9 @@ TEST(Lease6Test, decline) { HWAddrPtr hwaddr(new HWAddr(HWADDR, sizeof(HWADDR), HTYPE_ETHER)); // Let's create a lease for 2001:db8::1, DUID, iaid=1234, - // t1=1000, t2=2000, pref=3000, valid=4000, subnet-id = 1 + // pref=3000, valid=4000, subnet-id = 1 Lease6 lease(Lease::TYPE_NA, IOAddress("2001:db8::1"), duid, - 1234, 3000, 4000, 1000, 2000, 1, hwaddr); + 1234, 3000, 4000, 1, hwaddr); lease.cltt_ = 12345678; lease.hostname_ = "foo.example.org"; lease.fqdn_fwd_ = true; @@ -1016,8 +973,6 @@ TEST(Lease6Test, decline) { ASSERT_TRUE(lease.duid_); ASSERT_EQ("00", lease.duid_->toText()); ASSERT_FALSE(lease.hwaddr_); - EXPECT_EQ(0, lease.t1_); - EXPECT_EQ(0, lease.t2_); EXPECT_EQ(0, lease.preferred_lft_); EXPECT_TRUE(now <= lease.cltt_); @@ -1059,7 +1014,7 @@ TEST(Lease6Test, toText) { DuidPtr duid(new DUID(llt, sizeof(llt))); Lease6 lease(Lease::TYPE_NA, IOAddress("2001:db8::1"), duid, 123456, - 400, 800, 100, 200, 5678, hwaddr, 128); + 400, 800, 5678, hwaddr, 128); lease.cltt_ = 12345678; lease.state_ = Lease::STATE_DECLINED; lease.setContext(Element::fromJSON("{ \"foobar\": 1234 }")); @@ -1108,7 +1063,7 @@ TEST(Lease6Test, toElementAddress) { DuidPtr duid(new DUID(llt, sizeof(llt))); Lease6 lease(Lease::TYPE_NA, IOAddress("2001:db8::1"), duid, 123456, - 400, 800, 100, 200, 5678, hwaddr, 128); + 400, 800, 5678, hwaddr, 128); lease.cltt_ = 12345678; lease.state_ = Lease::STATE_DECLINED; lease.hostname_ = "urania.example.org"; @@ -1130,7 +1085,7 @@ TEST(Lease6Test, toElementAddress) { "\"user-context\": { \"foobar\": 1234 }," "\"valid-lft\": 800" "}"; - + runToElementTest(expected, lease); // Now let's try with a lease without hardware address and user context. @@ -1151,7 +1106,7 @@ TEST(Lease6Test, toElementAddress) { "\"type\": \"IA_NA\"," "\"valid-lft\": 800" "}"; - + runToElementTest(expected, lease); // And to finish try with a comment. @@ -1172,7 +1127,7 @@ TEST(Lease6Test, toElementAddress) { "\"type\": \"IA_NA\"," "\"valid-lft\": 800" "}"; - + runToElementTest(expected, lease); } @@ -1186,7 +1141,7 @@ TEST(Lease6Test, toElementPrefix) { DuidPtr duid(new DUID(llt, sizeof(llt))); Lease6 lease(Lease::TYPE_PD, IOAddress("2001:db8::"), duid, 123456, - 400, 800, 100, 200, 5678, hwaddr, 56); + 400, 800, 5678, hwaddr, 56); lease.cltt_ = 12345678; lease.state_ = Lease::STATE_DEFAULT; lease.hostname_ = "urania.example.org"; diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc index 263d24a4d1..e7ef6c2ac6 100644 --- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -249,8 +249,6 @@ public: /// /// The following lease parameters are set to constant values: /// - valid lifetime = 1200, - /// - T1 = 600, - /// - T2 = 900, /// - DNS update forward flag = false, /// - DNS update reverse flag = false, /// @@ -273,8 +271,6 @@ public: fillRandom(clientid.begin(), clientid.end()); uint32_t valid_lft = 1200; - uint32_t t1 = 600; - uint32_t t2 = 900; time_t timestamp = time(NULL) - 86400 + random()%86400; bool fqdn_fwd = false; bool fqdn_rev = false; @@ -285,7 +281,7 @@ public: // Return created lease. return (Lease4Ptr(new Lease4(address, hwaddr, &clientid[0], - clientid.size(), valid_lft, t1, t2, + clientid.size(), valid_lft, timestamp, subnet_id, fqdn_fwd, fqdn_rev, hostname.str()))); } @@ -303,8 +299,6 @@ public: /// - lease type = IA_NA /// - valid lifetime = 1200, /// - preferred lifetime = 1000 - /// - T1 = 600, - /// - T2 = 900, /// - DNS update forward flag = false, /// - DNS update reverse flag = false, /// @@ -325,8 +319,6 @@ public: uint32_t iaid = 1 + random()%100; uint32_t valid_lft = 1200; uint32_t preferred_lft = 1000; - uint32_t t1 = 600; - uint32_t t2 = 900; time_t timestamp = time(NULL) - 86400 + random()%86400; bool fqdn_fwd = false; bool fqdn_rev = false; @@ -337,7 +329,7 @@ public: // Return created lease. Lease6Ptr lease(new Lease6(lease_type, address, duid, iaid, - preferred_lft, valid_lft, t1, t2, + preferred_lft, valid_lft, subnet_id, fqdn_fwd, fqdn_rev, hostname.str())); lease->cltt_ = timestamp; @@ -545,7 +537,7 @@ TEST_F(MemfileLeaseMgrTest, leaseFileCleanup4) { HWAddrPtr hwaddr(new HWAddr(hwaddr_vec, HTYPE_ETHER)); Lease4Ptr new_lease(new Lease4(IOAddress("192.0.2.45"), hwaddr, static_cast(0), 0, - 100, 50, 60, 0, 1)); + 100, 0, 1)); ASSERT_NO_THROW(lease_mgr->addLease(new_lease)); std::string updated_file_contents = new_file_contents + @@ -625,8 +617,8 @@ TEST_F(MemfileLeaseMgrTest, leaseFileCleanup6) { // Check if we can still write to the lease file. std::vector duid_vec(13); DuidPtr duid(new DUID(duid_vec)); - Lease6Ptr new_lease(new Lease6(Lease::TYPE_NA, IOAddress("3000::1"),duid, - 123, 300, 400, 100, 300, 2)); + Lease6Ptr new_lease(new Lease6(Lease::TYPE_NA, IOAddress("3000::1"), duid, + 123, 300, 400, 2)); new_lease->cltt_ = 0; ASSERT_NO_THROW(lease_mgr->addLease(new_lease)); @@ -823,9 +815,7 @@ TEST_F(MemfileLeaseMgrTest, leaseFileCopy) { // Checks that adding/getting/deleting a Lease6 object works. TEST_F(MemfileLeaseMgrTest, addGetDelete6) { startBackend(V6); - testAddGetDelete6(true); // true - check T1,T2 values - // memfile is able to preserve those values, but some other - // backends can't do that. + testAddGetDelete6(); } /// @brief Basic Lease4 Checks diff --git a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc index a9b5e45262..e0b2125b0d 100644 --- a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc @@ -416,7 +416,7 @@ TEST_F(MySqlLeaseMgrTest, deleteExpiredReclaimedLeases4) { // Test checks whether simple add, get and delete operations are possible // on Lease6 TEST_F(MySqlLeaseMgrTest, testAddGetDelete6) { - testAddGetDelete6(false); + testAddGetDelete6(); } /// @brief Basic Lease6 Checks diff --git a/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc b/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc index e7a9d32d9a..b44aba1a30 100644 --- a/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc +++ b/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -254,8 +254,7 @@ public: /// @brief Implementation of the method creating DHCPv6 lease instance. virtual void initLease() { lease_.reset(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"), - duid_, 1234, 501, 502, 503, - 504, 1, HWAddrPtr(), 0)); + duid_, 1234, 501, 502, 1, HWAddrPtr(), 0)); } }; @@ -433,7 +432,7 @@ public: /// @brief Implementation of the method creating DHCPv4 lease instance. virtual void initLease() { lease_.reset(new Lease4(IOAddress("192.0.2.1"), hwaddr_, ClientIdPtr(), - 100, 30, 60, time(NULL), 1)); + 100, time(NULL), 1)); } }; diff --git a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc index 0fc23ee9e7..6298e9dbd2 100644 --- a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc @@ -406,7 +406,7 @@ TEST_F(PgSqlLeaseMgrTest, deleteExpiredReclaimedLeases4) { // Test checks whether simple add, get and delete operations are possible // on Lease6 TEST_F(PgSqlLeaseMgrTest, testAddGetDelete6) { - testAddGetDelete6(false); + testAddGetDelete6(); } /// @brief Basic Lease6 Checks diff --git a/src/lib/dhcpsrv/tests/sanity_checks_unittest.cc b/src/lib/dhcpsrv/tests/sanity_checks_unittest.cc index 91bfa86739..2f4be690e0 100644 --- a/src/lib/dhcpsrv/tests/sanity_checks_unittest.cc +++ b/src/lib/dhcpsrv/tests/sanity_checks_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -68,7 +68,7 @@ public: // Return created lease. return (Lease4Ptr(new Lease4(address, hwaddr, &clientid[0], 0, // no client-id - 1200, 600, 900, // valid, t1, t2 + 1200, // valid timestamp, subnet_id, false, false, ""))); } @@ -95,7 +95,7 @@ public: // Return created lease. Lease6Ptr lease(new Lease6(lease_type, address, duid, iaid, - 1000, 1200, 600, 900, // pref, valid, t1, t2 + 1000, 1200, // pref, valid subnet_id, false, false, "")); // fqdn fwd, rev, hostname return (lease);