BIND 10 trac2892, updated. dbf249256db006eef0111cff5dec4e644706ce54 [2892] removed exception, copyright date changed

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Jan 14 18:22:57 UTC 2014


The branch, trac2892 has been updated
       via  dbf249256db006eef0111cff5dec4e644706ce54 (commit)
       via  c1b0ce8c0ac8b79a8d7663d52b5fd553ed828dce (commit)
       via  caf297138dfa09a73d9311d77ec6298a64152fdc (commit)
       via  05265d4e8d24f358f7f55d62430f3592c3573b93 (commit)
       via  a5664487fa055249bf7afbe413be6a330e6e6b1c (commit)
       via  3a932918fc3013f92db4b41fab03b359c20c8611 (commit)
      from  ec47fdb14d1fd03d386147c1c6cf4afdd118c75f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dbf249256db006eef0111cff5dec4e644706ce54
Author: WlodekWencel <wlodek at isc.org>
Date:   Tue Jan 14 19:22:48 2014 +0100

    [2892] removed exception, copyright date changed

commit c1b0ce8c0ac8b79a8d7663d52b5fd553ed828dce
Author: WlodekWencel <wlodek at isc.org>
Date:   Tue Jan 14 19:21:57 2014 +0100

    [2892] added testServerID function, and copyright date

commit caf297138dfa09a73d9311d77ec6298a64152fdc
Author: WlodekWencel <wlodek at isc.org>
Date:   Tue Jan 14 19:20:59 2014 +0100

    [2892] Test for testServerID function for couple cases

commit 05265d4e8d24f358f7f55d62430f3592c3573b93
Author: WlodekWencel <wlodek at isc.org>
Date:   Tue Jan 14 19:19:41 2014 +0100

    [2892] testServerID founction added, Copyright date changed

commit a5664487fa055249bf7afbe413be6a330e6e6b1c
Author: WlodekWencel <wlodek at isc.org>
Date:   Tue Jan 14 19:19:00 2014 +0100

    [2892] testServerID founction added, Copyright date changed

commit 3a932918fc3013f92db4b41fab03b359c20c8611
Author: WlodekWencel <wlodek at isc.org>
Date:   Tue Jan 14 19:17:44 2014 +0100

    [2892] added DHCP6_PACKET_RECEIVED_MISMATCH_SERVERID message and Copyright date changed

-----------------------------------------------------------------------

Summary of changes:
 src/bin/dhcp6/dhcp6_messages.mes          |    6 +++-
 src/bin/dhcp6/dhcp6_srv.cc                |   51 ++++++++++++++++++-----------
 src/bin/dhcp6/dhcp6_srv.h                 |   19 ++++++-----
 src/bin/dhcp6/tests/dhcp6_srv_unittest.cc |   42 ++++++++++--------------
 src/bin/dhcp6/tests/dhcp6_test_utils.h    |    3 +-
 src/lib/dhcpsrv/utils.h                   |   17 +---------
 6 files changed, 67 insertions(+), 71 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes
index 9678b4f..ca50210 100644
--- a/src/bin/dhcp6/dhcp6_messages.mes
+++ b/src/bin/dhcp6/dhcp6_messages.mes
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013  Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2012-2014  Internet Systems Consortium, Inc. ("ISC")
 #
 # Permission to use, copy, modify, and/or distribute this software for any
 # purpose with or without fee is hereby granted, provided that the above
@@ -264,6 +264,10 @@ of packet.  Note that a packet marked as UNKNOWN may well be a valid
 DHCP packet, just a type not expected by the server (e.g. it will report
 a received OFFER packet as UNKNOWN).
 
+% DHCP6_PACKET_RECEIVED_MISMATCH_SERVERID %1 packet received, with transaction id %2 on interface %3 containing mismatch ServerID
+A debug message noting that server has received message with ServerID
+option that not matching ServerID that server is using.
+
 % DHCP6_PACKET_RECEIVE_FAIL error on attempt to receive packet: %1
 The IPv6 DHCP server tried to receive a packet but an error
 occurred during this attempt. The reason for the error is included in
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index 667e578..6d82d2e 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2014 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -205,6 +205,29 @@ void Dhcpv6Srv::sendPacket(const Pkt6Ptr& packet) {
     IfaceMgr::instance().send(packet);
 }
 
+bool
+Dhcpv6Srv::testServerID(const Pkt6Ptr& pkt){
+	OptionCollection server_ids = pkt->getOptions(D6O_SERVERID);
+	// if we find serverid option, lets test it.
+	/// @todo: In case we get message that has ServerID option forbidden
+	/// by the RFC, we will drop this loging DHCP6_PACKET_RECEIVED_MISMATCH_SERVERID
+	/// not RFCViolation. Some things should be double checked here and in sanityCheck
+	if (server_ids.size() == 1){
+		// Let us test received ServerID if it is same as ServerID
+		// which is beeing used by server
+		OptionPtr server_id = pkt->getOption(D6O_SERVERID);
+		if (getServerID()->getData() != server_id->getData()){
+			LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL_DATA, DHCP6_PACKET_RECEIVED_MISMATCH_SERVERID)
+				.arg(pkt->getName())
+				.arg(pkt->getTransid())
+				.arg(pkt->getIface());
+			return false;
+		}
+	}
+	// retunr True if: no serverid received or ServerIDs matching
+	return true;
+}
+
 bool Dhcpv6Srv::run() {
     while (!shutdown_) {
         /// @todo Calculate actual timeout to the next event (e.g. lease
@@ -277,6 +300,12 @@ bool Dhcpv6Srv::run() {
                 continue;
             }
         }
+        // Check received query if it carry ServerID that matches ServerID
+        // that beeing used by the server.
+        if (!testServerID(query)){
+        	continue;
+        }
+
         LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PACKET_RECEIVED)
             .arg(query->getName());
         LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL_DATA, DHCP6_QUERY_DATA)
@@ -763,16 +792,6 @@ Dhcpv6Srv::createStatusCode(uint16_t code, const std::string& text) {
 }
 
 void
-Dhcpv6Srv::testServerid(const Pkt6Ptr& pkt){
-	OptionPtr serverid = pkt->getOption(D6O_SERVERID); 
-
-	// I just want to throw exception when server id's don't mach.
-	if (!(getServerID()->getData() == serverid->getData())) 
-		//if received serverid isn't same with our, drop message
-		isc_throw(ServerID_mismatch, "Receievd serverid isn't ours");
-}
-
-void
 Dhcpv6Srv::sanityCheck(const Pkt6Ptr& pkt, RequirementLevel clientid,
                        RequirementLevel serverid) {
     OptionCollection client_ids = pkt->getOptions(D6O_CLIENTID);
@@ -811,21 +830,13 @@ Dhcpv6Srv::sanityCheck(const Pkt6Ptr& pkt, RequirementLevel clientid,
                       << server_ids.size() << "), exactly 1 expected in message "
                       << pkt->getName());
         }
-        // test server received server id to check if that's ours id
-        // RFCViolation will be thrown if we didn't get exaclty one server_id so
-        // checking server_ids.size() here is pointless.
-       	testServerid(pkt);
-       	break;
+        break;
 
     case OPTIONAL:
         if (server_ids.size() > 1) {
             isc_throw(RFCViolation, "Too many (" << server_ids.size()
                       << ") server-id options received in " << pkt->getName());
         }
-        if (server_ids.size() == 1) {
-        			// test server received server id to check if that's ours id 
-                	testServerid(pkt);
-        }
     }
 }
 
diff --git a/src/bin/dhcp6/dhcp6_srv.h b/src/bin/dhcp6/dhcp6_srv.h
index 1e43baa..1ef6d0d 100644
--- a/src/bin/dhcp6/dhcp6_srv.h
+++ b/src/bin/dhcp6/dhcp6_srv.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2013 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2014 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -117,15 +117,16 @@ public:
     /// @param port UDP port on which server should listen.
     static void openActiveSockets(const uint16_t port);
 
-    /// @brief compare received server id with ours server id
+protected:
+
+    /// @brief Compare received server id with our server id
     ///
-    /// Verifies received ServerID with generated ServerID
+    /// Checks if the server id carried in a query from a client matches
+    /// server identifier being used by the server.
     ///
-    /// @param pkt packet to be checked
-    /// @throw ServerID_mismatch if server_ids are not equal
-    void testServerid(const Pkt6Ptr& pkt);
-    
-protected:
+    /// @param pkt DHCPv6 packet carrying server identifier to be checked.
+    /// @return True or False
+    bool testServerID(const Pkt6Ptr& pkt);
 
     /// @brief verifies if specified packet meets RFC requirements
     ///
@@ -138,7 +139,7 @@ protected:
     /// @throw RFCViolation if any issues are detected
     void sanityCheck(const Pkt6Ptr& pkt, RequirementLevel clientid,
                      RequirementLevel serverid);
-    
+
     /// @brief Processes incoming SOLICIT and returns response.
     ///
     /// Processes received SOLICIT message and verifies that its sender
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index cbc01a8..6ef78ab 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2013  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2014  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -1073,24 +1073,13 @@ TEST_F(Dhcpv6SrvTest, sanityCheck) {
     EXPECT_THROW(srv.sanityCheck(pkt, Dhcpv6Srv::MANDATORY, Dhcpv6Srv::MANDATORY),
                  RFCViolation);
 }
-
-TEST_F(Dhcpv6SrvTest, testServerid){
+// Check that server is testing if received ServerID is equal to one beenig used by server
+TEST_F(Dhcpv6SrvTest, testServerID){
 	NakedDhcpv6Srv srv(0);
-	
-    Pkt6Ptr req = Pkt6Ptr(new Pkt6(DHCPV6_REQUEST, 1234));
-    req->setRemoteAddr(IOAddress("fe80::abcd"));
-    boost::shared_ptr<Option6IA> ia = generateIA(D6O_IA_PD, 234, 1500, 3000);
 
-    // with a valid hint
-    IOAddress hint("2001:db8:1:2:f::");
-    ASSERT_TRUE(subnet_->inPool(Lease::TYPE_PD, hint));
-    OptionPtr hint_opt(new Option6IAPrefix(D6O_IAPREFIX, hint, 64, 300, 500));
-    ia->addOption(hint_opt);
-    req->addOption(ia);
-    OptionPtr clientid = generateClientId();
-    req->addOption(clientid);
+	Pkt6Ptr req = Pkt6Ptr(new Pkt6(DHCPV6_REQUEST, 1234));
 
-    // server-id is mandatory in REQUEST
+    // server-id is MANDATORY in REQUEST
     // but add there something else
     std::vector<uint8_t> bin;
 
@@ -1100,16 +1089,21 @@ TEST_F(Dhcpv6SrvTest, testServerid){
     OptionPtr serverid = OptionPtr(new Option(Option::V6, D6O_SERVERID, bin));
 
     req->addOption(serverid);
-    
-    // I moved testServerid in src/bin/dhcp6/dhcp6_srv.h 
-    // above the protected part.
-    EXPECT_THROW(srv.testServerid(req),ServerID_mismatch);
-	
+
+    //Shoud be dropped
+    EXPECT_FALSE(srv.testServerID(req));
+
     req->delOption(D6O_SERVERID);
-    
     req->addOption(srv.getServerID());
-    
-    EXPECT_NO_THROW(srv.testServerid(req));
+
+    //with proper ServerID we expect true
+    EXPECT_TRUE(srv.testServerID(req));
+
+    // server-id is FORBIDDEN in SOLICIT, so check if server is not
+    // dropping corect message
+    Pkt6Ptr pkt = Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234));
+
+    EXPECT_TRUE(srv.testServerID(req));
 }
 
 // This test verifies if selectSubnet() selects proper subnet for a given
diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.h b/src/bin/dhcp6/tests/dhcp6_test_utils.h
index 2b6241e..52d6582 100644
--- a/src/bin/dhcp6/tests/dhcp6_test_utils.h
+++ b/src/bin/dhcp6/tests/dhcp6_test_utils.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2014  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -111,6 +111,7 @@ public:
     using Dhcpv6Srv::createRemovalNameChangeRequest;
     using Dhcpv6Srv::createStatusCode;
     using Dhcpv6Srv::selectSubnet;
+    using Dhcpv6Srv::testServerID;
     using Dhcpv6Srv::sanityCheck;
     using Dhcpv6Srv::loadServerID;
     using Dhcpv6Srv::writeServerID;
diff --git a/src/lib/dhcpsrv/utils.h b/src/lib/dhcpsrv/utils.h
index 99c864e..c01aa87 100644
--- a/src/lib/dhcpsrv/utils.h
+++ b/src/lib/dhcpsrv/utils.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -34,21 +34,6 @@ RFCViolation(const char* file, size_t line, const char* what) :
     isc::Exception(file, line, what) {}
 };
 
-class ServerID_mismatch : public isc::Exception {
-public:
-
-/// @brief constructor
-///
-/// @param file name of the file, where exception occurred
-/// @param line line of the file, where exception occurred
-/// @param what text description of the issue that caused exception
-ServerID_mismatch(const char* file, size_t line, const char* what) :
-    isc::Exception(file, line, what) {}
-};
-
-
-
-
 }; // namespace isc::dhcp
 }; // namespace isc
 



More information about the bind10-changes mailing list