]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1555] Log activation and deactivation of the interface.
authorMarcin Siodelski <marcin@isc.org>
Thu, 11 Jul 2013 16:35:28 +0000 (18:35 +0200)
committerMarcin Siodelski <marcin@isc.org>
Thu, 11 Jul 2013 16:35:28 +0000 (18:35 +0200)
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/dhcp4_messages.mes
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_messages.mes

index ebe2455cb2212f0fa85af63f2acaa651bd14479f..7d7354eefe7dff12f90a080198501229400c9f70 100644 (file)
@@ -254,19 +254,33 @@ ControlledDhcpv4Srv::execDhcpv4ServerCommand(const std::string& command_id,
 }
 
 void
-ControlledDhcpv4Srv::openActiveSockets(const uint16_t port, const bool use_bcast) {
+ControlledDhcpv4Srv::openActiveSockets(const uint16_t port,
+                                       const bool use_bcast) {
     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();
     for (IfaceMgr::IfaceCollection::const_iterator iface = ifaces.begin();
          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
     // sockets are marked active or inactive.
index 8b3e2552ddcb0fa19880fa7e5dead4cd934cd68e..0f0fd26369dc9db0c99a78e7ac2d26d1fc1567f9 100644 (file)
 
 $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
 A debug message issued during startup after the IPv4 DHCP server has
 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
 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)
 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
index 0bd9c51320882f0e813dd85f40a2f5b524e75fce..60b873563d480b8c220210f9a43e4010e5a50130 100644 (file)
@@ -263,11 +263,24 @@ ControlledDhcpv6Srv::openActiveSockets(const uint16_t port) {
     // Therefore we can safely iterate over instances of all interfaces and modify
     // their flags. Here we modify flags which indicate wheter socket should be
     // 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) {
-        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
     // sockets are marked active or inactive.
index 6b61473dc745e57220dab056a58f92801e8b3452..5e0eff7f5cef5bee9414f9e89eada5c6a83d21a5 100644 (file)
 
 $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
 A debug message issued during startup after the IPv6 DHCP server has
 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
 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)
 This debug message indicates that the server successfully advertised
 a lease. It is up to the client to choose one server out of the