From: Tomek Mrugalski Date: Wed, 2 Aug 2017 17:58:15 +0000 (+0200) Subject: [5241] Minor changes after review. X-Git-Tag: trac5124a_base~23^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71d40d828e482a72d6325d712f796ae6c812be18;p=thirdparty%2Fkea.git [5241] Minor changes after review. --- diff --git a/doc/guide/dhcp4-srv.xml b/doc/guide/dhcp4-srv.xml index 00187d8557..49597a559a 100644 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@ -1007,7 +1007,7 @@ temporarily override a list of interface names and listen on all interfaces. ] } - The effect is the same than adding the option code in the + The effect is the same as if the client added the option code in the Parameter Request List option (or its equivalent for vendor options) so in: diff --git a/doc/guide/dhcp6-srv.xml b/doc/guide/dhcp6-srv.xml index ebe9441295..198d3dc423 100644 --- a/doc/guide/dhcp6-srv.xml +++ b/doc/guide/dhcp6-srv.xml @@ -1035,7 +1035,7 @@ temporarily override a list of interface names and listen on all interfaces. ] } - The effect is the same than adding the option code in the + The effect is the same as if the client added the option code in the Option Request Option (or its equivalent for vendor options) so in: "Dhcp6": { diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc index 98c9ea7e79..2991dd62f3 100644 --- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc @@ -93,8 +93,33 @@ const char* CONFIGS[] = { " \"valid-lifetime\": 4000," " \"interface\": \"eth0\" " " } ]," - "\"valid-lifetime\": 4000 }" -}; + "\"valid-lifetime\": 4000 }", + + // Configuration 2: + // - 1 subnet, 2 global options (one forced with always-send) + "{" + " \"interfaces-config\": {" + " \"interfaces\": [ \"*\" ] }, " + " \"rebind-timer\": 2000, " + " \"renew-timer\": 1000, " + " \"valid-lifetime\": 4000, " + " \"subnet4\": [ {" + " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ], " + " \"subnet\": \"192.0.2.0/24\"" + " } ], " + " \"option-data\": [" + " {" + " \"name\": \"default-ip-ttl\", " + " \"data\": \"FF\", " + " \"csv-format\": false" + " }, " + " {" + " \"name\": \"ip-forwarding\", " + " \"data\": \"false\", " + " \"always-send\": true" + " }" + " ]" + "}" }; // This test verifies that the destination address of the response // message is set to giaddr, when giaddr is set to non-zero address @@ -751,7 +776,7 @@ TEST_F(Dhcpv4SrvTest, discoverEchoClientId) { CfgMgr::instance().getStagingCfg()->getCfgSubnets4()->add(subnets->at(0)); CfgMgr::instance().getStagingCfg()->setEchoClientId(false); CfgMgr::instance().commit(); - + offer = srv.processDiscover(dis); // Check if we get response at all @@ -2175,35 +2200,7 @@ TEST_F(Dhcpv4SrvTest, prlPersistency) { IfaceMgrTestConfig test_config(true); IfaceMgr::instance().openSockets4(); - NakedDhcpv4Srv srv(0); - - string config = "{ \"interfaces-config\": {" - " \"interfaces\": [ \"*\" ] }, " - "\"rebind-timer\": 2000, " - "\"renew-timer\": 1000, " - "\"valid-lifetime\": 4000, " - "\"subnet4\": [ " - "{ \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ], " - " \"subnet\": \"192.0.2.0/24\" } ], " - "\"option-data\": [" - " { \"name\": \"default-ip-ttl\", " - " \"data\": \"FF\", " - " \"csv-format\": false }, " - " { \"name\": \"ip-forwarding\", " - " \"data\": \"false\", " - " \"always-send\": true } ] }"; - - ConstElementPtr json; - ASSERT_NO_THROW(json = parseDHCP4(config)); - ConstElementPtr status; - - // Configure the server and make sure the config is accepted - EXPECT_NO_THROW(status = configureDhcp4Server(srv, json)); - ASSERT_TRUE(status); - comment_ = config::parseAnswer(rcode_, status); - ASSERT_EQ(0, rcode_); - - CfgMgr::instance().commit(); + ASSERT_NO_THROW(configure(CONFIGS[2])); // Create a packet with enough to select the subnet and go through // the DISCOVER processing @@ -2225,8 +2222,8 @@ TEST_F(Dhcpv4SrvTest, prlPersistency) { ASSERT_TRUE(hostname); query->addOption(hostname); - // Process the query - Pkt4Ptr response = srv.processDiscover(query); + // Let the server process it. + Pkt4Ptr response = srv_.processDiscover(query); // Processing should add an ip-forwarding option ASSERT_TRUE(response->getOption(DHO_IP_FORWARDING)); @@ -2240,8 +2237,8 @@ TEST_F(Dhcpv4SrvTest, prlPersistency) { prl->addValue(DHO_DEFAULT_IP_TTL); query->addOption(prl); - // Process query - response = srv.processDiscover(query); + // Let the server process it again. + response = srv_.processDiscover(query); // Processing should add an ip-forwarding option ASSERT_TRUE(response->getOption(DHO_IP_FORWARDING)); diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc index 33f74be93d..8123f4ea23 100644 --- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc @@ -99,7 +99,33 @@ const char* CONFIGS[] = { " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ]," " \"subnet\": \"2001:db8:1::/48\" " " } ]," - "\"valid-lifetime\": 4000 }" + "\"valid-lifetime\": 4000 }", + + // Configuration 2: + // - a single subnet + // - two global options (one enforced with always-send) + "{" + " \"interfaces-config\": { \"interfaces\": [ \"*\" ] }, " + " \"preferred-lifetime\": 3000, " + " \"rebind-timer\": 2000, " + " \"renew-timer\": 1000, " + " \"valid-lifetime\": 4000, " + " \"subnet6\": [ {" + " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ], " + " \"subnet\": \"2001:db8:1::/48\"" + " } ], " + " \"option-data\": [" + " {" + " \"name\": \"dns-servers\", " + " \"data\": \"2001:db8:1234:FFFF::1\"" + " }, " + " {" + " \"name\": \"subscriber-id\", " + " \"data\": \"1234\", " + " \"always-send\": true" + " }" + " ]" + "}" }; // This test verifies that incoming SOLICIT can be handled properly when @@ -1506,35 +1532,7 @@ TEST_F(Dhcpv6SrvTest, portsRelayedTraffic) { TEST_F(Dhcpv6SrvTest, prlPersistency) { IfaceMgrTestConfig test_config(true); - NakedDhcpv6Srv srv(0); - - string config = "{ \"interfaces-config\": {" - " \"interfaces\": [ \"*\" ] }, " - "\"preferred-lifetime\": 3000, " - "\"rebind-timer\": 2000, " - "\"renew-timer\": 1000, " - "\"valid-lifetime\": 4000, " - "\"subnet6\": [ " - "{ \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ], " - " \"subnet\": \"2001:db8:1::/48\" } ], " - "\"option-data\": [" - " { \"name\": \"dns-servers\", " - " \"data\": \"2001:db8:1234:FFFF::1\" }, " - " { \"name\": \"subscriber-id\", " - " \"data\": \"1234\", " - " \"always-send\": true } ] }"; - - ConstElementPtr json; - ASSERT_NO_THROW(json = parseDHCP6(config)); - ConstElementPtr status; - - // Configure the server and make sure the config is accepted - EXPECT_NO_THROW(status = configureDhcp6Server(srv, json)); - ASSERT_TRUE(status); - comment_ = config::parseAnswer(rcode_, status); - ASSERT_EQ(0, rcode_); - - CfgMgr::instance().commit(); + ASSERT_NO_THROW(configure(CONFIGS[2])); // Create a packet with enough to select the subnet and go through // the SOLICIT processing @@ -1551,10 +1549,10 @@ TEST_F(Dhcpv6SrvTest, prlPersistency) { oro->addValue(D6O_SNTP_SERVERS); sol->addOption(oro); - // Process the solicit - Pkt6Ptr response = srv.processSolicit(sol); + // Let the server process it and generate a response. + Pkt6Ptr response = srv_.processSolicit(sol); - // Processing should add a subscriber-id option + // The server should a subscriber-id option ASSERT_TRUE(response->getOption(D6O_SUBSCRIBER_ID)); // But no dns-servers ASSERT_FALSE(response->getOption(D6O_NAME_SERVERS)); @@ -1566,8 +1564,9 @@ TEST_F(Dhcpv6SrvTest, prlPersistency) { oro->addValue(D6O_NAME_SERVERS); sol->addOption(oro); - // Process solicit - response = srv.processSolicit(sol); + // Let the server process it again. This time the name-servers + // option should be present. + response = srv_.processSolicit(sol); // Processing should add a subscriber-id option ASSERT_TRUE(response->getOption(D6O_SUBSCRIBER_ID));