Browse Source

[1986] Messaging between auth and DDNS

cleanup and logging pending, but basic functionality is there;
upon start, b10-ddns will send auth a command to start forwarding
upon shutdown, b10-ddns will send auth a command to stop forwarding
auth also sends b10-ddns a command to send the above command, so that a restart of auth does not make things break down (auth does not expect an answer here, it is only a hint; b10-ddns, if running, will then send its start command to auth again)
Jelte Jansen 12 years ago
parent
commit
1f6f0248eb

+ 10 - 0
src/bin/auth/auth.spec.pre.in

@@ -131,6 +131,16 @@
             "item_optional": true, "item_default": "memory"
           }
         ]
+      },
+      {
+        "command_name": "start_ddns_forwarder",
+        "command_description": "(Re)start internal forwarding of DDNS Update packets.",
+        "command_args": []
+      },
+      {
+        "command_name": "stop_ddns_forwarder",
+        "command_description": "Stop internal forwarding of DDNS Update packets",
+        "command_args": []
       }
     ],
     "statistics": [

+ 3 - 0
src/bin/auth/main.cc

@@ -210,6 +210,9 @@ main(int argc, char* argv[]) {
 
         // Successfully initialized.
         LOG_INFO(auth_logger, AUTH_SERVER_STARTED);
+
+        // Ping any interested module that (a new) auth is up
+        cc_session->group_sendmsg(isc::config::createCommand("auth_started"), "DDNS");
         io_service.run();
 
     } catch (const std::exception& ex) {

+ 26 - 0
src/bin/ddns/ddns.py.in

@@ -228,6 +228,9 @@ class DDNSServer:
         # Outstanding TCP context: fileno=>(context_obj, dst)
         self._tcp_ctxs = {}
 
+        # Notify Auth server that DDNS update packets can now be forwarded
+        self.__notify_start_forwarder()
+
     class InternalError(Exception):
         '''Exception for internal errors in an update session.
 
@@ -274,6 +277,9 @@ class DDNSServer:
             logger.info(DDNS_RECEIVED_SHUTDOWN_COMMAND)
             self.trigger_shutdown()
             answer = create_answer(0)
+        elif cmd == "auth_started":
+            self.__notify_start_forwarder()
+            answer = None
         else:
             answer = create_answer(1, "Unknown command: " + str(cmd))
         return answer
@@ -378,6 +384,8 @@ class DDNSServer:
         Do NOT call this to initialize shutdown, use trigger_shutdown().
 
         '''
+        # tell Auth not to forward UPDATE packets anymore
+        self.__notify_stop_forwarder()
         # tell the ModuleCCSession to send a message that this module is
         # stopping.
         self._cc.send_stopping()
@@ -533,6 +541,24 @@ class DDNSServer:
 
         return True
 
+    def __notify_start_forwarder(self):
+        '''Notify auth that DDNS Update packets can now be forwarded'''
+        seq = self._cc._session.group_sendmsg(create_command("start_ddns_forwarder"),
+                                        AUTH_MODULE_NAME)
+        answer, _ = self._cc._session.group_recvmsg(False, seq)
+        rcode, error_msg = parse_answer(answer)
+        if (rcode != 0):
+            raise Exception(error_msg)
+
+    def __notify_stop_forwarder(self):
+        '''Notify auth that DDNS Update packets can now be forwarded'''
+        seq = self._cc._session.group_sendmsg(create_command("stop_ddns_forwarder"),
+                                        AUTH_MODULE_NAME)
+        answer, _ = self._cc._session.group_recvmsg(False, seq)
+        rcode, error_msg = parse_answer(answer)
+        if (rcode != 0):
+            raise Exception(error_msg)
+
     def __notify_auth(self, zname, zclass):
         '''Notify auth of the update, if necessary.'''
         msg = auth_loadzone_command(self._cc, zname, zclass)

+ 8 - 8
tests/lettuce/features/ddns_system.feature

@@ -54,13 +54,13 @@ Feature: DDNS System
         # Test 8
         # Known issue: after shutdown, first new attempt results in SERVFAIL
         When I use DDNS to set the SOA serial to 1238
-        The DDNS response should be SERVFAIL
-        And the SOA serial for example.org should be 1237
+        The DDNS response should be SUCCESS
+        And the SOA serial for example.org should be 1238
 
-        When I use DDNS to set the SOA serial to 1238
+        When I use DDNS to set the SOA serial to 1239
         And wait for new bind10 stderr message AUTH_LOAD_ZONE
         The DDNS response should be SUCCESS
-        And the SOA serial for example.org should be 1238
+        And the SOA serial for example.org should be 1239
 
         # Test 9
         When I send bind10 the command Auth shutdown
@@ -69,10 +69,10 @@ Feature: DDNS System
         And wait for new bind10 stderr message AUTH_SERVER_STARTED
 
         # Test 10
-        When I use DDNS to set the SOA serial to 1239
+        When I use DDNS to set the SOA serial to 1240
         And wait for new bind10 stderr message AUTH_LOAD_ZONE
         The DDNS response should be SUCCESS
-        And the SOA serial for example.org should be 1239
+        And the SOA serial for example.org should be 1240
 
         # Test 11
         When I configure BIND10 to stop running DDNS
@@ -81,10 +81,10 @@ Feature: DDNS System
         bind10 module DDNS should not be running
 
         # Test 12
-        When I use DDNS to set the SOA serial to 1240
+        When I use DDNS to set the SOA serial to 1241
         # should this be REFUSED again?
         The DDNS response should be NOTIMP
-        And the SOA serial for example.org should be 1239
+        And the SOA serial for example.org should be 1240
 
     Scenario: ACL
         Given I have bind10 running with configuration ddns/ddns.config