Browse Source

[1986] Add logging and doxygen about internal ddnsforwarder

Jelte Jansen 13 years ago
parent
commit
64d089fdc9

+ 16 - 0
src/bin/auth/auth_messages.mes

@@ -235,6 +235,13 @@ This is a debug message indicating that the authoritative server has
 found that the data source it is loading is an SQLite3 data source,
 found that the data source it is loading is an SQLite3 data source,
 so no further validation is needed.
 so no further validation is needed.
 
 
+% AUTH_START_DDNS_FORWARDER DDNS UPDATE handling started
+This is a debug message indicating that b10-auth has received a message
+that it should internally forward UPDATE message to b10-ddns. When b10-ddns
+is not running, b10-auth will respond to UPDATE requests with rcode NOTIMP.
+When b10-ddns is running, b10-ddns will handle and respond to the UPDATE
+message.
+
 % AUTH_STATS_CHANNEL_CREATED STATS session channel created
 % AUTH_STATS_CHANNEL_CREATED STATS session channel created
 This is a debug message indicating that the authoritative server has
 This is a debug message indicating that the authoritative server has
 created a channel to the statistics process.  It is issued during server
 created a channel to the statistics process.  It is issued during server
@@ -266,6 +273,15 @@ This is a debug message indicating that the statistics timer has been
 enabled and that the authoritative server will produce statistics data
 enabled and that the authoritative server will produce statistics data
 at the specified interval.
 at the specified interval.
 
 
+% AUTH_STOP_DDNS_FORWARDER DDNS UPDATE handling stopped
+This is a debug message indicating that b10-auth has received a message
+that it should stop internally forwarding UPDATE message to b10-ddns.
+b10-auth will no longer forward UPDATE messages to b10-ddns, but will
+respond itself with error code NOTIMP.
+This message is also logged when the forwarding is restarted (for instance
+if b10-ddns is restarted and the internal connection needs to be created
+again), in which case it should be followed by AUTH_START_DDNS_FORWARDER.
+
 % AUTH_UNSUPPORTED_OPCODE unsupported opcode: %1
 % AUTH_UNSUPPORTED_OPCODE unsupported opcode: %1
 This is a debug message, produced when a received DNS packet being
 This is a debug message, produced when a received DNS packet being
 processed by the authoritative server has been found to contain an
 processed by the authoritative server has been found to contain an

+ 8 - 3
src/bin/auth/auth_srv.cc

@@ -900,13 +900,18 @@ AuthSrvImpl::createDDNSForwarder() {
     if (hasDDNSForwarder()) {
     if (hasDDNSForwarder()) {
         destroyDDNSForwarder();
         destroyDDNSForwarder();
     }
     }
-    ddns_forwarder_ = new SocketSessionForwarderHolder("update", ddns_base_forwarder_);
+    LOG_DEBUG(auth_logger, DBG_AUTH_OPS, AUTH_START_DDNS_FORWARDER);
+    ddns_forwarder_ = new SocketSessionForwarderHolder("update",
+                                                       ddns_base_forwarder_);
 }
 }
 
 
 void
 void
 AuthSrvImpl::destroyDDNSForwarder() {
 AuthSrvImpl::destroyDDNSForwarder() {
-    delete ddns_forwarder_;
+    if (ddns_forwarder_ != NULL) {
-    ddns_forwarder_ = NULL;
+        LOG_DEBUG(auth_logger, DBG_AUTH_OPS, AUTH_STOP_DDNS_FORWARDER);
+        delete ddns_forwarder_;
+        ddns_forwarder_ = NULL;
+    }
 }
 }
 
 
 bool
 bool

+ 16 - 2
src/bin/auth/auth_srv.h

@@ -418,9 +418,23 @@ public:
     void setTSIGKeyRing(const boost::shared_ptr<isc::dns::TSIGKeyRing>*
     void setTSIGKeyRing(const boost::shared_ptr<isc::dns::TSIGKeyRing>*
                         keyring);
                         keyring);
 
 
-    /// \brief Tells the server DDNS update packets can be forwarded internally
+    /// \brief Create the internal forwarder for DDNS update messages
-    ///
+    ///
+    /// Until this method is called (it is called when the
+    /// start_ddns_forwarder command is sent to b10-auth), b10-auth will
+    /// respond to UPDATE packets with a NOTIMP rcode.
+    /// If the internal forwarder was already created, it is destroyed and
+    /// created again. This is useful for instance when b10-ddns is shut
+    /// down and restarted.
     void createDDNSForwarder();
     void createDDNSForwarder();
+
+    /// \brief Destroy the internal forwarder for DDNS update messages
+    ///
+    /// After this method has been called (it is called when the
+    /// stop_ddns_forwarder command is sent to b10-auth), DDNS Update
+    /// messages are no longer forwarded internally, but b10-auth will
+    /// immediately respond with a NOTIMP rcode.
+    /// If there was no forwarder yet, this method does nothing.
     void destroyDDNSForwarder();
     void destroyDDNSForwarder();
 
 
 private:
 private:

+ 1 - 0
src/bin/auth/common.cc

@@ -57,3 +57,4 @@ getDDNSSocketPath() {
 }
 }
 
 
 const char* const AUTH_NAME = "b10-auth";
 const char* const AUTH_NAME = "b10-auth";
+const char* const AUTH_STARTED_NOTIFICATION = "auth_started";

+ 5 - 0
src/bin/auth/common.h

@@ -57,6 +57,11 @@ std::string getDDNSSocketPath();
 /// This is currently b10-auth, but it can be changed easily in one place.
 /// This is currently b10-auth, but it can be changed easily in one place.
 extern const char* const AUTH_NAME;
 extern const char* const AUTH_NAME;
 
 
+/// \brief Notification string that is used to inform auth is starting
+///
+/// This is sent to interested modules (currently only b10-ddns)
+extern const char* const AUTH_STARTED_NOTIFICATION;
+
 #endif // __COMMON_H
 #endif // __COMMON_H
 
 
 // Local Variables:
 // Local Variables:

+ 4 - 1
src/bin/auth/main.cc

@@ -212,7 +212,10 @@ main(int argc, char* argv[]) {
         LOG_INFO(auth_logger, AUTH_SERVER_STARTED);
         LOG_INFO(auth_logger, AUTH_SERVER_STARTED);
 
 
         // Ping any interested module that (a new) auth is up
         // Ping any interested module that (a new) auth is up
-        cc_session->group_sendmsg(isc::config::createCommand("auth_started"), "DDNS");
+        // Currently, only the DDNS module is notified, but we could consider
+        // make an announcement channel for these (one-way) messages
+        cc_session->group_sendmsg(
+            isc::config::createCommand(AUTH_STARTED_NOTIFICATION), "DDNS");
         io_service.run();
         io_service.run();
 
 
     } catch (const std::exception& ex) {
     } catch (const std::exception& ex) {