From: JINMEI Tatuya Date: Sat, 19 May 2012 01:13:29 +0000 (-0700) Subject: [1539] log socket forward failure X-Git-Tag: trac2351_base~226^2~85^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=58be95ac3fcb9f498a4dc1d02a2e693068c97039;p=thirdparty%2Fkea.git [1539] log socket forward failure --- diff --git a/src/bin/auth/auth_messages.mes b/src/bin/auth/auth_messages.mes index b18feb13e6..86553216c6 100644 --- a/src/bin/auth/auth_messages.mes +++ b/src/bin/auth/auth_messages.mes @@ -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. diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc index 2a1d2054b4..5e41bfcbf2 100644 --- a/src/bin/auth/auth_srv.cc +++ b/src/bin/auth/auth_srv.cc @@ -14,17 +14,6 @@ #include -#include -#include - -#include -#include -#include -#include -#include - -#include - #include #include @@ -66,6 +55,18 @@ #include #include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + 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: []:port or :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(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); } diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc index 8c38412e72..48756ac08a 100644 --- a/src/bin/auth/tests/auth_srv_unittest.cc +++ b/src/bin/auth/tests/auth_srv_unittest.cc @@ -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);