BIND 10 trac495, updated. 58d2f4eb90876382d8ed316f157c1f39d8d44cbf [trac495] half implementation for using NSAS
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Feb 4 13:36:31 UTC 2011
The branch, trac495 has been updated
via 58d2f4eb90876382d8ed316f157c1f39d8d44cbf (commit)
from 7399e386eff98bb73a21589aaea7f790c65888dc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 58d2f4eb90876382d8ed316f157c1f39d8d44cbf
Author: Jelte Jansen <jelte at isc.org>
Date: Fri Feb 4 14:35:16 2011 +0100
[trac495] half implementation for using NSAS
Most of it is actually commented out, and unused, since it will
completely fail (there's no cache yet, so even if this part was
'complete' it would devolve in a loop between nsas and resolver)
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/Makefile.am | 1 +
src/bin/auth/benchmarks/Makefile.am | 1 +
src/bin/auth/tests/Makefile.am | 1 +
src/bin/resolver/tests/Makefile.am | 1 +
src/lib/asiolink/Makefile.am | 1 +
src/lib/asiolink/asiolink.cc | 91 +++++++++++++++++++++++++--
src/lib/asiolink/internal/tests/Makefile.am | 1 +
7 files changed, 92 insertions(+), 5 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/Makefile.am b/src/bin/auth/Makefile.am
index 3b21abf..23e3118 100644
--- a/src/bin/auth/Makefile.am
+++ b/src/bin/auth/Makefile.am
@@ -52,6 +52,7 @@ b10_auth_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
b10_auth_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
b10_auth_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
b10_auth_LDADD += $(top_builddir)/src/lib/log/liblog.la
+b10_auth_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
b10_auth_LDADD += $(SQLITE_LIBS)
# TODO: config.h.in is wrong because doesn't honor pkgdatadir
diff --git a/src/bin/auth/benchmarks/Makefile.am b/src/bin/auth/benchmarks/Makefile.am
index 05ab754..653d502 100644
--- a/src/bin/auth/benchmarks/Makefile.am
+++ b/src/bin/auth/benchmarks/Makefile.am
@@ -21,5 +21,6 @@ query_bench_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
query_bench_LDADD += $(top_builddir)/src/lib/cc/libcc.la
query_bench_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
query_bench_LDADD += $(top_builddir)/src/lib/log/liblog.la
+query_bench_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
query_bench_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
query_bench_LDADD += $(SQLITE_LIBS)
diff --git a/src/bin/auth/tests/Makefile.am b/src/bin/auth/tests/Makefile.am
index a1114e4..def99b0 100644
--- a/src/bin/auth/tests/Makefile.am
+++ b/src/bin/auth/tests/Makefile.am
@@ -45,6 +45,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
run_unittests_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
+run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
endif
noinst_PROGRAMS = $(TESTS)
diff --git a/src/bin/resolver/tests/Makefile.am b/src/bin/resolver/tests/Makefile.am
index 8bebff0..80977c5 100644
--- a/src/bin/resolver/tests/Makefile.am
+++ b/src/bin/resolver/tests/Makefile.am
@@ -39,6 +39,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
run_unittests_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
+run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
# Note the ordering matters: -Wno-... must follow -Wextra (defined in
# B10_CXXFLAGS
diff --git a/src/lib/asiolink/Makefile.am b/src/lib/asiolink/Makefile.am
index 99b3c66..dc0d31e 100644
--- a/src/lib/asiolink/Makefile.am
+++ b/src/lib/asiolink/Makefile.am
@@ -33,3 +33,4 @@ endif
libasiolink_la_CPPFLAGS = $(AM_CPPFLAGS)
libasiolink_la_LIBADD = $(top_builddir)/src/lib/log/liblog.la
libasiolink_la_LIBADD += $(top_builddir)/src/lib/resolve/libresolve.la
+libasiolink_la_LIBADD += $(top_builddir)/src/lib/nsas/libnsas.la
diff --git a/src/lib/asiolink/asiolink.cc b/src/lib/asiolink/asiolink.cc
index 6349ed3..be79ea8 100644
--- a/src/lib/asiolink/asiolink.cc
+++ b/src/lib/asiolink/asiolink.cc
@@ -41,6 +41,9 @@
#include <log/dummylog.h>
+#include <nsas/address_request_callback.h>
+#include <nsas/nameserver_address.h>
+
using namespace asio;
using asio::ip::udp;
using asio::ip::tcp;
@@ -343,6 +346,26 @@ namespace {
* Used by RecursiveQuery::sendQuery.
*/
class RunningQuery : public UDPQuery::Callback {
+
+class ResolverNSASCallback : public isc::nsas::AddressRequestCallback {
+public:
+ ResolverNSASCallback(RunningQuery* rq) : rq_(rq) {}
+
+ void success(const isc::nsas::NameserverAddress& address) {
+ (void)address;
+ rq_->sendTo(address);
+ }
+
+ void unreachable() {
+ dlog("Nameservers unreachable");
+ // Drop query or send servfail?
+ rq_->stop(false);
+ }
+
+private:
+ RunningQuery* rq_;
+};
+
private:
// The io service to handle async calls
asio::io_service& io_;
@@ -389,12 +412,28 @@ private:
deadline_timer client_timer;
deadline_timer lookup_timer;
+ // the 'current' nameserver we have a query out to
+ std::string cur_zone_;
+ isc::nsas::NameserverAddressStore& nsas_;
+ boost::shared_ptr<ResolverNSASCallback> nsas_callback_;
+
+ isc::nsas::NameserverAddress current_ns_address;
+ time_t current_ns_qsent_time;
+
size_t queries_out_;
// If we timed out ourselves (lookup timeout), stop issuing queries
bool done_;
// (re)send the query to the server.
+ // TODO rename this to send() once cache is in
+ void newsend() {
+ // Ask the NSAS for an address for the current zone,
+ // the callback will call the actual sendTo()
+ nsas_.lookup(cur_zone_, RRClass::IN(), nsas_callback_);
+ }
+
+ // TODO: remove this once the nsas can actually return something
void send() {
const int uc = upstream_->size();
const int zs = zone_servers_.size();
@@ -448,6 +487,12 @@ private:
// for this very first mockup, hope there is an
// address in additional and just use that
+ // TODO: should update "cur_zone_" here with the target
+ // of the delegation, store the answer in the cache
+ // and then ask the nsas for the address of that zone
+
+ // once done, remove below code (and the upstream_root etc)
+
// send query to the addresses in the delegation
bool found_ns_address = false;
zone_servers_.clear();
@@ -489,7 +534,9 @@ private:
public:
- RunningQuery(asio::io_service& io, const Question &question,
+ RunningQuery(asio::io_service& io,
+ isc::nsas::NameserverAddressStore& nsas,
+ const Question &question,
MessagePtr answer_message, shared_ptr<AddressVector> upstream,
shared_ptr<AddressVector> upstream_root,
OutputBufferPtr buffer,
@@ -507,6 +554,10 @@ public:
retries_(retries),
client_timer(io),
lookup_timer(io),
+ cur_zone_("."),
+ nsas_(nsas),
+ nsas_callback_(boost::shared_ptr<ResolverNSASCallback>(
+ new ResolverNSASCallback(this))),
queries_out_(0),
done_(false)
{
@@ -548,6 +599,18 @@ public:
send();
}
+ void sendTo(const isc::nsas::NameserverAddress address) {
+ // We need to keep track of the Address, so we can update
+ // the rtt
+ // Get the current time.
+ time(¤t_ns_qsent_time);
+
+ UDPQuery query(io_, question_, current_ns_address.getAddress(),
+ 53, buffer_, this, query_timeout_);
+ ++queries_out_;
+ io_.post(query);
+ }
+
virtual void clientTimeout() {
// right now, just stop (should make SERVFAIL and send that
// back, but not stop)
@@ -584,8 +647,19 @@ public:
virtual void operator()(UDPQuery::Result result) {
// XXX is this the place for TCP retry?
--queries_out_;
+ // Get the current time.
+ time_t cur_time;
+ time(&cur_time);
+
if (!done_ && result != UDPQuery::TIME_OUT) {
// we got an answer
+
+ // update the nsas with the time
+ // TODO not actually using NSAS right now, as it has no way
+ // to get the data, uncomment this when it does)
+ //current_ns_address.updateRTT(
+ // static_cast<uint32_t>(cur_time - current_ns_qsent_time));
+
Message incoming(Message::PARSE);
InputBuffer ibuf(buffer_->getData(), buffer_->getLength());
incoming.fromWire(ibuf);
@@ -603,9 +677,16 @@ public:
}
} else if (!done_ && retries_--) {
// We timed out, but we have some retries, so send again
+ // what to set? MAX? 0?
+ // TODO not actually using NSAS right now, as it has no way
+ // to get the data, uncomment this when it does)
+ //current_ns_address.updateRTT(0);
dlog("Timeout, resending query");
send();
} else {
+ // TODO not actually using NSAS right now, as it has no way
+ // to get the data, uncomment this when it does)
+ //current_ns_address.updateRTT(0);
// out of retries, give up for now
stop(false);
}
@@ -624,7 +705,7 @@ RecursiveQuery::resolve(const isc::dns::QuestionPtr& question,
OutputBufferPtr buffer(new OutputBuffer(0));
// It will delete itself when it is done
- new RunningQuery(io, *question, answer_message, upstream_,
+ new RunningQuery(io, nsas_, *question, answer_message, upstream_,
upstream_root_, buffer, callback, query_timeout_,
client_timeout_, lookup_timeout_, retries_);
}
@@ -645,9 +726,9 @@ RecursiveQuery::resolve(const Question& question,
new isc::resolve::ResolverCallbackServer(server));
// It will delete itself when it is done
- new RunningQuery(io, question, answer_message, upstream_, upstream_root_,
- buffer, crs, query_timeout_, client_timeout_,
- lookup_timeout_, retries_);
+ new RunningQuery(io, nsas_, question, answer_message, upstream_,
+ upstream_root_, buffer, crs, query_timeout_,
+ client_timeout_, lookup_timeout_, retries_);
}
class IntervalTimerImpl {
diff --git a/src/lib/asiolink/internal/tests/Makefile.am b/src/lib/asiolink/internal/tests/Makefile.am
index 449cab7..01ab21e 100644
--- a/src/lib/asiolink/internal/tests/Makefile.am
+++ b/src/lib/asiolink/internal/tests/Makefile.am
@@ -21,6 +21,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
+run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
# Note: the ordering matters: -Wno-... must follow -Wextra (defined in
# B10_CXXFLAGS)
run_unittests_CXXFLAGS = $(AM_CXXFLAGS)
More information about the bind10-changes
mailing list