From: Tomek Mrugalski Date: Tue, 9 Jun 2015 16:39:31 +0000 (+0200) Subject: [master] Merge branch 'trac3794' (packet statistics in DHCPv4) X-Git-Tag: throw_with_base~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a61f40c44910a09699a9a566a5ec35ab758564ba;p=thirdparty%2Fkea.git [master] Merge branch 'trac3794' (packet statistics in DHCPv4) --- a61f40c44910a09699a9a566a5ec35ab758564ba diff --cc src/bin/dhcp4/tests/dora_unittest.cc index ca7c2f7d2a,b92a36ab06..36f3090fc3 --- a/src/bin/dhcp4/tests/dora_unittest.cc +++ b/src/bin/dhcp4/tests/dora_unittest.cc @@@ -198,32 -172,84 +199,43 @@@ public : Dhcpv4SrvTest(), iface_mgr_test_config_(true) { IfaceMgr::instance().openSockets4(); + + // Let's wipe all existing statistics. + isc::stats::StatsMgr::instance().removeAll(); + } + + /// @brief Desctructor. + /// + /// Cleans up statistics after the test. + ~DORATest() { + // Let's wipe all existing statistics. + isc::stats::StatsMgr::instance().removeAll(); } - /// @brief Test that server doesn't allocate the lease for a client - /// which has the same address or client identifier as another client. + /// @brief Test that server returns the same lease for the client which is + /// sometimes using client identifier, sometimes not. /// /// This test checks the server's behavior in the following scenario: - /// - Client A identifies itself to the server using the hardware address - /// and client identifier or only one of those. - /// - Client A performs the 4-way exchange and obtains a lease from the server. - /// - Client B uses the same HW address or client identifier as the client A. - /// - Client B uses both HW address and client identifier if the client A is using - /// only one of them. Client B uses one of the HW address or client - /// identifier if the client A is using both. - /// - Client B sends the DHCPDISCOVER to the server. - /// The server determines that there is a lease for the client A using the - /// same HW address as the client B. Server discards the client's message and - /// doesn't offer the lease for the client B to prevent allocation of the - /// lease without a unique identifier. - /// - The client sends the DHCPREQUEST and the server sends the DHCPNAK for the - /// same reason. - /// - The client A renews its address successfully. + /// - Client identifies itself to the server using HW address, and may use + /// client identifier. + /// - Client performs the 4-way exchange and obtains a lease from the server. + /// - If the client identifier was in use when the client has acquired the lease, + /// the client uses null client identifier in the next exchange with the server. + /// - If the client identifier was not in use when the client has acquired the + /// lease, the client uses client identifier in the next exchange with the + /// server. + /// - When the client contacts the server for the second time using the + /// DHCPDISCOVER the server determines (using HW address) that the client + /// already has a lease and returns this lease to the client. + /// - The client renews the existing lease. /// - /// The specific test cases using this test must make sure that one of the - /// provided parameters is an empty string. This simulates the situation where - /// one of the clients has only one of the identifiers and the other one has - /// two. - /// - /// @param hwaddr_a HW address of client A. - /// @param clientid_a Client id of client A. - /// @param hwaddr_b HW address of client B. - /// @param clientid_b Client id of client B. - void oneAllocationOverlapTest(const std::string& hwaddr_a, - const std::string& clientid_a, - const std::string& hwaddr_b, + /// @param clientid_a Client identifier when the client initially allocates + /// the lease. An empty value means "no client identifier". + /// @param clientid_b Client identifier when the client sends the DHCPDISCOVER + /// and then DHCPREQUEST to renew lease. + void oneAllocationOverlapTest(const std::string& clientid_a, const std::string& clientid_b); - /// @brief Test that server can allocate the lease for a client having - /// the same HW Address or client id as another client. - /// - /// This test checks the server behavior in the following situation: - /// - Client A identifies itself to the server using client identifier - /// and the hardware address and requests allocation of the new lease. - /// - Server allocates the lease to the client. - /// - Client B has a different hardware address or client identifier than - /// the client A, but the other identifier is equal to the corresponding - /// identifier of the client A. - /// - Client B sends DHCPDISCOVER. - /// - Server should determine that the client B is not client A, because - /// it is using a different hadrware address or client identifier. - /// As a consequence, the server should offer a different address to the - /// client B. - /// - The client B performs the 4-way exchange again, and the server - /// allocates a new address to the client, which should be different - /// than the address used by the client A. - /// - Client B is in the renewing state and it successfully renews its - /// address. - /// - The client A also renews its address successfully. - /// - /// @param hwaddr_a HW address of client A. - /// @param clientid_a Client id of client A. - /// @param hwaddr_b HW address of client B. - /// @param clientid_b Client id of client B. - void twoAllocationsOverlapTest(const std::string& hwaddr_a, - const std::string& clientid_a, - const std::string& hwaddr_b, - const std::string& clientid_b); - /// @brief Interface Manager's fake configuration control. IfaceMgrTestConfig iface_mgr_test_config_;