Compare commits

...

5 Commits

Author SHA1 Message Date
Witold Kręcicki
69ef3b5509 Add NS_CLIENT_MOCKREPLY - if defined, BIND will reply with empty
answers to each query, without doing any processing. This can
be used to test network stack performance.
2018-11-26 05:42:38 -05:00
Michał Kępień
bf519a3574 Merge branch '732-fix-compilation-on-centos-6-i386' into 'master'
Fix compilation on CentOS 6 (i386)

Closes #732

See merge request isc-projects/bind9!1129
2018-11-26 05:22:36 -05:00
Michał Kępień
62ca7743ae Fix compilation on CentOS 6 (i386)
The stock toolchain available on CentOS 6 for i386 is unable to use the
_mm_pause() intrinsic.  Fix by using "rep; nop" assembly instructions on
that platform instead.
2018-11-26 10:57:14 +01:00
Ondřej Surý
7e4ed9f8ad Merge branch '674-fix-windows-build' into 'master'
Fix typo __LINE -> __LINE__ in lib/isc/win32/condition.c

See merge request isc-projects/bind9!1132
2018-11-23 18:54:26 -05:00
Ondřej Surý
e24afa3088 Fix typo __LINE -> __LINE__ 2018-11-24 00:53:24 +01:00
3 changed files with 69 additions and 2 deletions

View File

@@ -44,9 +44,11 @@
#if defined(_MSC_VER)
# include <intrin.h>
# define isc_rwlock_pause() YieldProcessor()
#elif defined(__x86_64__) || defined(__i386__)
#elif defined(__x86_64__)
# include <immintrin.h>
# define isc_rwlock_pause() _mm_pause()
#elif defined(__i386__)
# define isc_rwlock_pause() __asm__ __volatile__ ("rep; nop")
#elif defined(__ia64__)
# define isc_rwlock_pause() __asm__ __volatile__ ("hint @pause")
#elif defined(__arm__)

View File

@@ -40,7 +40,7 @@ isc_condition_init(isc_condition_t *cond) {
char strbuf[ISC_STRERRORSIZE];
DWORD err = GetLastError();
strerror_r(err, strbuf, sizeof(strbuf));
isc_error_fatal(__FILE__, __LINE,
isc_error_fatal(__FILE__, __LINE__,
"CreateEvent failed: %s", strbuf);
}
cond->events[LSIGNAL] = h;

View File

@@ -1049,6 +1049,51 @@ ns_client_sendraw(ns_client_t *client, dns_message_t *message) {
ns_client_next(client, result);
}
#ifdef NS_CLIENT_MOCKREPLY
static isc_result_t
client_mockreply(ns_client_t *client, uint16_t id) {
isc_result_t result;
unsigned char *data;
isc_buffer_t buffer;
isc_buffer_t tcpbuffer;
isc_region_t r;
unsigned char sendbuf[SEND_BUFFER_SIZE];
result = client_allocsendbuf(client, &buffer, &tcpbuffer, 0,
sendbuf, &data);
if (result != ISC_R_SUCCESS) {
goto done;
}
isc_buffer_putuint16(&buffer, id);
isc_buffer_putuint8(&buffer, 0x81);
isc_buffer_putuint8(&buffer, 0x80);
isc_buffer_putuint16(&buffer, 0);
isc_buffer_putuint16(&buffer, 0);
isc_buffer_putuint16(&buffer, 0);
isc_buffer_putuint16(&buffer, 0);
if (client->sendcb != NULL) {
client->sendcb(&buffer);
} else if (TCP_CLIENT(client)) {
isc_buffer_usedregion(&buffer, &r);
isc_buffer_putuint16(&tcpbuffer, (uint16_t) r.length);
isc_buffer_add(&tcpbuffer, r.length);
result = client_sendpkg(client, &tcpbuffer);
} else {
result = client_sendpkg(client, &buffer);
}
if (result == ISC_R_SUCCESS) {
return (ISC_R_SUCCESS);
}
done:
if (client->tcpbuf != NULL) {
isc_mem_put(client->mctx, client->tcpbuf, TCP_BUFFER_SIZE);
client->tcpbuf = NULL;
}
ns_client_next(client, result);
return (ISC_R_SUCCESS);
}
#endif
static void
client_send(ns_client_t *client) {
isc_result_t result;
@@ -2335,6 +2380,26 @@ ns__client_request(isc_task_t *task, isc_event_t *event) {
return;
}
#ifdef NS_CLIENT_MOCKREPLY
result = dns_message_peekheader(buffer, &id, &flags);
if (result != ISC_R_SUCCESS) {
/*
* There isn't enough header to determine whether
* this was a request or a response. Drop it.
*/
ns_client_next(client, result);
return;
}
/*
* client_mockreply always return success, but we want to
* make the return conditional to fool compilers that the
* code below is reachable.
*/
if (client_mockreply(client, id) == ISC_R_SUCCESS) {
return;
}
#endif
isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr);
#if NS_CLIENT_DROPPORT