Browse Source

[1555] Log activation and deactivation of the interface.

Marcin Siodelski 11 years ago
parent
commit
39fa196b6b

+ 22 - 8
src/bin/dhcp4/ctrl_dhcp4_srv.cc

@@ -254,19 +254,33 @@ ControlledDhcpv4Srv::execDhcpv4ServerCommand(const std::string& command_id,
 }
 }
 
 
 void
 void
-ControlledDhcpv4Srv::openActiveSockets(const uint16_t port, const bool use_bcast) {
+ControlledDhcpv4Srv::openActiveSockets(const uint16_t port,
+                                       const bool use_bcast) {
     IfaceMgr::instance().closeSockets();
     IfaceMgr::instance().closeSockets();
 
 
-    // Get the reference to the collection of interfaces. This reference should be
-    // valid as long as the program is run because IfaceMgr is a singleton.
-    // Therefore we can safely iterate over instances of all interfaces and modify
-    // their flags. Here we modify flags which indicate whether socket should be
-    // open for a particular interface or not.
+    // Get the reference to the collection of interfaces. This reference should
+    // be valid as long as the program is run because IfaceMgr is a singleton.
+    // Therefore we can safely iterate over instances of all interfaces and
+    // modify their flags. Here we modify flags which indicate whether socket
+    // should be open for a particular interface or not.
     const IfaceMgr::IfaceCollection& ifaces = IfaceMgr::instance().getIfaces();
     const IfaceMgr::IfaceCollection& ifaces = IfaceMgr::instance().getIfaces();
     for (IfaceMgr::IfaceCollection::const_iterator iface = ifaces.begin();
     for (IfaceMgr::IfaceCollection::const_iterator iface = ifaces.begin();
          iface != ifaces.end(); ++iface) {
          iface != ifaces.end(); ++iface) {
-        IfaceMgr::instance().getIface(iface->getName())->inactive_ =
-            !CfgMgr::instance().isActiveIface(iface->getName());
+        Iface* iface_ptr = IfaceMgr::instance().getIface(iface->getName());
+        if (CfgMgr::instance().isActiveIface(iface->getName())) {
+            iface_ptr->inactive_ = false;
+            LOG_INFO(dhcp4_logger, DHCP4_ACTIVATE_INTERFACE)
+                .arg(iface->getFullName());
+
+        } else {
+            // For deactivating interface, it should be sufficient to log it
+            // on the debug level because it is more useful to know what
+            // interface is activated which is logged on the info level.
+            LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC,
+                      DHCP4_DEACTIVATE_INTERFACE).arg(iface->getName());
+            iface_ptr->inactive_ = true;
+
+        }
     }
     }
     // Let's reopen active sockets. openSockets4 will check internally whether
     // Let's reopen active sockets. openSockets4 will check internally whether
     // sockets are marked active or inactive.
     // sockets are marked active or inactive.

+ 10 - 0
src/bin/dhcp4/dhcp4_messages.mes

@@ -14,6 +14,11 @@
 
 
 $NAMESPACE isc::dhcp
 $NAMESPACE isc::dhcp
 
 
+% DHCP4_ACTIVATE_INTERFACE activating interface %1
+This message is printed when DHCPv4 server enabled an interface to be used
+to receive DHCPv4 traffic. IPv4 socket on this interface will be opened once
+Interface Manager starts up procedure of opening sockets.
+
 % DHCP4_CCSESSION_STARTED control channel session started on socket %1
 % DHCP4_CCSESSION_STARTED control channel session started on socket %1
 A debug message issued during startup after the IPv4 DHCP server has
 A debug message issued during startup after the IPv4 DHCP server has
 successfully established a session with the BIND 10 control channel.
 successfully established a session with the BIND 10 control channel.
@@ -60,6 +65,11 @@ This informational message is printed every time DHCPv4 server is started
 and gives both the type and name of the database being used to store
 and gives both the type and name of the database being used to store
 lease and other information.
 lease and other information.
 
 
+% DHCP4_DEACTIVATE_INTERFACE deactivate interface %1
+This message is printed when DHCPv4 server disables an interface from being
+used to receive DHCPv4 traffic. Sockets on this interface will not be opened
+by the Interface Manager until interface is enabled.
+
 % DHCP4_LEASE_ADVERT lease %1 advertised (client client-id %2, hwaddr %3)
 % DHCP4_LEASE_ADVERT lease %1 advertised (client client-id %2, hwaddr %3)
 This debug message indicates that the server successfully advertised
 This debug message indicates that the server successfully advertised
 a lease. It is up to the client to choose one server out of othe advertised
 a lease. It is up to the client to choose one server out of othe advertised

+ 17 - 4
src/bin/dhcp6/ctrl_dhcp6_srv.cc

@@ -263,11 +263,24 @@ ControlledDhcpv6Srv::openActiveSockets(const uint16_t port) {
     // Therefore we can safely iterate over instances of all interfaces and modify
     // Therefore we can safely iterate over instances of all interfaces and modify
     // their flags. Here we modify flags which indicate wheter socket should be
     // their flags. Here we modify flags which indicate wheter socket should be
     // open for a particular interface or not.
     // open for a particular interface or not.
-    IfaceMgr::IfaceCollection ifaces = IfaceMgr::instance().getIfaces();
-    for (IfaceMgr::IfaceCollection::iterator iface = ifaces.begin();
+    const IfaceMgr::IfaceCollection& ifaces = IfaceMgr::instance().getIfaces();
+    for (IfaceMgr::IfaceCollection::const_iterator iface = ifaces.begin();
          iface != ifaces.end(); ++iface) {
          iface != ifaces.end(); ++iface) {
-        IfaceMgr::instance().getIface(iface->getName())->inactive_ =
-            !CfgMgr::instance().isActiveIface(iface->getName());
+        Iface* iface_ptr = IfaceMgr::instance().getIface(iface->getName());
+        if (CfgMgr::instance().isActiveIface(iface->getName())) {
+            iface_ptr->inactive_ = false;
+            LOG_INFO(dhcp6_logger, DHCP6_ACTIVATE_INTERFACE)
+                .arg(iface->getFullName());
+
+        } else {
+            // For deactivating interface, it should be sufficient to log it
+            // on the debug level because it is more useful to know what
+            // interface is activated which is logged on the info level.
+            LOG_DEBUG(dhcp6_logger, DBG_DHCP6_BASIC,
+                      DHCP6_DEACTIVATE_INTERFACE).arg(iface->getName());
+            iface_ptr->inactive_ = true;
+
+        }
     }
     }
     // Let's reopen active sockets. openSockets6 will check internally whether
     // Let's reopen active sockets. openSockets6 will check internally whether
     // sockets are marked active or inactive.
     // sockets are marked active or inactive.

+ 10 - 0
src/bin/dhcp6/dhcp6_messages.mes

@@ -14,6 +14,11 @@
 
 
 $NAMESPACE isc::dhcp
 $NAMESPACE isc::dhcp
 
 
+% DHCP6_ACTIVATE_INTERFACE activating interface %1
+This message is printed when DHCPv6 server enabled an interface to be used
+to receive DHCPv6 traffic. IPv6 socket on this interface will be opened once
+Interface Manager starts up procedure of opening sockets.
+
 % DHCP6_CCSESSION_STARTED control channel session started on socket %1
 % DHCP6_CCSESSION_STARTED control channel session started on socket %1
 A debug message issued during startup after the IPv6 DHCP server has
 A debug message issued during startup after the IPv6 DHCP server has
 successfully established a session with the BIND 10 control channel.
 successfully established a session with the BIND 10 control channel.
@@ -65,6 +70,11 @@ This informational message is printed every time the IPv6 DHCP server
 is started.  It indicates what database backend type is being to store
 is started.  It indicates what database backend type is being to store
 lease and other information.
 lease and other information.
 
 
+% DHCP6_DEACTIVATE_INTERFACE deactivate interface %1
+This message is printed when DHCPv6 server disables an interface from being
+used to receive DHCPv6 traffic. Sockets on this interface will not be opened
+by the Interface Manager until interface is enabled.
+
 % DHCP6_LEASE_ADVERT lease %1 advertised (client duid=%2, iaid=%3)
 % DHCP6_LEASE_ADVERT lease %1 advertised (client duid=%2, iaid=%3)
 This debug message indicates that the server successfully advertised
 This debug message indicates that the server successfully advertised
 a lease. It is up to the client to choose one server out of the
 a lease. It is up to the client to choose one server out of the