From b35a009df86b4aa3793e87602c95af2a503ec0ee Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 22 Jun 2000 00:05:11 +0000 Subject: [PATCH] 270. [func] Allow maximum sized TCP answers. --- CHANGES | 2 ++ bin/named/client.c | 29 ++++++++++++++++++++++++----- bin/named/include/named/client.h | 1 + 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index ea7277c1f5..8eb04fe0f5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ + 270. [func] Allow maximum sized TCP answers. + 269. [bug] Failed DNSSEC validations could cause an assertion failure by causing clone_results() to be called with with hevent->node == NULL. diff --git a/bin/named/client.c b/bin/named/client.c index 3fe931571e..4b6dd57318 100644 --- a/bin/named/client.c +++ b/bin/named/client.c @@ -72,7 +72,9 @@ #define TCP_CLIENT(c) (((c)->attributes & NS_CLIENTATTR_TCP) != 0) +#define TCP_BUFFER_SIZE (65535 + 2) #define SEND_BUFFER_SIZE 2048 +#define RECV_BUFFER_SIZE 2048 struct ns_clientmgr { /* Unlocked. */ @@ -223,6 +225,8 @@ client_free(ns_client_t *client) { isc_mem_put(client->mctx, client->sendbuf, SEND_BUFFER_SIZE); isc_timer_detach(&client->timer); + if (client->sendbuf != NULL) + isc_mem_put(client->mctx, client->sendbuf, TCP_BUFFER_SIZE); if (client->opt != NULL) { INSIST(dns_rdataset_isassociated(client->opt)); dns_rdataset_disassociate(client->opt); @@ -571,6 +575,11 @@ client_senddone(isc_task_t *task, isc_event_t *event) { INSIST(client->nsends > 0); client->nsends--; + + if (client->tcpbuf != NULL) { + isc_mem_put(client->mctx, client->tcpbuf, TCP_BUFFER_SIZE); + client->tcpbuf = NULL; + } isc_event_free(&event); @@ -599,7 +608,6 @@ ns_client_send(ns_client_t *client) { if ((client->attributes & NS_CLIENTATTR_RA) != 0) client->message->flags |= DNS_MESSAGEFLAG_RA; - data = client->sendbuf; /* * XXXRTH The following doesn't deal with TSIGs, TCP buffer resizing, * or ENDS1 more data packets. @@ -608,9 +616,14 @@ ns_client_send(ns_client_t *client) { /* * XXXRTH "tcpbuffer" is a hack to get things working. */ - isc_buffer_init(&tcpbuffer, data, SEND_BUFFER_SIZE); - isc_buffer_init(&buffer, data + 2, SEND_BUFFER_SIZE - 2); + client->tcpbuf = isc_mem_get(client->mctx, TCP_BUFFER_SIZE); + if (client->tcpbuf == NULL) + goto done; + data = client->tcpbuf; + isc_buffer_init(&tcpbuffer, data, TCP_BUFFER_SIZE); + isc_buffer_init(&buffer, data + 2, TCP_BUFFER_SIZE - 2); } else { + data = client->sendbuf; if (client->udpsize < SEND_BUFFER_SIZE) bufsize = client->udpsize; else @@ -623,7 +636,7 @@ ns_client_send(ns_client_t *client) { goto done; if (client->opt != NULL) { result = dns_message_setopt(client->message, client->opt); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) goto done; /* * XXXRTH dns_message_setopt() should probably do this... @@ -683,7 +696,12 @@ ns_client_send(ns_client_t *client) { client->nsends++; return; } + done: + if (client->tcpbuf != NULL) { + isc_mem_put(client->mctx, client->tcpbuf, TCP_BUFFER_SIZE); + client->tcpbuf = NULL; + } ns_client_next(client, result); } @@ -755,7 +773,7 @@ client_addopt(ns_client_t *client) { /* * Set Maximum UDP buffer size. */ - rdatalist->rdclass = SEND_BUFFER_SIZE; + rdatalist->rdclass = RECV_BUFFER_SIZE; /* * Set EXTENDED-RCODE, VERSION, and Z to 0. @@ -1155,6 +1173,7 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp) client->tcplistener = NULL; client->tcpsocket = NULL; client->tcpmsg_valid = ISC_FALSE; + client->tcpbuf = NULL; client->opt = NULL; client->udpsize = 512; client->next = NULL; diff --git a/bin/named/include/named/client.h b/bin/named/include/named/client.h index 876c0a913a..69ba6b3706 100644 --- a/bin/named/include/named/client.h +++ b/bin/named/include/named/client.h @@ -97,6 +97,7 @@ struct ns_client { dns_dispatchevent_t * dispevent; isc_socket_t * tcplistener; isc_socket_t * tcpsocket; + unsigned char * tcpbuf; dns_tcpmsg_t tcpmsg; isc_boolean_t tcpmsg_valid; isc_timer_t * timer;