From: mayya Date: Mon, 16 Jul 2018 21:53:29 +0000 (+0200) Subject: fixed minor issues X-Git-Tag: ha_phase2~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3606c3ba9ccaa0ab60f842cf89a9f0f9bb5b6be6;p=thirdparty%2Fkea.git fixed minor issues --- diff --git a/src/lib/dhcpsrv/host.cc b/src/lib/dhcpsrv/host.cc index f7d2664dfa..4ec23c0d81 100644 --- a/src/lib/dhcpsrv/host.cc +++ b/src/lib/dhcpsrv/host.cc @@ -73,8 +73,7 @@ AuthKey::operator!=(const AuthKey& other) const { IPv6Resrv::IPv6Resrv(const Type& type, const asiolink::IOAddress& prefix, const uint8_t prefix_len) - : type_(type), prefix_(asiolink::IOAddress("::")), - prefix_len_(128){ + : type_(type), prefix_(asiolink::IOAddress("::")), prefix_len_(128) { // Validate and set the actual values. set(type, prefix, prefix_len); } diff --git a/src/lib/dhcpsrv/host.h b/src/lib/dhcpsrv/host.h index 42bc096540..065df92400 100644 --- a/src/lib/dhcpsrv/host.h +++ b/src/lib/dhcpsrv/host.h @@ -696,6 +696,8 @@ private: std::string server_host_name_; /// @brief Boot file name (a.k.a. file, carried in DHCPv4 message) std::string boot_file_name_; + + /// @brief HostID (a unique identifier assigned when the host is stored in /// MySQL, PostgreSQL or Cassandra) uint64_t host_id_; @@ -710,15 +712,14 @@ private: /// we queried other backends for specific host and there was no /// entry for it. bool negative_; - /// @brief keys for authentication . + /// @brief key for authentication . /// - /// This key is a 16 byte value to be used in the authentication field - /// During server replies specified in the RFC 3315bis authentication field will - /// contain the below key. While sending reconfigure message authentication field + /// key is a 16 byte value to be used in the authentication field. + /// Server replies will contain the below key in authentication field as specified in the RFC 3315bis. + // While sending reconfigure message authentication field /// shall contain MD5 hash computed using this key. AuthKey key_; - /// @brief HostID (a unique identifier assigned when the host is stored in }; /// @brief Pointer to the @c Host object. diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.h b/src/lib/dhcpsrv/memfile_lease_mgr.h index 6a1008b4e8..23a12d299f 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.h +++ b/src/lib/dhcpsrv/memfile_lease_mgr.h @@ -312,6 +312,12 @@ public: /// @return Lease collection (may be empty if no IPv6 lease found). virtual Lease6Collection getLeases6() const; + /// @brief Returns IPv6 leases for the DUID. + /// + /// @todo: implement an optimised of the query using index. + /// @return Lease collection (may be empty if no IPv6 lease found) for the DUID. + virtual Lease6Collection getLeases6(const DUID& duid) const; + /// @brief Returns range of IPv6 leases using paging. /// /// This method implements paged browsing of the lease database. The first diff --git a/src/lib/dhcpsrv/mysql_host_data_source.cc b/src/lib/dhcpsrv/mysql_host_data_source.cc index 372c93ea80..e4bc90aaf8 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.cc +++ b/src/lib/dhcpsrv/mysql_host_data_source.cc @@ -76,7 +76,6 @@ const size_t BOOT_FILE_NAME_MAX_LEN = 128; /// @brief Maximum length of keys. const size_t KEY_LEN = 16; -/// @brief Numeric value representing last supported identifier. /// @brief Numeric value representing last supported identifier. /// /// This value is used to validate whether the identifier type stored in diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.h b/src/lib/dhcpsrv/mysql_lease_mgr.h index f9d9286c05..2a0b71f7e7 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.h +++ b/src/lib/dhcpsrv/mysql_lease_mgr.h @@ -309,6 +309,12 @@ public: /// @return Lease collection (may be empty if no IPv6 lease found). virtual Lease6Collection getLeases6() const; + /// @brief Returns all IPv6 leases for the DUID. + /// + /// @todo: implement an optimised of the query using index. + /// @return Lease collection (may be empty if no IPv6 lease found) for the DUID. + virtual Lease6Collection getLeases6(const DUID& duid) const; + /// @brief Returns range of IPv6 leases using paging. /// /// This method implements paged browsing of the lease database. The first diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.h b/src/lib/dhcpsrv/pgsql_lease_mgr.h index 423f820bcf..d67cac1b7b 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.h +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.h @@ -281,6 +281,12 @@ public: /// @return Lease collection (may be empty if no IPv6 lease found). virtual Lease6Collection getLeases6() const; + /// @brief Returns IPv6 leases for the DUID. + /// + /// @todo: implement an optimised of the query using index. + /// @return Lease collection (may be empty if no IPv6 lease found) for the DUID + virtual Lease6Collection getLeases6(const DUID& duid) const; + /// @brief Returns range of IPv6 leases using paging. /// /// This method implements paged browsing of the lease database. The first diff --git a/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc index 81dc571dac..49d471b527 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc @@ -1590,9 +1590,9 @@ TEST_F(ExpirationAllocEngine6Test, reclaimDeclinedStats) { // This test verifies that expired leases are reclaimed before they are // allocated to another client sending a Request message. -//TEST_F(ExpirationAllocEngine6Test, reclaimReusedLeases) { - // testReclaimReusedLeases(DHCPV6_REQUEST, false); -//} +/TEST_F(ExpirationAllocEngine6Test, reclaimReusedLeases) { + testReclaimReusedLeases(DHCPV6_REQUEST, false); +} // This test verifies that allocation engine detects that the expired // lease has been reclaimed already when it reuses this lease. diff --git a/src/lib/dhcpsrv/tests/host_unittest.cc b/src/lib/dhcpsrv/tests/host_unittest.cc index d957afbaa4..be5af1bc58 100644 --- a/src/lib/dhcpsrv/tests/host_unittest.cc +++ b/src/lib/dhcpsrv/tests/host_unittest.cc @@ -1285,5 +1285,3 @@ TEST(AuthKeyTest, basicTest) { } } // end of anonymous namespace - -// Test verifies if diff --git a/src/share/database/scripts/cql/dhcpdb_create.cql b/src/share/database/scripts/cql/dhcpdb_create.cql index bdb74b2d7c..56c1ce8c9c 100644 --- a/src/share/database/scripts/cql/dhcpdb_create.cql +++ b/src/share/database/scripts/cql/dhcpdb_create.cql @@ -276,6 +276,9 @@ INSERT INTO schema_version (version, minor) VALUES(2, 0); -- This line starts database upgrade to version 3.0 +-- This line adds auth_key column into host reservation table +ALTER TABLE host_reservations ADD auth_key text; + -- Add a column holding leases for user context. ALTER TABLE lease4 ADD user_context text; ALTER TABLE lease6 ADD user_context text; diff --git a/src/share/database/scripts/mysql/dhcpdb_create.mysql b/src/share/database/scripts/mysql/dhcpdb_create.mysql index ab9153705b..a6d50a3a42 100644 --- a/src/share/database/scripts/mysql/dhcpdb_create.mysql +++ b/src/share/database/scripts/mysql/dhcpdb_create.mysql @@ -679,6 +679,10 @@ SET version = '6', minor = '0'; # This line concludes database upgrade to version 6.0. +#add auth key in host tables +ALTER TABLE hosts + ADD COLUMN auth_key VARCHAR(16) NULL; + # Add user context into tables holding leases ALTER TABLE lease4 ADD COLUMN user_context TEXT NULL; ALTER TABLE lease6 ADD COLUMN user_context TEXT NULL; diff --git a/src/share/database/scripts/mysql/upgrade_5.2_to_6.0.sh.in b/src/share/database/scripts/mysql/upgrade_5.2_to_6.0.sh.in index 41736c9b6e..3bf129cce4 100644 --- a/src/share/database/scripts/mysql/upgrade_5.2_to_6.0.sh.in +++ b/src/share/database/scripts/mysql/upgrade_5.2_to_6.0.sh.in @@ -23,7 +23,6 @@ ALTER TABLE hosts ADD COLUMN user_context TEXT NULL; # Add user contexts into tables holding DHCP options ALTER TABLE dhcp4_options ADD COLUMN user_context TEXT NULL; ALTER TABLE dhcp6_options ADD COLUMN user_context TEXT NULL; -ALTER TABLE ipv6_reservations ADD COLUMN auth_key VARCHAR(128) NOT NULL; # Create index for searching leases by subnet identifier. CREATE INDEX lease4_by_subnet_id ON lease4 (subnet_id); diff --git a/src/share/database/scripts/pgsql/upgrade_4.0_to_5.0.sh.in b/src/share/database/scripts/pgsql/upgrade_4.0_to_5.0.sh.in index 88a7b7d65b..326522df8d 100644 --- a/src/share/database/scripts/pgsql/upgrade_4.0_to_5.0.sh.in +++ b/src/share/database/scripts/pgsql/upgrade_4.0_to_5.0.sh.in @@ -19,6 +19,9 @@ psql "$@" >/dev/null <