]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1539] log socket forward failure
authorJINMEI Tatuya <jinmei@isc.org>
Sat, 19 May 2012 01:13:29 +0000 (18:13 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Sat, 19 May 2012 01:13:29 +0000 (18:13 -0700)
src/bin/auth/auth_messages.mes
src/bin/auth/auth_srv.cc
src/bin/auth/tests/auth_srv_unittest.cc

index b18feb13e64beb8b6481ca755cd7f634d6c880cf..86553216c62fb7a39c86880c062c2afac3b43c63 100644 (file)
@@ -277,3 +277,14 @@ This is a debug message output during the processing of a NOTIFY
 request. The zone manager component has been informed of the request,
 but has returned an error response (which is included in the message). The
 NOTIFY request will not be honored.
+
+% AUTH_UPDATE_FORWARD_ERROR failed to forward update request from %1: %2
+The authoritative server receives a dynamic update request, tried to
+forward it to a separate process (which is usually b10-ddns) to handle it,
+but it failed.  It could be configuration mismatch between b10-auth and
+b10-ddns, or it may because update requests are coming too fast and b10-ddns
+cannot keep up with the rate, or some system level failure.  In either case
+this means the BIND 10 system is not working as expected, so the administrator
+should look into the cause and address the issue.  The log message
+includes the client's address (and port), and the error message sent
+from the lower layer that detects the failure.
index 2a1d2054b4a759d4f1986978a5e50ad33522930a..5e41bfcbf26eb3ac0130160040a6651d59b603a5 100644 (file)
 
 #include <config.h>
 
-#include <sys/types.h>
-#include <netinet/in.h>
-
-#include <algorithm>
-#include <cassert>
-#include <iostream>
-#include <vector>
-#include <memory>
-
-#include <boost/bind.hpp>
-
 #include <util/io/socketsession.h>
 
 #include <asiolink/asiolink.h>
 #include <auth/statistics.h>
 #include <auth/auth_log.h>
 
+#include <boost/bind.hpp>
+#include <boost/lexical_cast.hpp>
+
+#include <algorithm>
+#include <cassert>
+#include <iostream>
+#include <vector>
+#include <memory>
+
+#include <sys/types.h>
+#include <netinet/in.h>
+
 using namespace std;
 
 using namespace isc;
@@ -171,6 +172,23 @@ private:
         }
     }
 };
+
+// A helper function to log an address/port in the form of IOEndpoint
+// in our preferred format: [<ipv6_addr>]:port or <ipv4_addr>:port
+string
+formatEndpoint(const IOEndpoint& ep) {
+    string addr_port;
+    if (ep.getFamily() == AF_INET6) {
+        addr_port = "[" + ep.getAddress().toText() + "]";
+    } else if (ep.getFamily() == AF_INET) {
+        addr_port = ep.getAddress().toText();
+    } else {
+        addr_port = "(unknown address)";
+    }
+    addr_port += ":" + boost::lexical_cast<string>(ep.getPort());
+
+    return (addr_port);
+}
 }
 
 class AuthSrvImpl {
@@ -827,10 +845,17 @@ AuthSrvImpl::processUpdate(const IOMessage& io_message,
         ddns_forwarder_.connect();
         ddns_forwarder_.push(io_message);
     } catch (const SocketSessionError& ex) {
+        // If either connect or push fails, the forwarder object should throw
+        // an exception.  We log the event, and propagate the exception to
+        // the caller, which will result in SERVFAIL.
+        LOG_ERROR(auth_logger, AUTH_UPDATE_FORWARD_ERROR).
+            arg(formatEndpoint(io_message.getRemoteEndpoint())).
+            arg(ex.what());
         ddns_forwarder_.close();
         throw;
     }
 
+    // On successful push, the request shouldn't be responded from b10-auth.
     return (false);
 }
 
index 8c38412e72fb6dcda71d6f6d8e514c7acd8179ce..48756ac08a0fb44d69a5cd80ca6b86d373a72e21 100644 (file)
@@ -1506,9 +1506,10 @@ TEST_F(AuthSrvTest, DDNSForwardPushFail) {
     EXPECT_TRUE(ddns_forwarder.isConnected());
 
     // make connect attempt fail.  It should result in SERVFAIL.  The
-    // connection should be closed.
+    // connection should be closed.  Use IPv6 address for varying log output.
     ddns_forwarder.disablePush();
-    createAndSendRequest(RRType::SOA(), Opcode::UPDATE());
+    createAndSendRequest(RRType::SOA(), Opcode::UPDATE(), Name("example.com"),
+                         RRClass::IN(), IPPROTO_UDP, "2001:db8::2");
     EXPECT_TRUE(dnsserv.hasAnswer());
     headerCheck(*parse_message, default_qid, Rcode::SERVFAIL(),
                 Opcode::UPDATE().getCode(), QR_FLAG, 0, 0, 0, 0);