Merging upstream version 2.10.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-09 09:05:05 +01:00
parent aa5ead0b5b
commit ab9af27b84
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
56 changed files with 405 additions and 112 deletions

View file

@ -1,4 +1,4 @@
# Copyright 2019-2021 OARC, Inc.
# Copyright 2019-2022 OARC, Inc.
# Copyright 2017-2018 Akamai Technologies
# Copyright 2006-2016 Nominum, Inc.
# All rights reserved.

View file

@ -14,7 +14,7 @@
@SET_MAKE@
# Copyright 2019-2021 OARC, Inc.
# Copyright 2019-2022 OARC, Inc.
# Copyright 2017-2018 Akamai Technologies
# Copyright 2006-2016 Nominum, Inc.
# All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.
@ -33,7 +33,10 @@
#include <sys/stat.h>
#include <assert.h>
perf_datafile_t* perf_datafile_open(const char* filename)
static perf_result_t read_one_blob(perf_datafile_t* dfile, perf_buffer_t* wire);
static perf_result_t read_one_line(perf_datafile_t* dfile, perf_buffer_t* lines);
perf_datafile_t* perf_datafile_open(const char* filename, perf_input_format_t format)
{
perf_datafile_t* dfile;
struct stat buf;
@ -63,6 +66,18 @@ perf_datafile_t* perf_datafile_open(const char* filename)
dfile->size = buf.st_size;
}
}
dfile->format = format;
switch (format) {
case input_format_text_query:
case input_format_text_update:
dfile->readfunc = read_one_line;
break;
case input_format_tcp_wire_format:
dfile->readfunc = read_one_blob;
break;
default:
perf_log_fatal("invalid datafile format");
};
return dfile;
}
@ -129,13 +144,15 @@ static perf_result_t read_more(perf_datafile_t* dfile)
dfile->at = 0;
}
/* leave space for \0 string termination at the end */
n = read(dfile->fd, &dfile->databuf[dfile->have], sizeof(dfile->databuf) - dfile->have - 1);
if (n < 0) {
return (PERF_R_FAILURE);
} else if (n == 0) {
return (PERF_R_EOF);
}
dfile->have += n;
dfile->databuf[dfile->have] = 0;
if (dfile->is_file && dfile->have == dfile->size) {
dfile->cached = true;
@ -144,6 +161,61 @@ static perf_result_t read_more(perf_datafile_t* dfile)
return (PERF_R_SUCCESS);
}
/* Binary format: (<uint16_t> for blob length, <bytes>), repeat
* Outputs single packet _without_ the length preambule. */
static perf_result_t read_one_blob(perf_datafile_t* dfile, perf_buffer_t* wire)
{
perf_result_t result;
uint16_t packet_size; /* 2-byte preambule like in the TCP stream */
while (true) {
if ((dfile->have - dfile->at) < sizeof(packet_size)) {
/* we don't have complete preambule yet */
if (dfile->cached) {
if ((dfile->have - dfile->at) == 0) {
return PERF_R_EOF;
} else {
return PERF_R_INVALIDFILE;
}
}
result = read_more(dfile);
if (result != PERF_R_SUCCESS) {
if (result == PERF_R_EOF && (dfile->have - dfile->at) != 0) {
/* incomplete preambule at the end of file */
result = PERF_R_INVALIDFILE;
}
return (result);
}
continue;
}
memcpy(&packet_size, &dfile->databuf[dfile->at], sizeof(uint16_t));
packet_size = ntohs(packet_size);
break;
}
while (true) {
if (sizeof(packet_size) + packet_size > (dfile->have - dfile->at)) {
if (dfile->cached) {
return PERF_R_INVALIDFILE;
}
result = read_more(dfile);
if (result != PERF_R_SUCCESS) {
if (result == PERF_R_EOF) {
/* incomplete blob at the end of file */
result = PERF_R_INVALIDFILE;
}
return (result);
}
continue;
}
break;
}
perf_buffer_putmem(wire, ((unsigned char*)&dfile->databuf[dfile->at]) + sizeof(packet_size), packet_size);
dfile->at += sizeof(packet_size) + packet_size;
return (PERF_R_SUCCESS);
}
/* String in output buffer is not \0 terminated, check length in dfile->have */
static perf_result_t read_one_line(perf_datafile_t* dfile, perf_buffer_t* lines)
{
const char* cur;
@ -163,11 +235,12 @@ static perf_result_t read_one_line(perf_datafile_t* dfile, perf_buffer_t* lines)
if (curlen == nrem) {
if (!dfile->cached) {
result = read_more(dfile);
/* line terminator for text input */
dfile->databuf[dfile->have] = 0;
if (result != PERF_R_SUCCESS)
return (result);
}
if (dfile->have - dfile->at == 0) {
dfile->nruns++;
return (PERF_R_EOF);
}
if (dfile->have - dfile->at > nrem)
@ -176,7 +249,7 @@ static perf_result_t read_one_line(perf_datafile_t* dfile, perf_buffer_t* lines)
/* We now have a line. Advance the buffer past it. */
dfile->at += curlen;
if (dfile->have - dfile->at > 0) {
if (dfile->at < dfile->have) {
dfile->at += 1;
}
@ -194,7 +267,7 @@ static perf_result_t read_one_line(perf_datafile_t* dfile, perf_buffer_t* lines)
return (PERF_R_SUCCESS);
}
perf_result_t perf_datafile_next(perf_datafile_t* dfile, perf_buffer_t* lines, bool is_update)
perf_result_t perf_datafile_next(perf_datafile_t* dfile, perf_buffer_t* lines)
{
const char* current;
perf_result_t result;
@ -206,15 +279,16 @@ perf_result_t perf_datafile_next(perf_datafile_t* dfile, perf_buffer_t* lines, b
goto done;
}
result = read_one_line(dfile, lines);
result = dfile->readfunc(dfile, lines);
if (result == PERF_R_EOF) {
if (!dfile->read_any) {
result = PERF_R_INVALIDFILE;
goto done;
}
dfile->nruns++;
if (dfile->maxruns != dfile->nruns) {
reopen_file(dfile);
result = read_one_line(dfile, lines);
result = dfile->readfunc(dfile, lines);
}
}
if (result != PERF_R_SUCCESS) {
@ -222,12 +296,15 @@ perf_result_t perf_datafile_next(perf_datafile_t* dfile, perf_buffer_t* lines, b
}
dfile->read_any = true;
if (is_update) {
if (dfile->format == input_format_text_update) {
while (true) {
current = perf_buffer_used(lines);
result = read_one_line(dfile, lines);
if (result == PERF_R_EOF && dfile->maxruns != dfile->nruns) {
reopen_file(dfile);
result = dfile->readfunc(dfile, lines);
if (result == PERF_R_EOF) {
dfile->nruns++;
if (dfile->maxruns != dfile->nruns) {
reopen_file(dfile);
}
}
if (result != PERF_R_SUCCESS || strcasecmp(current, "send") == 0)
break;

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.
@ -25,27 +25,38 @@
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
typedef struct perf_datafile {
typedef enum {
input_format_text_query,
input_format_text_update,
input_format_tcp_wire_format
} perf_input_format_t;
typedef struct perf_datafile perf_datafile_t;
struct perf_datafile {
pthread_mutex_t lock;
int pipe_fd;
int fd;
bool is_file;
size_t size, at, have;
bool cached;
char databuf[(64 * 1024) + 1];
char databuf[(64 * 1024) + sizeof(uint16_t)]; /* pad for null-terminated string or TCP wire length */
unsigned int maxruns;
unsigned int nruns;
bool read_any;
} perf_datafile_t;
perf_datafile_t* perf_datafile_open(const char* filename);
perf_input_format_t format;
perf_result_t (*readfunc)(perf_datafile_t* dfile, perf_buffer_t* lines);
};
perf_datafile_t* perf_datafile_open(const char* filename, perf_input_format_t format);
void perf_datafile_close(perf_datafile_t** dfilep);
void perf_datafile_setmaxruns(perf_datafile_t* dfile, unsigned int maxruns);
void perf_datafile_setpipefd(perf_datafile_t* dfile, int pipe_fd);
perf_result_t perf_datafile_next(perf_datafile_t* dfile, perf_buffer_t* lines, bool is_update);
perf_result_t perf_datafile_next(perf_datafile_t* dfile, perf_buffer_t* lines);
unsigned int perf_datafile_nruns(const perf_datafile_t* dfile);

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,4 +1,4 @@
.\" Copyright 2019-2021 OARC, Inc.
.\" Copyright 2019-2022 OARC, Inc.
.\" Copyright 2017-2018 Akamai Technologies
.\" Copyright 2006-2016 Nominum, Inc.
.\" All rights reserved.
@ -22,6 +22,7 @@ dnsperf \- test the performance of a DNS server
.ad l
\fBdnsperf\fR\ [\fB\-a\ \fIlocal_addr\fR]
[\fB\-b\ \fIbufsize\fR]
[\fB\-B\fR]
[\fB\-c\ \fIclients\fR]
[\fB\-d\ \fIdatafile\fR]
[\fB\-D\fR]
@ -192,6 +193,42 @@ Sets the size of the socket's send and receive buffers, in kilobytes.
If not specified, the operating system's default is used.
.RE
\fB-B\fR
.br
.RS
Instructs \fBdnsperf\fR to read datafile in TCP-stream binary format
as specified by RFC 1035 section "4.2.2. TCP usage".
Each packet is preceded by 2-byte preambule which specifies length of
the following DNS packet in network byte order, immediatelly followed
by raw bytes of the packet.
First two bytes of any packet should contain message ID and are
overwritten by \fBdnsperf\fR on the fly. All other bytes are left
intact.
Packets shorter than two bytes are sent intact.
Packets in datafile can contain arbitrary bytes and are not checked for
validity.
Malformed packets probably will not be responded to by servers and will
cause timeouts.
This option is mutually exclusive with \fB-D\fR, \fB-e\fR, \fB-E\fR,
\fB-u\fR and \fB-y\fR.
These binary datafiles can be generated using arbitrary TCP listeners such
as \fBnetcat\fR (nc) and \fBsockat\fR.
TCP must be used so that the length is prepended.
Following example shows how to generate a datafile with two query and
then using it, you need two terminals.
.EX
(terminal 1) $ nc -l 127.0.0.1 5300 > dns.blob
(terminal 2) $ echo "example.com A" | dnsperf -s 127.0.0.1 -p 5300 -m tcp
...wait for dnsperf to finish...
(terminal 1) $ nc -l 127.0.0.1 5300 >> dns.blob
(terminal 2) $ echo "example.com AAAA" | dnsperf -s 127.0.0.1 -p 5300 -m tcp
...wait for dnsperf to finish...
(terminal 1) $ dnsperf -B -d dns.blob -s $IP
.EE
.RE
\fB-c \fIclients\fR
.br
.RS
@ -212,12 +249,14 @@ If not specified, \fBdnsperf\fR will read from standard input.
.RS
Sets the DO (DNSSEC OK) bit [RFC3225] in all packets sent.
This also enables EDNS0, which is required for DNSSEC.
This option is mutually exclusive with \fB-B\fR.
.RE
\fB-e\fR
.br
.RS
Enables EDNS0 [RFC2671], by adding an OPT record to all packets sent.
This option is mutually exclusive with \fB-B\fR.
.RE
\fB-E \fIcode:value\fR
@ -226,6 +265,7 @@ Enables EDNS0 [RFC2671], by adding an OPT record to all packets sent.
Add an EDNS [RFC2671] option to all packets sent, using the specified
numeric option code and value expressed as a a hex-encoded string.
This also enables EDNS0.
This option is mutually exclusive with \fB-B\fR.
.RE
\fB-f \fIfamily\fR
@ -331,6 +371,7 @@ Instructs \fBdnsperf\fR to send DNS dynamic update messages, rather than
queries.
The format of the input file is different in this case; see the
"Constructing a dynamic update input file" section for more details.
This option is mutually exclusive with \fB-B\fR.
.RE
\fB-v\fR
@ -373,6 +414,7 @@ key algorithm, name and secret, where the algorithm defaults to hmac-md5 and
the secret is expressed as a base-64 encoded string.
Available algorithms are: hmac-md5, hmac-sha1, hmac-sha224, hmac-sha256,
hmac-sha384 and hmac-sha512.
This option is mutually exclusive with \fB-B\fR.
.RE
\fB-O \fIoption=value\fR

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.
@ -67,29 +67,31 @@
#define RECV_BATCH_SIZE 16
typedef struct {
int argc;
char** argv;
int family;
uint32_t clients;
uint32_t threads;
uint32_t maxruns;
uint64_t timelimit;
perf_sockaddr_t server_addr;
perf_sockaddr_t local_addr;
uint64_t timeout;
uint32_t bufsize;
bool edns;
bool dnssec;
perf_tsigkey_t* tsigkey;
perf_ednsoption_t* edns_option;
uint32_t max_outstanding;
uint32_t max_qps;
uint64_t stats_interval;
bool updates;
bool verbose;
enum perf_net_mode mode;
perf_suppress_t suppress;
size_t num_queries_per_conn;
int argc;
char** argv;
int family;
uint32_t clients;
uint32_t threads;
uint32_t maxruns;
uint64_t timelimit;
perf_sockaddr_t server_addr;
perf_sockaddr_t local_addr;
uint64_t timeout;
uint32_t bufsize;
bool edns;
bool dnssec;
perf_tsigkey_t* tsigkey;
perf_ednsoption_t* edns_option;
uint32_t max_outstanding;
uint32_t max_qps;
uint64_t stats_interval;
bool updates;
bool binary_input;
perf_input_format_t input_format;
bool verbose;
enum perf_net_mode mode;
perf_suppress_t suppress;
size_t num_queries_per_conn;
} config_t;
typedef struct {
@ -483,6 +485,9 @@ setup(int argc, char** argv, config_t* config)
perf_opt_add('u', perf_opt_boolean, NULL,
"send dynamic updates instead of queries",
NULL, &config->updates);
perf_opt_add('B', perf_opt_boolean, NULL,
"read input file as TCP-stream binary format",
NULL, &config->binary_input);
perf_opt_add('v', perf_opt_boolean, NULL,
"verbose: report each query and additional information to stdout",
NULL, &config->verbose);
@ -538,7 +543,19 @@ setup(int argc, char** argv, config_t* config)
perf_net_parselocal(config->server_addr.sa.sa.sa_family,
local_name, local_port, &config->local_addr);
input = perf_datafile_open(filename);
if (config->binary_input
&& (config->edns || config->edns_option || config->dnssec
|| config->tsigkey || config->updates)) {
fprintf(stderr, "-B is mutually exclusive with -D, -e, -E, -u, -y\n");
exit(1);
}
if (config->updates)
config->input_format = input_format_text_update;
else if (config->binary_input)
config->input_format = input_format_tcp_wire_format;
else
config->input_format = input_format_text_query;
input = perf_datafile_open(filename, config->input_format);
if (config->maxruns == 0 && config->timelimit == 0)
config->maxruns = 1;
@ -736,20 +753,35 @@ do_send(void* arg)
PERF_UNLOCK(&tinfo->lock);
perf_buffer_clear(&lines);
result = perf_datafile_next(input, &lines, config->updates);
result = perf_datafile_next(input, &lines);
if (result != PERF_R_SUCCESS) {
if (result == PERF_R_INVALIDFILE)
perf_log_fatal("input file contains no data");
break;
}
qid = q - tinfo->queries;
perf_buffer_usedregion(&lines, &used);
perf_buffer_clear(&msg);
result = perf_dns_buildrequest(&used, qid,
config->edns, config->dnssec, config->updates,
config->tsigkey, config->edns_option,
&msg);
perf_buffer_t* send = &msg;
qid = q - tinfo->queries;
switch (config->input_format) {
case input_format_text_query:
case input_format_text_update:
perf_buffer_clear(&msg);
perf_buffer_usedregion(&lines, &used);
result = perf_dns_buildrequest(&used, qid,
config->edns, config->dnssec, config->input_format == input_format_text_update,
config->tsigkey, config->edns_option,
&msg);
break;
case input_format_tcp_wire_format:
send = &lines;
if (perf_buffer_usedlength(send) > 1) {
((uint8_t*)perf_buffer_base(send))[0] = qid >> 8;
((uint8_t*)perf_buffer_base(send))[1] = qid;
}
result = PERF_R_SUCCESS;
break;
}
if (result != PERF_R_SUCCESS) {
PERF_LOCK(&tinfo->lock);
query_move(tinfo, q, prepend_unused);
@ -758,13 +790,17 @@ do_send(void* arg)
continue;
}
base = perf_buffer_base(&msg);
length = perf_buffer_usedlength(&msg);
base = perf_buffer_base(send);
length = perf_buffer_usedlength(send);
now = perf_get_time();
if (config->verbose) {
free(q->desc);
q->desc = strdup(lines.base);
if (config->input_format == input_format_tcp_wire_format) {
q->desc = strdup("binary input");
} else {
q->desc = strdup(lines.base);
}
if (q->desc == NULL)
perf_log_fatal("out of memory");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2019-2021 OARC, Inc.
# Copyright 2019-2022 OARC, Inc.
# Copyright 2017-2018 Akamai Technologies
# Copyright 2006-2016 Nominum, Inc.
# All rights reserved.

View file

@ -1,4 +1,4 @@
.\" Copyright 2019-2021 OARC, Inc.
.\" Copyright 2019-2022 OARC, Inc.
.\" Copyright 2017-2018 Akamai Technologies
.\" Copyright 2006-2016 Nominum, Inc.
.\" All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.
@ -401,7 +401,7 @@ static void setup(int argc, char** argv)
perf_net_parselocal(server_addr.sa.sa.sa_family, local_name,
local_port, &local_addr);
input = perf_datafile_open(filename);
input = perf_datafile_open(filename, input_format_text_query);
if (reopen_datafile) {
perf_datafile_setmaxruns(input, -1);
}
@ -635,7 +635,7 @@ do_one_line(perf_buffer_t* lines, perf_buffer_t* msg)
}
perf_buffer_clear(lines);
result = perf_datafile_next(input, lines, false);
result = perf_datafile_next(input, lines);
if (result != PERF_R_SUCCESS)
perf_log_fatal("ran out of query data");
perf_buffer_usedregion(lines, &used);

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,9 +1,15 @@
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
CLEANFILES = test*.log test*.trs \
test2.out test4.out test4err.out key.pem cert.pem test6.out
test2.out test4.out test4err.out key.pem cert.pem test6.out \
10queries.tmp.blob 10queries.tmp.out empty.out emptypayload.out \
largesttcp.out largestudp.out missingpayload.out querywithcookie.out \
shortpayload.out tooshortlength.out twoquerieswithnsid.out
TESTS = test1.sh test2.sh test3.sh test4.sh test5.sh test6.sh
TESTS = test1.sh test2.sh test3.sh test4.sh test5.sh test6.sh test7.sh
EXTRA_DIST = $(TESTS) \
datafile datafile2 updatefile datafile3 datafile4 datafile5 datafile6
datafile datafile2 updatefile datafile3 datafile4 datafile5 datafile6 \
empty.blob emptypayload.blob largesttcp.blob largestudp.blob \
missingpayload.blob querywithcookie.blob shortpayload.blob \
tooshortlength.blob twoquerieswithnsid.blob

View file

@ -465,11 +465,17 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
CLEANFILES = test*.log test*.trs \
test2.out test4.out test4err.out key.pem cert.pem test6.out
test2.out test4.out test4err.out key.pem cert.pem test6.out \
10queries.tmp.blob 10queries.tmp.out empty.out emptypayload.out \
largesttcp.out largestudp.out missingpayload.out querywithcookie.out \
shortpayload.out tooshortlength.out twoquerieswithnsid.out
TESTS = test1.sh test2.sh test3.sh test4.sh test5.sh test6.sh
TESTS = test1.sh test2.sh test3.sh test4.sh test5.sh test6.sh test7.sh
EXTRA_DIST = $(TESTS) \
datafile datafile2 updatefile datafile3 datafile4 datafile5 datafile6
datafile datafile2 updatefile datafile3 datafile4 datafile5 datafile6 \
empty.blob emptypayload.blob largesttcp.blob largestudp.blob \
missingpayload.blob querywithcookie.blob shortpayload.blob \
tooshortlength.blob twoquerieswithnsid.blob
all: all-am
@ -701,6 +707,13 @@ test6.sh.log: test6.sh
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
test7.sh.log: test7.sh
@p='test7.sh'; \
b='test7.sh'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
.test.log:
@p='$<'; \
$(am__set_b); \

0
src/test/empty.blob Normal file
View file

BIN
src/test/emptypayload.blob Normal file

Binary file not shown.

1
src/test/largesttcp.blob Normal file

File diff suppressed because one or more lines are too long

1
src/test/largestudp.blob Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

BIN
src/test/shortpayload.blob Normal file

Binary file not shown.

83
src/test/test7.sh Executable file
View file

@ -0,0 +1,83 @@
#!/bin/sh -xe
# expect non-zero exit code
malformed_input_fmt() {
FILESTEM="$1"
! ../dnsperf -vvv -B -d "$srcdir/$FILESTEM.blob" > "$FILESTEM.out" 2>&1
grep -F "Error: input file contains no data" "$FILESTEM.out"
}
malformed_input_fmt "empty"
malformed_input_fmt "tooshortlength"
malformed_input_fmt "missingpayload"
test "$TEST_DNSPERF_WITH_NETWORK" = "1" || exit 0
check_sent_and_lost() {
FILESTEM="$1"
EXPECTEDCOUNT="$2"
grep "Queries sent: $EXPECTEDCOUNT$" "$FILESTEM.out"
grep -F "Queries lost: $EXPECTEDCOUNT (" "$FILESTEM.out"
}
# send to an address which does not reply anyway;
# typically for weird blobs which do not even have DNS header - so we cannot expect a response
blackhole() {
FILESTEM="$1"
EXTRAARGS="$2"
EXPECTEDCOUNT="$3"
../dnsperf -t 0.001 -vvv -B -d "$srcdir/$FILESTEM.blob" -s 192.0.2.1 $EXTRAARGS > "$FILESTEM.out" 2>&1
check_sent_and_lost "$FILESTEM" "$EXPECTEDCOUNT"
}
blackhole2() {
FILESTEM="$1"
EXTRAARGS="$2"
EXPECTEDCOUNT="$3"
../dnsperf -t 0.001 -vvv -B -d "$FILESTEM.blob" -s 192.0.2.1 $EXTRAARGS > "$FILESTEM.out" 2>&1
check_sent_and_lost "$FILESTEM" "$EXPECTEDCOUNT"
}
blackhole "emptypayload" "" 1
blackhole "shortpayload" "" 1
blackhole "largestudp" "" 1
# too large for UDP; at least it should not crash
blackhole "largesttcp" "" 0
grep -F 'failed to send packet' largesttcp.out
# valid DNS queries as blobs
expect_noerror() {
FILESTEM="$1"
EXTRAARGS="$2"
EXPECTEDCOUNT="$3"
../dnsperf -vvv -B -d "$srcdir/$FILESTEM.blob" -s 1.1.1.1 $EXTRAARGS > "$FILESTEM.out" 2>&1
grep "Queries sent: $EXPECTEDCOUNT$" "$FILESTEM.out"
grep -F "Queries completed: $EXPECTEDCOUNT (" "$FILESTEM.out"
}
# single plain run
expect_noerror "querywithcookie" "" 1
# loop over the binary twice
expect_noerror "querywithcookie" "-n 2" 2
# multiple queries in one file
expect_noerror "twoquerieswithnsid" "" 2
# file too big to cache
rm -f 10queries.tmp.blob
cat "$srcdir/twoquerieswithnsid.blob" "$srcdir/querywithcookie.blob" "$srcdir/emptypayload.blob" \
"$srcdir/largestudp.blob" "$srcdir/twoquerieswithnsid.blob" "$srcdir/querywithcookie.blob" \
"$srcdir/emptypayload.blob" "$srcdir/largestudp.blob" \
> 10queries.tmp.blob
blackhole2 "10queries.tmp" "" 10
# repeat non-cacheable file the same twice
blackhole2 "10queries.tmp" "-n 2" 20
# large binary on stdin should work too
cat 10queries.tmp.blob | ../dnsperf -t 0.001 -vvv -B -s 192.0.2.1 > "stdinlarge.out" 2>&1
check_sent_and_lost "stdinlarge" 10
# small binary on stdin
cat "$srcdir/twoquerieswithnsid.blob" | ../dnsperf -t 0.001 -vvv -B -s 192.0.2.1 > "stdinsmall.out" 2>&1
check_sent_and_lost "stdinsmall" 2

Binary file not shown.

Binary file not shown.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 OARC, Inc.
* Copyright 2019-2022 OARC, Inc.
* Copyright 2017-2018 Akamai Technologies
* Copyright 2006-2016 Nominum, Inc.
* All rights reserved.