Browse Source

[3539] Address review comments.

Marcin Siodelski 10 years ago
parent
commit
b50479bf52

+ 4 - 1
src/bin/dhcp4/tests/config_parser_unittest.cc

@@ -3031,9 +3031,12 @@ TEST_F(Dhcp4ParserTest, selectedInterfacesAndAddresses) {
     CfgMgr::instance().getStagingCfg()->
         getCfgIface().openSockets(AF_INET, 10000);
 
-    // eth0 and eth1 were explicitly selected. eth2 was not.
+    // An address on eth0 was selected
     EXPECT_TRUE(test_config.socketOpen("eth0", "10.0.0.1"));
+    // The 192.0.2.3 address on eth1 was selected.
     EXPECT_TRUE(test_config.socketOpen("eth1", "192.0.2.3"));
+    // The 192.0.2.5 was not selected, thus the socket should not
+    // be bound to this address.
     EXPECT_FALSE(test_config.socketOpen("eth1", "192.0.2.5"));
 }
 

+ 1 - 1
src/lib/dhcp/iface_mgr.cc

@@ -514,7 +514,7 @@ IfaceMgr::openSockets4(const uint16_t port, const bool use_bcast,
              addr != addrs.end();
              ++addr) {
 
-            // Skip non-IPv4 addresses and thos that weren't selected..
+            // Skip non-IPv4 addresses and those that weren't selected..
             if (!addr->get().isV4() || !addr->isSpecified()) {
                 continue;
             }

+ 1 - 1
src/lib/dhcp/tests/iface_mgr_test_config.h

@@ -241,7 +241,7 @@ public:
     /// @param iface_name Interface name.
     /// @param address Address to which the socket is bound.
     bool socketOpen(const std::string& iface_name,
-                    const std::string & address) const;
+                    const std::string& address) const;
 
     /// @brief Checks if unicast socket is opened on interface.
     ///

+ 3 - 3
src/lib/dhcpsrv/cfg_iface.cc

@@ -79,7 +79,7 @@ CfgIface::openSockets(const uint16_t family, const uint16_t port,
 
                 // Otherwise, activate first one.
                 } else {
-                    IOAddress address("0.0.0.0");
+                    IOAddress address(0);
                     if (iface->getAddress4(address)) {
                         iface->setActive(address, true);
                     }
@@ -251,7 +251,7 @@ CfgIface::use(const uint16_t family, const std::string& iface_name) {
         // Validate V6 address.
         if (family == AF_INET6) {
             // Check that the address is a valid unicast address.
-            if (!addr.isV6() || addr.isV6LinkLocal() || addr.isV6Multicast()) {
+            if (!addr.isV6() || addr.isV6Multicast()) {
                 isc_throw(InvalidIfaceName, "address '" << addr << "' is not"
                           " a valid IPv6 unicast address");
             }
@@ -287,7 +287,7 @@ CfgIface::use(const uint16_t family, const std::string& iface_name) {
         }
 
         if (family == AF_INET6) {
-            LOG_INFO(dhcpsrv_logger, DHCPSRV_CFGMGR_ADD_UNICAST)
+            LOG_INFO(dhcpsrv_logger, DHCPSRV_CFGMGR_USE_UNICAST)
                 .arg(addr.toText()).arg(name);
 
         } else {

+ 3 - 3
src/lib/dhcpsrv/cfg_iface.h

@@ -12,8 +12,8 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
-#ifndef IFACE_CFG_H
-#define IFACE_CFG_H
+#ifndef CFG_IFACE_H
+#define CFG_IFACE_H
 
 #include <asiolink/io_address.h>
 #include <map>
@@ -209,4 +209,4 @@ private:
 }
 }
 
-#endif // IFACE_CFG_H
+#endif // CFG_IFACE_H

+ 5 - 4
src/lib/dhcpsrv/dhcpsrv_messages.mes

@@ -58,9 +58,6 @@ available sooner.
 An info message issued when new interface is being added to the collection of
 interfaces on which server listens to DHCP messages.
 
-% DHCPSRV_CFGMGR_ADD_UNICAST listening on unicast address %1, on interface %2
-A debug message issued when new configuring DHCP server to listen on unicast
-address on the specific interface.
 
 % DHCPSRV_CFGMGR_ADD_SUBNET4 adding subnet %1
 A debug message reported when the DHCP configuration manager is adding the
@@ -143,9 +140,13 @@ receive unicast traffic. The warning message is issued because it is an
 uncommon use.
 
 % DHCPSRV_CFGMGR_USE_ADDRESS listening on address %1, on interface %2
-A message issued when server is configured to listen on the explicitly specified
+A message issued when the server is configured to listen on the explicitly specified
 IP address on the given interface.
 
+% DHCPSRV_CFGMGR_USE_UNICAST listening on unicast address %1, on interface %2
+An info message issued when new configuring DHCP server to listen on unicast
+address on the specific interface.
+
 % 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

+ 0 - 4
src/lib/dhcpsrv/tests/cfg_iface_unittest.cc

@@ -283,10 +283,6 @@ TEST_F(CfgIfaceTest, invalidValues) {
     ASSERT_THROW(cfg.use(AF_INET6, "/2001:db8:1::1"), InvalidIfaceName);
     ASSERT_THROW(cfg.use(AF_INET6, "*/2001:db8:1::1"), InvalidIfaceName);
     ASSERT_THROW(cfg.use(AF_INET6, "bogus/2001:db8:1::1"), NoSuchIface);
-    ASSERT_THROW(cfg.use(AF_INET6, "eth0/fe80::3a60:77ff:fed5:cdef"),
-                 InvalidIfaceName);
-    ASSERT_THROW(cfg.use(AF_INET6, "eth0/fe80::3a60:77ff:fed5:cdef"),
-                 InvalidIfaceName);
     ASSERT_THROW(cfg.use(AF_INET6, "eth0/2001:db8:1::2"), NoSuchAddress);
     ASSERT_NO_THROW(cfg.use(AF_INET6, "*"));
     ASSERT_THROW(cfg.use(AF_INET6, "*"), DuplicateIfaceName);