REQUIRE(client->sendhandle == handle);
CTRACE("senddone");
+
+ /*
+ * Set sendhandle to NULL, but don't detach it immediately, in
+ * case we need to retry the send. If we do resend, then
+ * sendhandle will be reattached. Whether or not we resend,
+ * we will then detach the handle from *this* send by detaching
+ * 'handle' directly below.
+ */
+ client->sendhandle = NULL;
+
if (result != ISC_R_SUCCESS) {
- ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
- NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
- "send failed: %s", isc_result_totext(result));
+ if (!TCP_CLIENT(client) && result == ISC_R_MAXSIZE) {
+ ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
+ NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
+ "send exceeded maximum size: truncating");
+ client->query.attributes &= ~NS_QUERYATTR_ANSWERED;
+ client->rcode_override = dns_rcode_noerror;
+ ns_client_error(client, ISC_R_MAXSIZE);
+ } else {
+ ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
+ NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
+ "send failed: %s",
+ isc_result_totext(result));
+ }
}
- isc_nmhandle_detach(&client->sendhandle);
+ isc_nmhandle_detach(&handle);
}
static void
void
ns_client_error(ns_client_t *client, isc_result_t result) {
+ dns_message_t *message = NULL;
dns_rcode_t rcode;
- dns_message_t *message;
+ bool trunc = false;
REQUIRE(NS_CLIENT_VALID(client));
rcode = (dns_rcode_t)(client->rcode_override & 0xfff);
}
+ if (result == ISC_R_MAXSIZE) {
+ trunc = true;
+ }
+
#if NS_CLIENT_DROPPORT
/*
* Don't send FORMERR to ports on the drop port list.
return;
}
}
+
message->rcode = rcode;
+ if (trunc) {
+ message->flags |= DNS_MESSAGEFLAG_TC;
+ }
if (rcode == dns_rcode_formerr) {
/*