]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[606-drop-packets-in-drop-class] Addressed minor comments (checkpoint before rebasing)
authorFrancis Dupont <fdupont@isc.org>
Mon, 15 Jul 2019 17:27:04 +0000 (19:27 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 16 Jul 2019 09:11:19 +0000 (05:11 -0400)
doc/guide/classify.xml
doc/guide/dhcp4-srv.xml
doc/guide/dhcp6-srv.xml
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/tests/classify_unittest.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/tests/classify_unittests.cc

index 4ca827d436b07845888c5cc7c10331333cf0df2c..83f51fdd2eb36bd8900a9f8cc9245d42481df482 100644 (file)
@@ -90,7 +90,7 @@
       resort) definition.
       </para></listitem>
       <listitem><para>
-      When the incoming packet belongs the special DROP class it is
+      When the incoming packet belongs the special class, "DROP", it is
       dropped and an informational message is logged with the packet
       information.
       </para></listitem>
index 8b932ce243e88fc5424d10d342639db265a5a917..959ef2b110271180c2bbcf47b3c715b46f8e0d21 100644 (file)
@@ -2534,8 +2534,8 @@ It is merely echoed by the server.
       The first step is to assess an incoming packet and assign it to
       zero or more classes.
       The second step is to choose a subnet, possibly based on the
-      class information. When the incoming packet is in the "DROP"
-      special class it is dropped and an information message logged.
+      class information. When the incoming packet is in the special
+      class, "DROP", it is dropped and an information message logged.
       The next step is to evaluate class expressions depending on the
       built-in "KNOWN"/"UNKNOWN" classes after host reservation lookup,
       using them for pool selection and assigning classes from host reservations.
index 78784183d1eb02d7d45e89cf876ded2facbac394..7352d0ebd0f7143403aa410ed38fb4647cb2f36f 100644 (file)
@@ -2429,8 +2429,8 @@ should include options from the new option space:
       The first step is to assess an incoming packet and assign it to
       zero or more classes.
       Next, a subnet is chosen, possibly based on the
-      class information. When the incoming packet is inthe "DROP"
-      special class it is dropped and an information message logged.
+      class information. When the incoming packet is in the special
+      class, "DROP", it is dropped and an information message logged.
       After that, class expressions are evaluated depending on the
       built-in "KNOWN"/"UNKNOWN" classes after host reservation lookup,
       using them for pool/pd-pool selection and assigning classes from host
index 27c32ff4b76929488fd2948c5f8426ea93b81ecc..34aac1f5e45b1f434c2b8f8a9b64c8ac0e32310d 100644 (file)
@@ -1010,7 +1010,8 @@ Dhcpv4Srv::processPacket(Pkt4Ptr& query, Pkt4Ptr& rsp, bool allow_packet_park) {
     if (query->inClass("DROP")) {
         LOG_INFO(packet4_logger, DHCP4_PACKET_DROP_DROP_CLASS)
             .arg(query->toText());
-        // increase pkt4-receive-drop stats?
+        isc::stats::StatsMgr::instance().addValue("pkt4-receive-drop",
+                                                  static_cast<int64_t>(1));
         return;
     }
 
index 5c1f1047c7dd8fa208e9d218da0df683953d1622..644b42702079d4fa93fde30619326b8bd9e06062 100644 (file)
@@ -10,6 +10,7 @@
 #include <dhcp/tests/iface_mgr_test_config.h>
 #include <dhcp4/tests/dhcp4_client.h>
 #include <dhcp/option_int.h>
+#include <stats/stats_mgr.h>
 #include <algorithm>
 #include <vector>
 
@@ -1154,6 +1155,14 @@ TEST_F(ClassifyTest, dropClass) {
 
     // Option, dropped.
     EXPECT_FALSE(client2.getContext().response_);
+
+    // There should also be pkt4-receive-drop stat bumped up.
+    stats::StatsMgr& mgr = stats::StatsMgr::instance();
+    stats::ObservationPtr drop_stat = mgr.getObservation("pkt4-receive-drop");
+
+    // This statistic must be present and must be set to 1.
+    ASSERT_TRUE(drop_stat);
+    EXPECT_EQ(1, drop_stat->getInteger().first);
 }
 
 } // end of anonymous namespace
index 5006977a054295434440759887fc5d97da3bfcb6..3166f4bd5997d55544cdd002ca4f1d8f24b3c3de 100644 (file)
@@ -687,7 +687,8 @@ Dhcpv6Srv::processPacket(Pkt6Ptr& query, Pkt6Ptr& rsp) {
     if (query->inClass("DROP")) {
         LOG_INFO(packet6_logger, DHCP6_PACKET_DROP_DROP_CLASS)
             .arg(query->toText());
-        // increase pkt6-receive-drop stats?
+        StatsMgr::instance().addValue("pkt6-receive-drop",
+                                      static_cast<int64_t>(1));
         return;
     }
 
index b37ce46ecd7a5da7e093aee1383ba172657a09a9..b19372a16d8c3d42e0619dfaa01516cce0bde149 100644 (file)
@@ -20,6 +20,7 @@
 #include <dhcp6/tests/dhcp6_test_utils.h>
 #include <dhcp6/tests/dhcp6_client.h>
 #include <asiolink/io_address.h>
+#include <stats/stats_mgr.h>
 #include <boost/pointer_cast.hpp>
 #include <string>
 
@@ -2107,6 +2108,14 @@ TEST_F(ClassifyTest, dropClass) {
 
     // Option, dropped.
     EXPECT_FALSE(client2.getContext().response_);
+
+    // There should also be pkt6-receive-drop stat bumped up.
+    stats::StatsMgr& mgr = stats::StatsMgr::instance();
+    stats::ObservationPtr drop_stat = mgr.getObservation("pkt6-receive-drop");
+
+    // This statistic must be present and must be set to 1.
+    ASSERT_TRUE(drop_stat);
+    EXPECT_EQ(1, drop_stat->getInteger().first);
 }
 
 } // end of anonymous namespace