parser = new PdPoolListParser(config_id, pools_);
} else if (config_id.compare("option-data") == 0) {
parser = new OptionDataListParser(config_id, options_, AF_INET6);
+ } else if (config_id.compare("rapid-commit") == 0) {
+ parser = new BooleanParser(config_id, boolean_values_);
} else {
isc_throw(NotImplemented, "unsupported parameter: " << config_id);
}
}
}
- stringstream tmp;
- tmp << addr << "/" << static_cast<int>(len)
- << " with params t1=" << t1 << ", t2=" << t2 << ", pref="
- << pref << ", valid=" << valid;
+ bool rapid_commit = boolean_values_->getOptionalParam("rapid-commit", false);
- LOG_INFO(dhcp6_logger, DHCP6_CONFIG_NEW_SUBNET).arg(tmp.str());
+ std::ostringstream output;
+ output << addr << "/" << static_cast<int>(len)
+ << " with params t1=" << t1 << ", t2="
+ << t2 << ", preferred-lifetime=" << pref
+ << ", valid-lifetime=" << valid
+ << ", rapid-commit is " << (rapid_commit ? "enabled" : "disabled");
+
+ LOG_INFO(dhcp6_logger, DHCP6_CONFIG_NEW_SUBNET).arg(output.str());
// Create a new subnet.
Subnet6* subnet6 = new Subnet6(addr, len, t1, t2, pref, valid,
subnet6->setInterfaceId(opt);
}
+ // Enable or disable Rapid Commit option support for the subnet.
+ subnet6->setRapidCommit(rapid_commit);
+
// Try setting up client class (if specified)
try {
string client_class = string_values_->getParam("client-class");
CfgMgr::instance().clear();
}
+ /// @brief Tests teh Rapid Commit configuration for a subnet.
+ ///
+ /// This test configures the server with a given configuration and
+ /// verifies if the Rapid Commit has been configured successfully
+ /// for a subnet.
+ ///
+ /// @param config Server configuration, possibly including the
+ /// 'rapid-commit' parameter.
+ /// @param exp_rapid_commit Expected value of the Rapid Commit flag
+ /// within a subnet.
+ void testRapidCommit(const std::string& config,
+ const bool exp_rapid_commit) {
+ // Clear any existing configuration.
+ CfgMgr::instance().clear();
+
+ // Configure the server.
+ ElementPtr json = Element::fromJSON(config);
+
+ // Make sure that the configuration was successful.
+ ConstElementPtr status;
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
+ checkResult(status, 0);
+
+ // Get the subnet.
+ Subnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->
+ selectSubnet(IOAddress("2001:db8:1::5"), classify_);
+ ASSERT_TRUE(subnet);
+
+ // Check the Rapid Commit flag for the subnet.
+ EXPECT_EQ(exp_rapid_commit, subnet->getRapidCommit());
+ }
+
int rcode_; ///< Return code (see @ref isc::config::parseAnswer)
Dhcpv6Srv srv_; ///< Instance of the Dhcp6Srv used during tests
ConstElementPtr comment_; ///< Comment (see @ref isc::config::parseAnswer)
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
+// This test checks the configuration of the Rapid Commit option
+// support for the subnet.
+TEST_F(Dhcp6ParserTest, subnetRapidCommit) {
+ {
+ // rapid-commit implicitly set to false.
+ SCOPED_TRACE("Default Rapid Commit setting");
+ testRapidCommit("{ \"preferred-lifetime\": 3000,"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, "
+ "\"subnet6\": [ { "
+ " \"pools\": [ { \"pool\": \"2001:db8:1::1 - "
+ "2001:db8:1::ffff\" } ],"
+ " \"subnet\": \"2001:db8:1::/64\" } ],"
+ "\"valid-lifetime\": 4000 }",
+ false);
+ }
+
+ {
+ SCOPED_TRACE("Enable Rapid Commit");
+ // rapid-commit explicitly set to true.
+ testRapidCommit("{ \"preferred-lifetime\": 3000,"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, "
+ "\"subnet6\": [ { "
+ " \"pools\": [ { \"pool\": \"2001:db8:1::1 - "
+ "2001:db8:1::ffff\" } ],"
+ " \"rapid-commit\": True,"
+ " \"subnet\": \"2001:db8:1::/64\" } ],"
+ "\"valid-lifetime\": 4000 }",
+ true);
+ }
+
+ {
+ SCOPED_TRACE("Disable Rapid Commit");
+ // rapid-commit explicitly set to false.
+ testRapidCommit("{ \"preferred-lifetime\": 3000,"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, "
+ "\"subnet6\": [ { "
+ " \"pools\": [ { \"pool\": \"2001:db8:1::1 - "
+ "2001:db8:1::ffff\" } ],"
+ " \"rapid-commit\": False,"
+ " \"subnet\": \"2001:db8:1::/64\" } ],"
+ "\"valid-lifetime\": 4000 }",
+ false);
+ }
+}
+
// This test checks that multiple pools can be defined and handled properly.
// The test defines 2 subnets, each with 2 pools.
TEST_F(Dhcp6ParserTest, multiplePools) {
SubnetConfigParser::SubnetConfigParser(const std::string&,
ParserContextPtr global_context,
const isc::asiolink::IOAddress& default_addr)
- : uint32_values_(new Uint32Storage()),
- string_values_(new StringStorage()),
- boolean_values_(new BooleanStorage()),
- pools_(new PoolStorage()), global_context_(global_context),
+ : boolean_values_(new BooleanStorage()), uint32_values_(new Uint32Storage()),
+ string_values_(new StringStorage()), pools_(new PoolStorage()),
+ global_context_(global_context),
relay_info_(new isc::dhcp::Subnet::RelayInfo(default_addr)),
options_(new CfgOption()) {
// The first parameter should always be "subnet", but we don't check