Commit 4bac0846 authored by Marcin Siodelski's avatar Marcin Siodelski

[3512] Addressed review comments.

parent 578bf4d0
......@@ -614,6 +614,7 @@ TEST_F(IfaceMgrTest, ifaceHasAddress) {
Iface* iface = IfaceMgr::instance().getIface("eth0");
ASSERT_FALSE(iface == NULL);
EXPECT_TRUE(iface->hasAddress(IOAddress("10.0.0.1")));
EXPECT_FALSE(iface->hasAddress(IOAddress("10.0.0.2")));
EXPECT_TRUE(iface->hasAddress(IOAddress("fe80::3a60:77ff:fed5:cdef")));
EXPECT_TRUE(iface->hasAddress(IOAddress("2001:db8:1::1")));
EXPECT_FALSE(iface->hasAddress(IOAddress("2001:db8:1::2")));
......
......@@ -237,6 +237,13 @@ CfgIface::use(const std::string& iface_name) {
" a valid IPv6 unicast address");
}
// There are valid cases where link local address can be specified to
// receive unicast traffic, e.g. sent by relay agent.
if (addr.isV6LinkLocal()) {
LOG_WARN(dhcpsrv_logger, DHCPSRV_CFGMGR_UNICAST_LINK_LOCAL)
.arg(addr.toText()).arg(name);
}
// Interface must have this address assigned.
if (!iface->hasAddress(addr)) {
isc_throw(NoSuchAddress,
......
......@@ -176,17 +176,22 @@ private:
/// @brief Protocol family.
Family family_;
/// @brief Represents a set of interface names.
typedef std::set<std::string> IfaceSet;
/// @brief A set of interface names specified by the user.
IfaceSet iface_set_;
/// @brief A map of interfaces and unicast addresses.
typedef std::map<std::string, asiolink::IOAddress> UnicastMap;
/// @brief A map which holds the pairs of interface names and unicast
/// addresses for which the unicast sockets should be opened.
///
/// This is only used for V6 family.
UnicastMap unicast_map_;
/// @brief A booolean value which indicates that the wildcard interface name
/// has been specified (*).
bool wildcard_used_;
......
......@@ -145,6 +145,11 @@ This is a debug message reporting that the DHCP configuration manager has
returned the specified IPv6 subnet, because detected relay agent address
matches value specified for this subnet.
% DHCPSRV_CFGMGR_UNICAST_LINK_LOCAL specified link local address %1 for unicast traffic on interface %2
This warning message is logged when user specified a link-local address to
receive unicast traffic. The warning message is issued because it is an
uncommon use.
% DHCPSRV_CLOSE_DB closing currently open %1 database
This is a debug message, issued when the DHCP server closes the currently
open lease database. It is issued at program shutdown and whenever
......
......@@ -146,7 +146,7 @@ TEST_F(CfgIfaceTest, explicitNamesV6) {
// select all interfaces to open IPv4 sockets.
TEST_F(CfgIfaceTest, wildcardV4) {
CfgIface cfg(CfgIface::V4);
ASSERT_NO_THROW(cfg.use(CfgIface::ALL_IFACES_KEYWORD));
ASSERT_NO_THROW(cfg.use("*"));
cfg.openSockets(DHCP4_SERVER_PORT);
......@@ -165,7 +165,7 @@ TEST_F(CfgIfaceTest, wildcardV4) {
// select all interfaces to open IPv6 sockets.
TEST_F(CfgIfaceTest, wildcardV6) {
CfgIface cfg(CfgIface::V6);
ASSERT_NO_THROW(cfg.use(CfgIface::ALL_IFACES_KEYWORD));
ASSERT_NO_THROW(cfg.use("*"));
cfg.openSockets(DHCP4_SERVER_PORT);
......@@ -219,8 +219,8 @@ TEST_F(CfgIfaceTest, invalidValues) {
ASSERT_THROW(cfg.use("eth0/fe80::3a60:77ff:fed5:cdef"), InvalidIfaceName);
ASSERT_THROW(cfg.use("eth0/2001:db8:1::2"), NoSuchAddress);
ASSERT_NO_THROW(cfg.use(CfgIface::ALL_IFACES_KEYWORD));
ASSERT_THROW(cfg.use(CfgIface::ALL_IFACES_KEYWORD), DuplicateIfaceName);
ASSERT_NO_THROW(cfg.use("*"));
ASSERT_THROW(cfg.use("*"), DuplicateIfaceName);
}
} // end of anonymous namespace
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment