diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/resperf.c | 17 | ||||
-rwxr-xr-x | src/test/test3.sh | 9 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/resperf.c b/src/resperf.c index a6d120c..f7038e9 100644 --- a/src/resperf.c +++ b/src/resperf.c @@ -103,6 +103,8 @@ static uint64_t query_timeout; static bool edns; static bool dnssec; +static perf_ednsoption_t* edns_option = 0; + static perf_datafile_t* input; /* The target traffic level at the end of the ramp-up */ @@ -229,7 +231,8 @@ setup(int argc, char** argv) int sock_family; unsigned int bufsize; unsigned int i; - const char* _mode = 0; + const char* _mode = 0; + const char* edns_option_str = NULL; sock_family = AF_UNSPEC; server_port = 0; @@ -270,6 +273,8 @@ setup(int argc, char** argv) &bufsize); perf_opt_add('e', perf_opt_boolean, NULL, "enable EDNS 0", NULL, &edns); + perf_opt_add('E', perf_opt_string, "code:value", + "send EDNS option", NULL, &edns_option_str); perf_opt_add('D', perf_opt_boolean, NULL, "set the DNSSEC OK bit (implies EDNS)", NULL, &dnssec); perf_opt_add('y', perf_opt_string, "[alg:]name:secret", @@ -350,12 +355,15 @@ setup(int argc, char** argv) perf_datafile_setmaxruns(input, -1); } - if (dnssec) + if (dnssec || edns_option_str) edns = true; if (tsigkey_str != NULL) tsigkey = perf_tsig_parsekey(tsigkey_str); + if (edns_option_str != NULL) + edns_option = perf_edns_parseoption(edns_option_str); + if (!(socks = calloc(nsocks, sizeof(*socks)))) { perf_log_fatal("out of memory"); } @@ -380,6 +388,9 @@ cleanup(void) (void)perf_net_close(socks[i]); close(dummypipe[0]); close(dummypipe[1]); + + if (edns_option) + perf_edns_destroyoption(&edns_option); } /* Find the ramp_bucket for queries sent at time "when" */ @@ -586,7 +597,7 @@ do_one_line(perf_buffer_t* lines, perf_buffer_t* msg) perf_buffer_clear(msg); result = perf_dns_buildrequest(&used, qid, edns, dnssec, false, - tsigkey, 0, + tsigkey, edns_option, msg); if (result != PERF_R_SUCCESS) return (result); diff --git a/src/test/test3.sh b/src/test/test3.sh index 006ea2e..58ebd12 100755 --- a/src/test/test3.sh +++ b/src/test/test3.sh @@ -37,6 +37,15 @@ echo "" | ../dnsperf -W -y test: | grep "unable to setup TSIG, secret empty" ../dnsperf -W -E a:aa | grep "invalid EDNS Option code 'a'" ../dnsperf -W -E 1:xx | grep "invalid EDNS Option hex value 'xx'" +! ../resperf -e -E invalid +! ../resperf -e -E 9999999:invalid +! ../resperf -e -E 123:invalid +! ../resperf -e -E 123:fa0 +../resperf -W -E a: | grep "invalid EDNS Option, value is empty" +../resperf -W -E a:a | grep "invalid EDNS Option, value must hex string (even number of characters)" +../resperf -W -E a:aa | grep "invalid EDNS Option code 'a'" +../resperf -W -E 1:xx | grep "invalid EDNS Option hex value 'xx'" + ! ../resperf -d does_not_exist ! ../resperf -r 0 -c 0 ! ../resperf -f invalid |