[svn] commit: r1630 - in /trunk: ./ src/bin/ src/bin/auth/ src/bin/bind10/ src/bin/xfrout/ src/lib/ src/lib/python/isc/auth/ src/lib/xfr/
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Mar 23 08:41:24 UTC 2010
Author: zhanglikun
Date: Tue Mar 23 08:41:24 2010
New Revision: 1630
Log:
Commit code for module xfrout, AXFR-out works now. Notes:
1. When auth server get axfr query in tcp, the query message and tcp socket will be sent to xfrout process over sendmsg/recvmsg, then auth server will close the tcp socket, or get the next tcp query on the socket. Xfrout send the query response over the tcp socket it received from auth server.
2. Since python3.1 didn't provide the wrapper of sendmsg() and recvmsg() for C socket module(Seems they plan do it in python3.2), I have to write the code in c++, and make python binding for it. See the code in file /src/lib/xfr/fd_share.cc and /src/lib/xfr/python_xfr.cc.
Added:
trunk/src/bin/xfrout/
trunk/src/bin/xfrout/Makefile.am
trunk/src/bin/xfrout/run_b10-xfrout.sh.in
trunk/src/bin/xfrout/xfrout.pre.in
trunk/src/bin/xfrout/xfrout.py.in
trunk/src/lib/xfr/
trunk/src/lib/xfr/Makefile.am
trunk/src/lib/xfr/fd_share.cc
trunk/src/lib/xfr/fd_share.h
trunk/src/lib/xfr/python_xfr.cc
trunk/src/lib/xfr/xfrout_client.cc
trunk/src/lib/xfr/xfrout_client.h
Modified:
trunk/configure.ac
trunk/src/bin/Makefile.am
trunk/src/bin/auth/Makefile.am
trunk/src/bin/auth/main.cc
trunk/src/bin/bind10/bind10.py.in
trunk/src/lib/Makefile.am
trunk/src/lib/python/isc/auth/sqlite3_ds.py
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Tue Mar 23 08:41:24 2010
@@ -361,6 +361,7 @@
src/bin/auth/Makefile
src/bin/auth/tests/Makefile
src/bin/xfrin/Makefile
+ src/bin/xfrout/Makefile
src/bin/usermgr/Makefile
src/lib/Makefile
src/lib/cc/Makefile
@@ -376,6 +377,7 @@
src/lib/exceptions/Makefile
src/lib/auth/Makefile
src/lib/auth/tests/Makefile
+ src/lib/xfr/Makefile
])
AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
src/bin/cmdctl/cmdctl.py
@@ -385,6 +387,9 @@
src/bin/xfrin/xfrin.py
src/bin/xfrin/xfrin.pre
src/bin/xfrin/run_b10-xfrin.sh
+ src/bin/xfrout/xfrout.py
+ src/bin/xfrout/xfrout.pre
+ src/bin/xfrout/run_b10-xfrout.sh
src/bin/bind10/bind10.py
src/bin/bind10/tests/bind10_test
src/bin/bind10/run_bind10.sh
@@ -408,6 +413,7 @@
], [
chmod +x src/bin/cmdctl/run_b10-cmdctl.sh
chmod +x src/bin/xfrin/run_b10-xfrin.sh
+ chmod +x src/bin/xfrout/run_b10-xfrout.sh
chmod +x src/bin/bind10/run_bind10.sh
chmod +x src/bin/cmdctl/unittest/cmdctl_test
chmod +x src/bin/xfrin/unittest/xfrin_test
Modified: trunk/src/bin/Makefile.am
==============================================================================
--- trunk/src/bin/Makefile.am (original)
+++ trunk/src/bin/Makefile.am Tue Mar 23 08:41:24 2010
@@ -1,1 +1,1 @@
-SUBDIRS = bind10 bindctl cfgmgr loadzone msgq host cmdctl auth xfrin usermgr
+SUBDIRS = bind10 bindctl cfgmgr loadzone msgq host cmdctl auth xfrin xfrout usermgr
Modified: trunk/src/bin/auth/Makefile.am
==============================================================================
--- trunk/src/bin/auth/Makefile.am (original)
+++ trunk/src/bin/auth/Makefile.am Tue Mar 23 08:41:24 2010
@@ -33,6 +33,7 @@
b10_auth_LDADD += $(top_builddir)/src/lib/cc/libcc.a
b10_auth_LDADD += $(top_builddir)/src/lib/exceptions/.libs/libexceptions.a
b10_auth_LDADD += $(SQLITE_LIBS)
+b10_auth_LDADD += $(top_builddir)/src/lib/xfr/.libs/libxfr.a
if HAVE_BOOST_SYSTEM
b10_auth_LDFLAGS = $(AM_LDFLAGS) $(BOOST_LDFLAGS)
b10_auth_LDADD += $(BOOST_SYSTEM_LIB)
Modified: trunk/src/bin/auth/main.cc
==============================================================================
--- trunk/src/bin/auth/main.cc (original)
+++ trunk/src/bin/auth/main.cc Tue Mar 23 08:41:24 2010
@@ -42,12 +42,14 @@
#include <cc/session.h>
#include <cc/data.h>
#include <config/ccsession.h>
+#include <xfr/xfrout_client.h>
#include "spec_config.h"
#include "common.h"
#include "auth_srv.h"
using namespace std;
+using namespace isc::xfr;
#ifdef HAVE_BOOST_SYSTEM
using namespace boost::asio;
@@ -103,7 +105,38 @@
return answer;
}
-#ifdef HAVE_BOOST_SYSTEM
+//TODO. The sample way for checking axfr query, the code should be merged to auth server class
+static bool
+check_axfr_query(char *msg_data, uint16_t msg_len)
+{
+ if (msg_len < 15)
+ return false;
+
+ uint16_t query_type = *(uint16_t *)(msg_data + (msg_len - 4));
+ if ( query_type == 0xFC00)
+ return true;
+
+ return false;
+}
+
+//TODO. Send the xfr query to xfrout module, the code should be merged to auth server class
+static void
+dispatch_axfr_query(int tcp_sock, char axfr_query[], uint16_t query_len)
+{
+ std::string path = "/tmp/auth_xfrout_conn";
+ XfroutClient xfr_client(path);
+ try {
+ xfr_client.connect();
+ xfr_client.sendXfroutRequestInfo(tcp_sock, (uint8_t *)axfr_query, query_len);
+ xfr_client.disconnect();
+ }
+ catch (const std::exception & err) {
+ //if (verbose_mode)
+ cerr << "error handle xfr query:" << err.what() << endl;
+ }
+}
+
+#ifdef HAVE_BOOSTLIB
//
// Helper classes for asynchronous I/O using boost::asio
//
@@ -148,17 +181,24 @@
{
if (!error) {
InputBuffer dnsbuffer(data_, bytes_transferred);
- if (auth_server->processMessage(dnsbuffer, dns_message_,
- response_renderer_, false)) {
- responselen_buffer_.writeUint16(response_buffer_.getLength());
- async_write(socket_,
- boost::asio::buffer(
- responselen_buffer_.getData(),
- responselen_buffer_.getLength()),
- boost::bind(&TCPClient::responseWrite, this,
- placeholders::error));
- } else {
- delete this;
+ if (check_axfr_query(data_, bytes_transferred)) {
+ dispatch_axfr_query(socket_.native(), data_, bytes_transferred);
+ // start to get new query ?
+ start();
+ }
+ else {
+ if (auth_server->processMessage(dnsbuffer, dns_message_,
+ response_renderer_, false)) {
+ responselen_buffer_.writeUint16(response_buffer_.getLength());
+ async_write(socket_,
+ boost::asio::buffer(
+ responselen_buffer_.getData(),
+ responselen_buffer_.getLength()),
+ boost::bind(&TCPClient::responseWrite, this,
+ placeholders::error));
+ } else {
+ delete this;
+ }
}
} else {
delete this;
@@ -537,25 +577,30 @@
cc += cc0;
}
- InputBuffer buffer(&message_buffer[0], size);
- dns_message.clear(Message::PARSE);
- response_renderer.clear();
- if (auth_server->processMessage(buffer, dns_message, response_renderer,
- false)) {
- size = response_renderer.getLength();
- size_n = htons(size);
- if (send(ts, &size_n, 2, 0) == 2) {
- cc = send(ts, response_renderer.getData(),
- response_renderer.getLength(), 0);
- if (cc == -1) {
- if (verbose_mode) {
- cerr << "[AuthSrv] error in sending TCP response message" <<
- endl;
- }
- } else {
- if (verbose_mode) {
- cerr << "[XX] sent TCP response: " << cc << " bytes"
- << endl;
+ if (check_axfr_query(&message_buffer[0], size)) {
+ dispatch_axfr_query(ts, &message_buffer[0], size);
+ }
+ else {
+ InputBuffer buffer(&message_buffer[0], size);
+ dns_message.clear(Message::PARSE);
+ response_renderer.clear();
+ if (auth_server->processMessage(buffer, dns_message, response_renderer,
+ false)) {
+ size = response_renderer.getLength();
+ size_n = htons(size);
+ if (send(ts, &size_n, 2, 0) == 2) {
+ cc = send(ts, response_renderer.getData(),
+ response_renderer.getLength(), 0);
+ if (cc == -1) {
+ if (verbose_mode) {
+ cerr << "[AuthSrv] error in sending TCP response message" <<
+ endl;
+ }
+ } else {
+ if (verbose_mode) {
+ cerr << "[XX] sent TCP response: " << cc << " bytes"
+ << endl;
+ }
}
}
} else {
Modified: trunk/src/bin/bind10/bind10.py.in
==============================================================================
--- trunk/src/bin/bind10/bind10.py.in (original)
+++ trunk/src/bin/bind10/bind10.py.in Tue Mar 23 08:41:24 2010
@@ -265,6 +265,21 @@
if self.verbose:
print("[XX] ccsession started")
+ # start the xfrout before auth-server, to make sure every xfr-query can be
+ # processed properly.
+ if self.verbose:
+ sys.stdout.write("Starting b10-xfrout\n")
+ try:
+ xfrout = ProcessInfo("b10-xfrout", ["b10-xfrout"],
+ { 'ISC_MSGQ_PORT': str(self.c_channel_port)})
+ except Exception as e:
+ c_channel.process.kill()
+ bind_cfgd.process.kill()
+ return "Unable to start b10-xfrout; " + str(e)
+ self.processes[xfrout.pid] = xfrout
+ if self.verbose:
+ sys.stdout.write("Started b10-xfrout (PID %d)\n" % xfrout.pid)
+
# start b10-auth
# XXX: this must be read from the configuration manager in the future
authargs = ['b10-auth', '-p', str(self.auth_port)]
@@ -278,6 +293,7 @@
except Exception as e:
c_channel.process.kill()
bind_cfgd.process.kill()
+ xfrout.process.kill()
return "Unable to start b10-auth; " + str(e)
self.processes[auth.pid] = auth
if self.verbose:
@@ -292,6 +308,7 @@
except Exception as e:
c_channel.process.kill()
bind_cfgd.process.kill()
+ xfrout.process.kill()
auth.process.kill()
return "Unable to start b10-xfrin; " + str(e)
self.processes[xfrind.pid] = xfrind
@@ -308,6 +325,7 @@
except Exception as e:
c_channel.process.kill()
bind_cfgd.process.kill()
+ xfrout.process.kill()
auth.process.kill()
xfrind.process.kill()
return "Unable to start b10-cmdctl; " + str(e)
Modified: trunk/src/lib/Makefile.am
==============================================================================
--- trunk/src/lib/Makefile.am (original)
+++ trunk/src/lib/Makefile.am Tue Mar 23 08:41:24 2010
@@ -1,1 +1,1 @@
-SUBDIRS = exceptions dns cc config auth python
+SUBDIRS = exceptions dns cc config auth xfr python
Modified: trunk/src/lib/python/isc/auth/sqlite3_ds.py
==============================================================================
--- trunk/src/lib/python/isc/auth/sqlite3_ds.py (original)
+++ trunk/src/lib/python/isc/auth/sqlite3_ds.py Tue Mar 23 08:41:24 2010
@@ -84,6 +84,40 @@
return conn, cur
+
+#########################################################################
+# get_zone_datas
+# returns all the records for one zone with the given zone name.
+#########################################################################
+def get_zone_datas(zonename, dbfile):
+ conn, cur = open(dbfile)
+ zone_id = get_zoneid(zonename, cur)
+
+ cur.execute("SELECT * FROM records WHERE zone_id = ?", [zone_id])
+ record = cur.fetchone()
+ while record:
+ yield record
+ record = cur.fetchone()
+
+ cur.close()
+ conn.close()
+
+
+#########################################################################
+# get_zone_soa
+# returns the soa record of the zone with the given zone name.
+# If the zone doesn't exist, return None.
+#########################################################################
+def get_zone_soa(zonename, dbfile):
+ conn, cur = open(dbfile)
+ id = get_zoneid(zonename, cur)
+ cur.execute("SELECT * FROM records WHERE zone_id = ? and rdtype = ?", [id, 'SOA'])
+ datas = cur.fetchone()
+ cur.close()
+ conn.close()
+
+ return datas
+
#########################################################################
# get_zoneid:
# returns the zone_id for a given zone name, or an empty
More information about the bind10-changes
mailing list