Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
02141f25
Commit
02141f25
authored
Jul 16, 2013
by
Tomek Mrugalski
🛰
Browse files
[2994] selectSubnet(), hooks tests for subnet4_select fixes.
parent
07074c52
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/dhcp4/dhcp4_srv.cc
View file @
02141f25
...
...
@@ -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
);
...
...
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
View file @
02141f25
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment