2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

3655. [cleanup] Simplify TCP message processing when requesting a

zone transfer.  [RT #34825]
This commit is contained in:
Mark Andrews
2013-09-25 09:57:34 +10:00
parent 5116f25421
commit fb623f9a07
3 changed files with 23 additions and 51 deletions

View File

@@ -1,3 +1,6 @@
3655. [cleanup] Simplify TCP message processing when requesting a
zone transfer. [RT #34825]
3654. [bug] Address race condition with manual notify requests.
[RT #34806]

View File

@@ -14,13 +14,14 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
TOP=$( (cd ../../.. && pwd) )
SYSTEMTESTTOP=..
. ../conf.sh
addr=127.127.0.0
ttl=300
named=${TOP}/bin/named/named
keygen=${TOP}/bin/dnssec/dnssec-keygen
dsfromkey=${TOP}/bin/dnssec/dnssec-dsfromkey
named=${NAMED}
keygen=${KEYGEN}
dsfromkey=${DSFROMKEY}
nextaddr() {
OLDIF="$IFS"

View File

@@ -221,7 +221,6 @@ static isc_result_t xfrin_start(dns_xfrin_ctx_t *xfr);
static void xfrin_connect_done(isc_task_t *task, isc_event_t *event);
static isc_result_t xfrin_send_request(dns_xfrin_ctx_t *xfr);
static void xfrin_send_done(isc_task_t *task, isc_event_t *event);
static void xfrin_sendlen_done(isc_task_t *task, isc_event_t *event);
static void xfrin_recv_done(isc_task_t *task, isc_event_t *event);
static void xfrin_timeout(isc_task_t *task, isc_event_t *event);
@@ -881,8 +880,11 @@ xfrin_create(isc_mem_t *mctx,
xfr->sourceaddr = *sourceaddr;
isc_sockaddr_setport(&xfr->sourceaddr, 0);
isc_buffer_init(&xfr->qbuffer, xfr->qbuffer_data,
sizeof(xfr->qbuffer_data));
/*
* Reserve 2 bytes for TCP length at the begining of the buffer.
*/
isc_buffer_init(&xfr->qbuffer, &xfr->qbuffer_data[2],
sizeof(xfr->qbuffer_data) - 2);
xfr->magic = XFRIN_MAGIC;
*xfrp = xfr;
@@ -1065,10 +1067,8 @@ static isc_result_t
xfrin_send_request(dns_xfrin_ctx_t *xfr) {
isc_result_t result;
isc_region_t region;
isc_region_t lregion;
dns_rdataset_t *qrdataset = NULL;
dns_message_t *msg = NULL;
unsigned char length[2];
dns_difftuple_t *soatuple = NULL;
dns_name_t *qname = NULL;
dns_dbversion_t *ver = NULL;
@@ -1137,12 +1137,16 @@ xfrin_send_request(dns_xfrin_ctx_t *xfr) {
isc_buffer_usedregion(&xfr->qbuffer, &region);
INSIST(region.length <= 65535);
length[0] = region.length >> 8;
length[1] = region.length & 0xFF;
lregion.base = length;
lregion.length = 2;
CHECK(isc_socket_send(xfr->socket, &lregion, xfr->task,
xfrin_sendlen_done, xfr));
/*
* Record message length and adjust region to include TCP
* length field.
*/
xfr->qbuffer_data[0] = (region.length >> 8) & 0xff;
xfr->qbuffer_data[1] = region.length & 0xff;
region.base -= 2;
region.length += 2;
CHECK(isc_socket_send(xfr->socket, &region, xfr->task,
xfrin_send_done, xfr));
xfr->sends++;
failure:
@@ -1159,42 +1163,6 @@ xfrin_send_request(dns_xfrin_ctx_t *xfr) {
return (result);
}
/* XXX there should be library support for sending DNS TCP messages */
static void
xfrin_sendlen_done(isc_task_t *task, isc_event_t *event) {
isc_socketevent_t *sev = (isc_socketevent_t *) event;
dns_xfrin_ctx_t *xfr = (dns_xfrin_ctx_t *) event->ev_arg;
isc_result_t evresult = sev->result;
isc_result_t result;
isc_region_t region;
REQUIRE(VALID_XFRIN(xfr));
UNUSED(task);
INSIST(event->ev_type == ISC_SOCKEVENT_SENDDONE);
isc_event_free(&event);
xfr->sends--;
if (xfr->shuttingdown) {
maybe_free(xfr);
return;
}
xfrin_log(xfr, ISC_LOG_DEBUG(3), "sent request length prefix");
CHECK(evresult);
isc_buffer_usedregion(&xfr->qbuffer, &region);
CHECK(isc_socket_send(xfr->socket, &region, xfr->task,
xfrin_send_done, xfr));
xfr->sends++;
failure:
if (result != ISC_R_SUCCESS)
xfrin_fail(xfr, result, "failed sending request length prefix");
}
static void
xfrin_send_done(isc_task_t *task, isc_event_t *event) {
isc_socketevent_t *sev = (isc_socketevent_t *) event;