From: Francis Dupont Date: Mon, 15 Jul 2019 17:27:04 +0000 (+0200) Subject: [606-drop-packets-in-drop-class] Addressed minor comments (checkpoint before rebasing) X-Git-Tag: Kea-1.6.0-beta2~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=330065ad5f60a3b9c2a0aa15bccdcb91e9341f4a;p=thirdparty%2Fkea.git [606-drop-packets-in-drop-class] Addressed minor comments (checkpoint before rebasing) --- diff --git a/doc/guide/classify.xml b/doc/guide/classify.xml index 4ca827d436..83f51fdd2e 100644 --- a/doc/guide/classify.xml +++ b/doc/guide/classify.xml @@ -90,7 +90,7 @@ resort) definition. - 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. diff --git a/doc/guide/dhcp4-srv.xml b/doc/guide/dhcp4-srv.xml index 8b932ce243..959ef2b110 100644 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@ -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. diff --git a/doc/guide/dhcp6-srv.xml b/doc/guide/dhcp6-srv.xml index 78784183d1..7352d0ebd0 100644 --- a/doc/guide/dhcp6-srv.xml +++ b/doc/guide/dhcp6-srv.xml @@ -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 diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 27c32ff4b7..34aac1f5e4 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -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(1)); return; } diff --git a/src/bin/dhcp4/tests/classify_unittest.cc b/src/bin/dhcp4/tests/classify_unittest.cc index 5c1f1047c7..644b427020 100644 --- a/src/bin/dhcp4/tests/classify_unittest.cc +++ b/src/bin/dhcp4/tests/classify_unittest.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -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 diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 5006977a05..3166f4bd59 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -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(1)); return; } diff --git a/src/bin/dhcp6/tests/classify_unittests.cc b/src/bin/dhcp6/tests/classify_unittests.cc index b37ce46ecd..b19372a16d 100644 --- a/src/bin/dhcp6/tests/classify_unittests.cc +++ b/src/bin/dhcp6/tests/classify_unittests.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -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