Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dns over quic support: bis #62

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
6f5b260
initial quicly addition
weyrick Mar 23, 2019
a491869
docs
weyrick Mar 23, 2019
129a31f
add openssl, picotls to build. move quic to trafgen.
weyrick Mar 23, 2019
af2f2dd
quic integration 1
weyrick Mar 23, 2019
7ee822e
quic integration 2
weyrick Mar 23, 2019
59a5230
quic integration 3
weyrick Mar 23, 2019
5c737c8
quic integration 4
weyrick Mar 23, 2019
2b6edfb
quic integration 5 - working
weyrick Mar 23, 2019
668896a
remove debug
weyrick Mar 23, 2019
060c1cd
build: ext deps as system includes
fcelda Mar 24, 2019
e97670a
quic: build picotls outside flame core
fcelda Mar 24, 2019
b2520ad
build: fix openssl linking
fcelda Mar 24, 2019
e8f2b55
fix headers
fcelda Mar 24, 2019
0eabfad
add missing header
fcelda Mar 24, 2019
987bb53
quic: must close stream after sending the query
fcelda Mar 24, 2019
c56ab60
make DoQ support optional, add docs for building it.
weyrick Mar 29, 2019
8896fec
remove namespace on memcpy
weyrick Mar 29, 2019
7896984
add quic build to CI
weyrick Apr 2, 2019
3cf867e
lower openssl to version req by quicly
weyrick Apr 2, 2019
f7055d0
travis fixes 1
weyrick Apr 2, 2019
40b5e80
travis fixes 2
weyrick Apr 2, 2019
e837a8f
travis fixes 3
weyrick Apr 2, 2019
d173a98
travis fixes 4
weyrick Apr 2, 2019
f502c9f
travis fixes 5
weyrick Apr 2, 2019
b806ddf
travis fixes 6
weyrick Apr 2, 2019
d332b7d
merge multi target
weyrick Apr 28, 2019
296d9d1
match quicly upstream change
weyrick Apr 29, 2019
e7977bb
calculate size of sockaddr
weyrick Apr 29, 2019
ff1e7a4
Merge branch 'master' into dns-over-quic
weyrick Jul 11, 2019
83f392b
Merge tag 'v0.11.0' into dns-over-quic
VanStratum Feb 9, 2021
578e50a
Uniformise handling of error messages for compile-time options
VanStratum Feb 22, 2021
7163c28
Fix compatibility with recent versions of quicly.
VanStratum Feb 23, 2021
0e8d098
Fix sefault.
VanStratum Feb 24, 2021
b6e487c
Correct call to quicly_receive.
VanStratum Feb 24, 2021
f9a21a5
Implement the bind_ip option in quic mode
VanStratum Mar 10, 2021
f904983
Add metrics update on receiving a quic reply.
VanStratum Mar 11, 2021
0429e30
Add alpn in quic connection open.
VanStratum Mar 17, 2021
b3a8083
First working implementation of doq.
VanStratum Apr 10, 2021
bd93b25
Use the stream id's to track the queries in DoQ mode.
VanStratum Apr 12, 2021
9857a7d
Implement tracking of response codes in DoQ
VanStratum Apr 13, 2021
67e8612
Check if the response is fully received in DoQ mode.
VanStratum Apr 14, 2021
66300e9
Gracefully close the QUIC connection.
VanStratum Apr 14, 2021
96b7e2d
Stop using the timeout timers in DoQ mode.
VanStratum Apr 14, 2021
88a2ace
Add checking of handles on closing.
VanStratum Apr 22, 2021
412047d
Add missing ifdef's for QUIC-specific things
VanStratum May 5, 2021
5f8962a
Correct call to send_pending in DoQ mode.
VanStratum May 5, 2021
4df5007
Remove duplicated code
VanStratum May 15, 2021
196f544
Switch quic to using one connection per batch
VanStratum May 17, 2021
a9341cc
Switch from NULL to nullptr
VanStratum May 17, 2021
aeea60a
Add timeout support to quic mode.
VanStratum May 18, 2021
192bb9d
Make the timeout work properly in DoQ mode.
VanStratum May 19, 2021
7da4c23
Fix segfault in DoQ mode.
VanStratum May 19, 2021
8b95f1d
Add missing ifdef's and clean up their use.
VanStratum May 19, 2021
a0e408f
Correct shutdown timers close.
VanStratum May 19, 2021
67ae8e4
Fix rate limiting in DoQ
VanStratum May 20, 2021
5c80848
Improve connection close and uniformize printing in DOQ mode.
VanStratum Jun 8, 2021
b5144a5
Move the doq-specific code in a separate class.
VanStratum Jun 15, 2021
85596e4
Fix quic error handling to be closer to rfc.
VanStratum Jun 15, 2021
3bf9ce6
Fix segfaults, aborts, and a double free.
VanStratum Jun 16, 2021
ff25b7f
Fix quic session close.
VanStratum Jun 16, 2021
d577e35
Fix buffer overflow when using ipv6.
VanStratum Jun 16, 2021
0367e4f
Fix memleak.
VanStratum Jun 17, 2021
b08b4b3
Fix the quic connection close.
VanStratum Jun 18, 2021
c1b2d18
Close the quic connection when receiving the last reply.
VanStratum Jun 18, 2021
1f114ea
Fix segfault and assert fail
VanStratum Jun 21, 2021
e19cf47
Completely isolate quicly references and includes in QUICSession
VanStratum Aug 26, 2021
cabf5df
Slight improvement of DoQ IPv6 handling.
VanStratum Aug 28, 2021
dfdb0ff
Switch the naming from quic to doq.
VanStratum Aug 28, 2021
06c1db2
Merge branch 'master' into dns-over-quic
VanStratum Aug 28, 2021
f0cba21
Simplify and bisect the session end timer.
VanStratum Aug 29, 2021
fcdb12a
Style harmonisation and obsolete comment removal.
VanStratum Aug 29, 2021
7a9b3c9
Update DoQ support to draft-ietf-dprive-dnsoquic-03.
VanStratum Aug 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ matrix:
- libssl-dev
- libgnutls28-dev
- libnghttp2-dev
- openssl
# - os: osx
# addons:
# homebrew:
Expand All @@ -26,8 +27,16 @@ matrix:
before_script:
- if [ "${TRAVIS_OS_NAME}" = linux ]; then sh ci/install-libuv.sh; fi
- if [ "${TRAVIS_OS_NAME}" = linux ]; then sh ci/install-ldns.sh; fi
- sh ci/install-quicly.sh

script:
- ln -s /tmp/quicly 3rd/
- mkdir build && cd build && cmake ..
- make all tests
- ./tests
- cd ..
- mkdir quic-build && cd quic-build
- if [ "${TRAVIS_OS_NAME}" = linux ]; then cmake -DQUIC_ENABLE=ON ..; fi
- if [ "${TRAVIS_OS_NAME}" = osx ]; then PKG_CONFIG_PATH=/usr/local/opt/openssl@1.1/lib/pkgconfig cmake -DQUIC_ENABLE=ON ..; fi
- make all tests
- ./tests
34 changes: 34 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ pkg_search_module(LIBLDNS REQUIRED libldns ldns)
pkg_check_modules(LIBUV REQUIRED libuv>=1.23)
pkg_check_modules(LIBGNUTLS REQUIRED gnutls>=3.3)

option(DOQ_ENABLE "Enable QUIC support" OFF)
if (DOQ_ENABLE)
pkg_check_modules(OPENSSL REQUIRED libcrypto>=1.0.2)
message(STATUS "QUIC support is enabled")
add_definitions(-DDOQ_ENABLE)
else()
message(STATUS "QUIC support is disabled")
endif()

option(DOH_ENABLE "Enable DNS over HTTPS (DoH) support" OFF)
option(USE_HTTP_PARSER "Use http_parse library instead of url_parse" OFF)
if (DOH_ENABLE)
Expand Down Expand Up @@ -178,6 +187,31 @@ if (DOH_ENABLE)
)
endif()

if (DOQ_ENABLE)
set(flamecore_src
${flamecore_src}
flame/quicsession.cpp
flame/quicsession.h
3rd/quicly/deps/picotls/lib/openssl.c
3rd/quicly/deps/picotls/lib/pembase64.c
3rd/quicly/deps/picotls/lib/picotls.c
)

set(flamecore_dirs
${flamecore_dirs}
PUBLIC ${OPENSSL_INCLUDE_DIRS}
PUBLIC "${CMAKE_SOURCE_DIR}/3rd/quicly/include"
PUBLIC "${CMAKE_SOURCE_DIR}/3rd/quicly/deps/picotls/include"
)

set(flamecore_libs
${flamecore_libs}
PRIVATE ${OPENSSL_LIBRARIES}
PRIVATE "-L ${CMAKE_SOURCE_DIR}/3rd/quicly/build/ -lquicly"
PUBLIC ${OPENSSL_LDFLAGS}
)
endif()

add_library(flamecore ${flamecore_src})

target_include_directories(flamecore ${flamecore_dirs})
Expand Down
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ A DNS performance and functional testing utility.
Overview
--------

Flamethrower is a small, fast, configurable tool for functional testing, benchmarking, and stress testing DNS servers and networks. It supports IPv4, IPv6, UDP, TCP, DoT, and DoH and has a modular system for generating queries used in the tests.
Flamethrower is a small, fast, configurable tool for functional testing, benchmarking, and stress testing DNS servers and networks. It supports IPv4, IPv6, UDP, TCP, DoT, DoH, and DoQ and has a modular system for generating queries used in the tests.

The support of DNS-over-QUIC is experimental, following the draft RFC https://datatracker.ietf.org/doc/draft-huitema-quic-dnsoquic/

Originally built as an alternative to [dnsperf](https://github.com/DNS-OARC/dnsperf), many of the command line options are compatible.

Expand Down Expand Up @@ -120,6 +122,10 @@ Optional dependencies:
* nlohmann-json >= 3.7.3
* cpp-httplib

Optional experimental DoQ support requires:
* quicly https://github.com/h2o/quicly
* openssl >= 1.0.2

Building
--------

Expand All @@ -139,6 +145,25 @@ cmake -DDOH_ENABLE=ON ..
make
```

To build with DoQ support, first checkout and build quicly:
```
git clone https://github.com/h2o/quicly.git
cd quicly
git submodule update --init --recursive
mkdir build; cd build
cmake ..
make
```
the name of the "build" directory used to build quicly is significant, as it's referenced in the flamethrower paths.
You then need to manually symlink quicly into the flamethrower 3rd party directory before enabling support in flamethrower and building:
```
cd flamethrower
ln -s <PATH-TO-QUICLY> 3rd/
mkdir build; cd build
cmake -DQUIC_ENABLE=ON ..
make
```

Building the docker image:
```
org="myorg"
Expand All @@ -155,4 +180,3 @@ Pull Requests and issues are welcome. See the [NS1 Contribution Guidelines](http
License
-------
This code is released under Apache License 2.0. You can find terms and conditions in the LICENSE file.

19 changes: 19 additions & 0 deletions ci/install-quicly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

GITREPO="https://github.com/h2o/quicly"

set -ex

cd /tmp
git clone "$GITREPO"
cd quicly

git submodule update --init --recursive
if [ "$TRAVIS_OS_NAME" = "osx" ];
then
export PKG_CONFIG_PATH=/usr/local/opt/openssl@1.1/lib/pkgconfig
fi
mkdir build && cd build
cmake ..
make

3 changes: 3 additions & 0 deletions flame/flame.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#cmakedefine QUIC_ENABLE
#cmakedefine FLAME_VERSION_NUM "@PROJECT_VERSION@"
#cmakedefine FLAME_VERSION "@FLAME_VERSION@"
25 changes: 19 additions & 6 deletions flame/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 NSONE, Inc
// Copyright 2017-2019 NSONE, Inc

#include <iostream>
#include <iterator>
Expand Down Expand Up @@ -62,9 +62,9 @@ static const char USAGE[] =
-r RECORD The base record to use as the DNS query for generators [default: test.com]
-T QTYPE The query type to use for generators [default: A]
-f FILE Read records from FILE, one per row, QNAME TYPE
-p PORT Which port to flame [defaults: 53, 443 for DoH, 853 for DoT]
-p PORT Which port to flame [defaults: 53, 443 for DoH, 853 for DoT, 853 for DoQ]
-F FAMILY Internet family (inet/inet6) [default: inet]
-P PROTOCOL Protocol to use (udp/tcp/dot/doh) [default: udp]
-P PROTOCOL Protocol to use (udp/tcp/dot/doh/doq) [default: udp]
-M HTTPMETHOD HTTP method to use (POST/GET) when DoH is used [default: GET]
-g GENERATOR Generate queries with the given generator [default: static]
-o FILE Metrics output file, JSON format
Expand Down Expand Up @@ -244,8 +244,17 @@ int main(int argc, char *argv[])
c_count = 30;
} else if (args["-P"].asString() == "udp") {
proto = Protocol::UDP;
} else {
std::cerr << "protocol must be 'udp', 'tcp', dot' or 'doh'" << std::endl;
}
else if (args["-P"].asString() == "doq") {
#ifdef DOQ_ENABLE
proto = Protocol::DOQ;
#else
std::cerr << "DNS over QUIC support is not enabled" << std::endl;
return 1;
#endif
}
else {
std::cerr << "protocol must be 'udp', 'tcp', 'dot', 'doh', 'doq'" << std::endl;
return 1;
}

Expand All @@ -256,7 +265,11 @@ int main(int argc, char *argv[])
else if (proto == Protocol::DOH)
args["-p"] = std::string("443");
#endif
else
#ifdef DOQ_ENABLE
else if (proto == Protocol::DOQ)
args["-p"] = std::string("853");
#endif
else
args["-p"] = std::string("53");
}

Expand Down
12 changes: 10 additions & 2 deletions flame/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ void MetricsMgr::flush_to_disk()
j["runtime_s"] = _runtime_s;
j["run_id"] = _run_id;
for (auto i : _response_codes) {
j["total_responses"][ldns_lookup_by_id(ldns_rcodes, i.first)->name] = i.second;
ldns_lookup_table* msg = ldns_lookup_by_id(ldns_rcodes, i.first);
if (msg)
j["total_responses"][msg->name] = i.second;
else
j["total_responses"]["Unknown rcode (" + std::to_string(i.second) + ")"] = i.second;
}
_metric_file << j << std::endl;
}
Expand Down Expand Up @@ -131,7 +135,11 @@ void MetricsMgr::display_final_text()
if (_response_codes.size()) {
std::cout << "responses :" << std::endl;
for (auto i : _response_codes) {
std::cout << " " << ldns_lookup_by_id(ldns_rcodes, i.first)->name << ": " << i.second << std::endl;
ldns_lookup_table* msg = ldns_lookup_by_id(ldns_rcodes, i.first);
if (msg)
std::cout << " " << msg->name << ": " << i.second << std::endl;
else
std::cout << " Unknown rcode (" << std::to_string(i.first) << "): " << i.second << std::endl;
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions flame/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,24 @@ QueryGenerator::QueryTpt QueryGenerator::next_tcp(const std::vector<uint16_t> &i
return std::make_tuple(std::move(buf), total_len);
}

QueryGenerator::QueryTpt QueryGenerator::next_tcp(uint16_t id)
{

WireTpt w = _wire_buffers[_reqs++ % _wire_buffers.size()];
size_t len{2 + w.second};

auto buf = std::make_unique<char[]>(len);
// write pkt len
uint16_t plen = htons(w.second);
memcpy(buf.get(), &plen, sizeof(plen));
// write wire
memcpy(buf.get() + 2, w.first, w.second);
// write id requested
uint16_t _id = ntohs(id);
memcpy(buf.get() + 2, &_id, sizeof(_id));
return std::make_tuple(std::move(buf), len);
}

QueryGenerator::QueryTpt QueryGenerator::next_udp(uint16_t id)
{

Expand Down Expand Up @@ -634,6 +652,11 @@ QueryGenerator::QueryTpt NumberNameQueryGenerator::next_tcp(const std::vector<ui
throw std::runtime_error("tcp unsupported");
}

QueryGenerator::QueryTpt NumberNameQueryGenerator::next_tcp(uint16_t id)
{
throw std::runtime_error("tcp unsupported");
}

QueryGenerator::QueryTpt NumberNameQueryGenerator::next_udp(uint16_t id)
{

Expand Down
2 changes: 2 additions & 0 deletions flame/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class QueryGenerator
#endif
virtual QueryTpt next_udp(uint16_t);
virtual QueryTpt next_tcp(const std::vector<uint16_t> &);
virtual QueryTpt next_tcp(uint16_t);
bool finished();

virtual const char *name() = 0;
Expand Down Expand Up @@ -254,6 +255,7 @@ class NumberNameQueryGenerator : public QueryGenerator
//QueryTpt next_base64url(uint16_t);
QueryTpt next_udp(uint16_t);
QueryTpt next_tcp(const std::vector<uint16_t> &);
QueryTpt next_tcp(uint16_t);

const char *name()
{
Expand Down
Loading