BIND 10 trac2994, updated. 02141f2524808a5ccf1ac9b620fc702e37607e31 [2994] selectSubnet(), hooks tests for subnet4_select fixes.
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jul 16 13:13:12 UTC 2013
The branch, trac2994 has been updated
via 02141f2524808a5ccf1ac9b620fc702e37607e31 (commit)
from 07074c5295156356a0608fbaf8d706f5eaaaaef8 (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 02141f2524808a5ccf1ac9b620fc702e37607e31
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Tue Jul 16 15:12:52 2013 +0200
[2994] selectSubnet(), hooks tests for subnet4_select fixes.
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp4/dhcp4_srv.cc | 4 +++-
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc | 33 ++++++++++++++++-------------
2 files changed, 21 insertions(+), 16 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc
index 195e3d8..c98651f 100644
--- a/src/bin/dhcp4/dhcp4_srv.cc
+++ b/src/bin/dhcp4/dhcp4_srv.cc
@@ -885,7 +885,7 @@ Dhcpv4Srv::selectSubnet(const Pkt4Ptr& question) {
Subnet4Ptr subnet;
// Is this relayed message?
IOAddress relay = question->getGiaddr();
- if (relay.toText() == "0.0.0.0") {
+ if (relay.toText() != "0.0.0.0") {
// Yes: Use relay address to select subnet
subnet = CfgMgr::instance().getSubnet4(relay);
@@ -895,6 +895,8 @@ Dhcpv4Srv::selectSubnet(const Pkt4Ptr& question) {
subnet = CfgMgr::instance().getSubnet4(question->getRemoteAddr());
}
+ /// @todo Implement getSubnet4(interface-name)
+
// Let's execute all callouts registered for packet_received
if (HooksManager::getHooksManager().calloutsPresent(hook_index_subnet4_select_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(question);
diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
index 4612643..55cfbd3 100644
--- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
+++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
@@ -1622,6 +1622,11 @@ TEST_F(Dhcpv4SrvTest, ServerID) {
EXPECT_EQ(srvid_text, text);
}
+/// @todo Implement tests for subnetSelect See tests in dhcp6_srv_unittest.cc:
+/// selectSubnetAddr, selectSubnetIface, selectSubnetRelayLinkaddr,
+/// selectSubnetRelayInterfaceId. Note that the concept of interface-id is not
+/// present in the DHCPv4, so not everything is applicable directly.
+
// Checks if hooks are registered properly.
TEST_F(Dhcpv4SrvTest, Hooks) {
NakedDhcpv4Srv srv(0);
@@ -1909,14 +1914,14 @@ public:
// Call the basic calllout to record all passed values
subnet4_select_callout(callout_handle);
- Subnet4Collection subnets;
+ const Subnet4Collection* subnets;
Subnet4Ptr subnet;
callout_handle.getArgument("subnet4", subnet);
callout_handle.getArgument("subnet4collection", subnets);
// Let's change to a different subnet
- if (subnets.size() > 1) {
- subnet = subnets[1]; // Let's pick the other subnet
+ if (subnets->size() > 1) {
+ subnet = (*subnets)[1]; // Let's pick the other subnet
callout_handle.setArgument("subnet4", subnet);
}
@@ -2222,16 +2227,15 @@ TEST_F(HooksDhcpv4SrvTest, subnet4_select) {
// Configure 2 subnets, both directly reachable over local interface
// (let's not complicate the matter with relays)
string config = "{ \"interface\": [ \"all\" ],"
- "\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"subnet4\": [ { "
- " \"pool\": [ \"2001:db8:1::/44\" ],"
- " \"subnet\": \"2001:db8:1::/48\", "
+ " \"pool\": [ \"192.0.2.0/25\" ],"
+ " \"subnet\": \"192.0.2.0/24\", "
" \"interface\": \"" + valid_iface_ + "\" "
" }, {"
- " \"pool\": [ \"2001:db8:2::/44\" ],"
- " \"subnet\": \"2001:db8:2::/48\" "
+ " \"pool\": [ \"192.0.3.0/25\" ],"
+ " \"subnet\": \"192.0.3.0/24\" "
" } ],"
"\"valid-lifetime\": 4000 }";
@@ -2246,7 +2250,7 @@ TEST_F(HooksDhcpv4SrvTest, subnet4_select) {
// Prepare discover packet. Server should select first subnet for it
Pkt4Ptr sol = Pkt4Ptr(new Pkt4(DHCPDISCOVER, 1234));
- sol->setRemoteAddr(IOAddress("fe80::abcd"));
+ sol->setRemoteAddr(IOAddress("192.0.2.1"));
sol->setIface(valid_iface_);
OptionPtr clientid = generateClientId();
sol->addOption(clientid);
@@ -2289,16 +2293,15 @@ TEST_F(HooksDhcpv4SrvTest, subnet_select_change) {
// Configure 2 subnets, both directly reachable over local interface
// (let's not complicate the matter with relays)
string config = "{ \"interface\": [ \"all\" ],"
- "\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"subnet4\": [ { "
- " \"pool\": [ \"2001:db8:1::/44\" ],"
- " \"subnet\": \"2001:db8:1::/48\", "
+ " \"pool\": [ \"192.0.2.0/25\" ],"
+ " \"subnet\": \"192.0.2.0/24\", "
" \"interface\": \"" + valid_iface_ + "\" "
" }, {"
- " \"pool\": [ \"2001:db8:2::/44\" ],"
- " \"subnet\": \"2001:db8:2::/48\" "
+ " \"pool\": [ \"192.0.3.0/25\" ],"
+ " \"subnet\": \"192.0.3.0/24\" "
" } ],"
"\"valid-lifetime\": 4000 }";
@@ -2313,7 +2316,7 @@ TEST_F(HooksDhcpv4SrvTest, subnet_select_change) {
// Prepare discover packet. Server should select first subnet for it
Pkt4Ptr sol = Pkt4Ptr(new Pkt4(DHCPDISCOVER, 1234));
- sol->setRemoteAddr(IOAddress("fe80::abcd"));
+ sol->setRemoteAddr(IOAddress("192.0.2.1"));
sol->setIface(valid_iface_);
OptionPtr clientid = generateClientId();
sol->addOption(clientid);
More information about the bind10-changes
mailing list