Adding support for large UDP responses#684
Conversation
evdns.c
Outdated
| base->global_max_nameserver_timeout = 3; | ||
| base->global_search_state = NULL; | ||
| base->global_randomize_case = 1; | ||
| base->global_max_record_len = 512; |
There was a problem hiding this comment.
could also use DEFAULT_MAX_PACKET_LENGTH here
|
@ploxiln I'm not that familiar with the PR process for libevent. Is there anything else needed here? |
|
I'm not a maintainer or anything like that. Just some more patience is needed - the maintainer will probably be around in a week or so, and will probably have some of his own questions and comments. |
|
Ah ok didn't realize you weren't a maintainer, I'll wait it out then. |
azat
left a comment
There was a problem hiding this comment.
Great stuff, here are some comments, can you take a look?
Also, can you please add some unit test for this? (that will help a lot)
P.S. I just briefly looked and didn't check the protocol, going to do this tomorrow
evdns.c
Outdated
| sizeof(tv)); | ||
| } | ||
| return 0; | ||
| } else if (str_matches_option(option, "max-record-len:")) { |
There was a problem hiding this comment.
should be enumerated in dns.h (and also feel free to wrap each available option on new line)
evdns.c
Outdated
| * | RDLEN | u_int16_t | length of all RDATA | | ||
| * | RDATA | octet stream | {attribute,value} pairs | | ||
| * +------------+--------------+------------------------------+ */ | ||
| if ( max_record_len > DEFAULT_MAX_PACKET_LENGTH ) { |
There was a problem hiding this comment.
this does not suite evdns.c coding style (and in few other places too)
|
Thanks for the comments! I tried to make all the changes you requested. I modified the docs to describe all the options, let me know if you want me to revert that. I also tried to add a unit test. Unfortunately I cannot get tests to pass on my local machine, existing test also fail. Is there something required to get it working? |
There are some time-related failures. I tried to run you test
Nope. |
Sorry, disinformation. But dns server do not need/have |
|
@azat I updated the pull request. I had been looking at the wrong place in the earlier version, instead of changing evdns_server_request_format_response I needed to change nameserver_read. I didn't move global_max_record_len to evdns_server_port since I don't think it's needed there anymore. If you want me to move it somewhere else I can. Sorry for mis-understanding the code in the previous commits, I am still unfamiliar with the internals. |
|
The dns regression tests seem to pass now |
|
I just looked over your changes, and I have some comments:
- Maybe it will be better to rename DEFAULT_MAX_PACKET_LENGTH to
RFC_MAX_PACKET_LENGTH?
- about dns_large_udp test -- it does not check "max-record-len"
actually, i.e. simply removing this line and tests passes, while it
shoudn't (since there is no requests whose len >
DEFAULT_MAX_PACKET_LENGTH)
- different style in you new code:
tt_assert(! evdns_base_set_option(dns, "max-record-len", "4096"));
tt_assert(!evdns_base_nameserver_ip_add(dns, buf));
- different style in your new code against existing code, this is
mostly c++ style comments (the one that starts with "//" in evdns.c)
putting labels with tabulations in some places, extra white spaces
- and don't forget to polish the history once you will finish with the
patch-set
|
|
Hi @azat. I tried to make all the suggested changes. Currently the unit test dns_large_udp is making sure that the request is not broken. With max-record-len set to > 512, it adds the extended dns record to the dns request. The unit test makes sure that the request does not break. Unfortunately I wasn't able to add a unit test where the response was larger than 512 bytes. This is because I couldn't find a public url that was larger than this. I ran into this issue because I was running a local dns resolver, unbound, that by default is configured to return UDP responses up to 4096 bytes. Unbound would resolve it through TCP, but return the response in UDP to libevent. |
|
Unfortunately I wasn't able to add a unit test where the response was larger than 512 bytes.
But you can create answer >512 bytes by your self, could you?
|
Yes I can, and I did this on my local box to verify that it worked. I setup a fake dns server to return a large response, but obviously this would only work on my local box. I could be missing something, but I don't how I would do that within a unit without drastically re-writing how the unit tests run. |
|
The project I was working that was using libevent ended up going in a different direction and we're no longer using libevent. Since I won't be actively working on libevent I don't think I would be able to actively support any changes, including this one. Feel free to re-use any of the code if someone else wants to try a different approach or can support it. |
|
Thanks for let me know and for you contribution! |
|
@seleznevae are you interesting in this? |
|
Looks interesting. I'll take a look. |
This adds support for DNS records larger than 512 bytes.
I ran into an issue where a domain was failing to resolve because their DNS record was larger than 512 bytes. It is enabled by setting the "max-record-len" option to greater than 512 bytes. By default nothing changes. I tested it with some common public DNS servers (google, cloudflare, Dyn) and they all seemed to work correctly.
Relevant RFC https://tools.ietf.org/html/rfc6891