summaryrefslogtreecommitdiff
path: root/sbin/unwind/unwind.h
AgeCommit message (Collapse)Author
2021-08-31Say autoconf not dhcpKlemens Nanni
Do not abuse "dhcp" to say "DHCP and SLAAC". unwind.conf(5) does so but unwindctl(8) does not; in fact, the latter already has `status autoconf' to Show nameservers learned from dhclient(8), dhcpleased(8) or slaacd(8). Adjust unwind's config manual and internal code accordingly; still accept the old keyword but do not document it. hostname.if(5) already advises for `inet[6] autoconf' instead of `dhcp' and other related daemons don't abuse the word "dhcp" like unwind does. Feedback sthen OK florian
2021-07-25We store a list of resolver strategies in order of their preference inFlorian Obser
the configuration struct. This is also an implicit list of enabled resolver strategies. We have also stored an explict lookup array of enabled strategies outside of the configuration to be able to quickly answer "is this strategy enabled" without traversing the preferences list. Move this table into the configuration so that we don't need to "repair" it on config reload. This fixes a bug where on startup the preferences list and enabled lookup table were not in sync. It didn't matter in practice since we do a config reload and then pass in DNSSEC trustanchors on startup. Both actions combined repaired things. OK benno
2021-02-27Path #defines are traditionally prefixed with _PATH.Florian Obser
Pointed out by deraadt
2021-01-27Determine available address families (and monitor when this changes)Florian Obser
to configure libunbound accordingly. This way it no longer tries to talk to IPv6 nameservers when only IPv4 is available and vice versa. input deraadt OK kn
2021-01-24Implement DNS64 synthesis.Florian Obser
When unwind(8) learns new autoconf resolvers (from dhcp or router advertisements) it checks if a DNS64 is present in this network location and tries to recover the IPv6 prefix used according to RFC7050. The learned autoconf resolvers are then prevented from upgrading to the validating state since DNS64 breaks DNSSEC. unwind(8) can now perform its own synthesis. If a query for a AAAA record results in no answer we re-send the query for A and if that leads to an answer we synthesize an AAAA answer using the learned prefixes. Testing & OK kn
2021-01-19No need for a global uw_process; unbreaks -fno-common.Florian Obser
Problem reported by mortimer
2021-01-12Implement listening on 53/TCPFlorian Obser
Since we are only serving localhost we could get away with doing serving over UDP only because we have a huge MTU on lo0, it's still not correct behavior. This also enables sending truncated answers with TC set if the answer does not fit into the edns announced udp size. Testing at least by matthieu, jca, otto, phessler OK phessler
2020-12-11The recent fix to handle large answers in unwind (errata #5 for 6.8)Florian Obser
has the downside to always copy the maximum IMSG size (about 16k) between the resolver and frontend process for DNS answers because we had to keep it as simple as possible. We can now rearange things in -current to be less wasteful. This copies only the usually small DNS answer. In the unusual case that a DNS answer is larger than the maximum IMSG size fragment the message and send multiple IMSGs.
2020-11-05Handle DNS answers that are larger than the maximum imsg size (aboutFlorian Obser
16k) by splitting them up. Previously unwind would send meta-data about the finished query from the resolver process to the frontend process and then silently fail to send the actual answer because it was too big for imsg. When receiving the meta-data for the next query the frontend process would then exit via fatal() because it was still expecting an answer. This likely fixes rare crashes observed by Leo Unglaub. Note that even with DNSSEC signatures, answers this big are very rare. OK tb, benno
2019-12-18Implement unwindctl status memory to show chache memory usage.Florian Obser
testing by otto & pamela as part of a larger diff
2019-12-08More compact two column format for first section of status display; useOtto Moerbeek
* to mark opportunistic DoT forwarders; ok florian
2019-12-08Turn opportunistic DoT into their own strategies.Florian Obser
This is beneficial since we prefer strategies according to their performance. Previously name servers were upgraded to opportunistic DoT if it was available even if the round trip times went through the roof and there was no way to got back to plain udp/53 DNS. To make up a bit of space in the unwindctl status output, name servers learned via DHCP or SLAAC are printed in a new subcommand. The status output will be further improved shortly. Input & OK otto
2019-12-04Use NI_MAXHOST like everywhere else instead of a wrong number.Florian Obser
2019-12-03Add one more debug level and enable very detailed libunbound loggingFlorian Obser
with this. Currently only available as a command line flag (-vvv). With this we now have two debug levels available in unwind proper, to be used shortly. looks good to otto
2019-12-02Add an "all" mode for status and a much more compact and readable histogramOtto Moerbeek
display; remove the why bogus status message; ok florian@
2019-12-01Allow forcing specific domains to be resolved by specific resolvers;Otto Moerbeek
Handles typical split-horzizon setups. ok florian@
2019-11-29While we learn how the "decaying" histogram works it's helpful to showFlorian Obser
it in unwindctl status output next to the all time histogram.
2019-11-28Track all elements of a forwarder configuration individually:Florian Obser
IP address, port and authentication name. This makes print_config less awkward and fixes a bug were an alternative port number was not printed.
2019-11-27Move resolver preference storage to a struct which makes it easier toFlorian Obser
reuse in the future. OK otto
2019-11-27Nuke http captive portal detection; something better is coming.Florian Obser
OK otto
2019-11-26Improve previouskn
Avoid an extra parameter and set NULL initialised conffile conditionally. From Matthew Martin <phy1729 at gmail dot com>, thanks!
2019-11-26Fail on nonexistent config file iff -c is givenkn
Default /etc/unwind.conf is optional and may be missing, but explicitly specified files should exist. OK florian
2019-11-25 Signal what happened, not what needs doing.Florian Obser
The frontend doesn't know.
2019-11-22Treat DNS proposals as replacement of previous proposals from the sameFlorian Obser
daemon and interface. An empty list is automatically a withdrawl. prodding deraadt@
2019-11-21 Track on which interface nameservers have been learned.Florian Obser
prodding deraadt@
2019-11-19Print learned forwarders in unwindctl.Florian Obser
Someone please make this pretty. Tested by deraadt as part of a larger diff.
2019-11-19Proposals from dhclient are sometimes replacements.Florian Obser
slaacd should be changed as well. Tested by deraadt as part of a larger diff.
2019-11-19Stop dhcp lease file parsing now that dhclient sends proposals.Florian Obser
Tested by deraadt as part of a larger diff.
2019-11-14With the stub resolver we have since some time we can resolve theFlorian Obser
captive portal host internaly via the resolver process. deraadt and me observed weird captive portal checking hangs inside of unwind if only 127.0.0.1 was listed as a nameserver in resolv.conf with the old code.
2019-11-14 Since resolve() switched to a callback mechanism all uw_resolver objectsFlorian Obser
pass through resolve() and either asr_resolve_done() or ub_resolve_done(). With that we can pull resolver_ref() and resolver_unref() into those functions to make the reference counting easier. Only check_resolver is special since it needs to refcount the to be checked resolver. But the resolver doing the actual work is automatically refcounted by resolve() and *_resolve_done(). One last piece of the puzzle is to track the uw_resolver object in cb_data so that the *_resolve_done() functions have access to it. This also allowes us to remove the ad-hoc passing of the resolver in query_imsg. Since the callback functions all need access to the resolver that did the work we pass it in as first argument. OK otto
2019-11-12 It is possible to cancel libunbound queries by tracking an id.Florian Obser
We are not using that feature so stop tracking the value.
2019-11-11Implement DNS proposals to learn nameservers from networkFlorian Obser
autoconfiguration daemons. Currently only slaacd is switched over so we need to keep the lease file parsing.
2019-11-09Mechanically change the forwarder SIMPLEQ to a TAILQ. Needed forFlorian Obser
future work to be able to easily delete elements while iterating. OK kn
2019-11-06Move control socket to /dev like slaacd(8) is doing to be able toFlorian Obser
start unwind earlier, before /var is mounted. discussed with deraadt
2019-11-06Rename "asr" to "stub" in user visible parts.Florian Obser
More people know what a "stub" resolver is then asr. Pointed out by & discussed with deraadt Input & OK otto
2019-11-03*** empty log message ***Otto Moerbeek
2019-10-31 With the asr fallback we can skip the service port up & down dance,Florian Obser
unwind should now be able to work in networks with crappy middle boxes. We also need to switch to the ASR resolver, not DHCP when we are behind a captive portal. Some captive portals let through DNS queries with edns0 options but the "click here to accept the terms of service page" is not resolvable with edns0.
2019-10-31Add asr resolver type which completely bypasses libunbound and uses theFlorian Obser
libc asynchronous resolver directly with DHCP provided nameservers. This is a last-ditch effort when we find ourself behind a completely broken middle-box. Input & OK otto OK benno
2019-10-21Optionally log blocked queries when using the block list.Florian Obser
OK benno
2019-05-14Move common config passing code into a function.Florian Obser
OK pamela
2019-05-13Remove strict mode for now, it is in the way.Florian Obser
2019-05-10 Implement DNS block lists. If unwind is queried for a domainFlorian Obser
in the block list it answers with rcode REFUSED.
2019-04-02Add a config option to specify the preference of name servers.Florian Obser
Unfortunately the nameserver types enums needed to be renamed to not collide with yacc tokens.
2019-03-30Shuffle captive portal detection around.Florian Obser
While we are behind a captive portal we have to ask the dhcp provided resolvers. However it is possible that those resolvers do not like to talk to unwind because of EDNS0. Unwind handles this case by closing its listening socket and hands over to asr. Except for the resolving of the captive portal host which it still tries to resolve via libunbound. Turns out there is no need for this we can just use getaddrinfo_async from asr which then either hits unwind which does the right thing or unwind closed its listening socket and asr moves on to talk directly to the dhcp resolvers.
2019-03-24Do not check every resolver every 30 seconds as that is wasteful andFlorian Obser
pointless. Trigger a check - on startup - when forwarders change on config reload - when dhcp provided forwarders change - on network interface state change When a check finishes and the checked resolver cannot resolve anything configure a timer to run another check in the future using an exponential backoff for the timeout.
2019-02-18Introduce IMSG_DATA_SIZE() macro to to replace reoccuring math onFlorian Obser
imsg.hdr.len and shorten code. Input & OK pamela
2019-02-17Since we do a naive string comparison to see if the trust anchorFlorian Obser
changed we need to fix the TTL to the value we would get from the root for the ksk DNSKEY (currently 2 days). Otherwise we would interpret a lowerd TTL from a cache as changed trust anchor. Use the same define everywhere. (Considering the glacial speed with which the root ksk rotates this should be fine for the forseable future.)
2019-02-17 s/unwind_/uw_/ to save screen real estate; fix style(9) issues while hereFlorian Obser
2019-02-10Simplify trust anchor handling.Florian Obser
Open trust anchor file for reading and writing on startup and pass it to the frontend process. The frontend process seeks and truncates the file apropriately when writing out new trust anchors learned via DNS but never closes the file. On error the file is truncated to zero length. This is in turn handled on startup by switching to the built in trust anchor when no trustanchor can be read from disk. This side steps the need for an unveil'ed directory with "c" permission and also removes the wpath and cpath pledges from the parent process. deraadt@ pointed out that my previous design didn't make sense and I had confused myself along the way. (It did work, but was too complicated for no good reason). While here validate that we actually read a trust anchor from disk by trying to parse it and checking that it is a DNSKEY. Unfortunately ub_ctx_add_ta() accepts just any string as a trust anchor without any validation.
2019-02-07Rewrite trust anchor handling.Florian Obser
Do not use the libunbound's auto trust anchor file feature since it then the resolver process needs rpath, wpath, and cpath pledges and permission on the trust anchor file. Instead configure the trust anchor as resource record strings. The parent process opens the file, passes a filedescriptor to the frontend process to parse the file and then passes trust anchors to the resolver process to (re-) configure the resolver contexts. The resolver process periodically probes for new trust anchors (DNSKEY records of the root zone) and passes those to the frontend process. This in turn requests a file descripter for writing from the parent process. Once the trust anchors have been written the parent process renames the tmp file to the final location. Also provide a built in trust anchor for boot strapping purposes if no file is found on disk. That way we can get rid of unbound-anchor in unwind's rc.d script.