summaryrefslogtreecommitdiff
path: root/src/resolve
AgeCommit message (Collapse)Author
2015-11-29tree-wide: remove unused variablesThomas Hindoe Paaboel Andersen
2015-11-27Merge pull request #2052 from poettering/export-cleanupDavid Herrmann
Make gcc cleanup helper calls public in most of our sd-xyz APIs
2015-11-27resolved: add one more comment with a link to the matching RFCLennart Poettering
2015-11-27tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering
GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
2015-11-27resolved: announce support for large UDP packetsTom Gundersen
This is often needed for proper DNSSEC support, and even to handle AAAA records without falling back to TCP. If the path between the client and server is fully compliant, this should always work, however, that is not the case, and overlarge packets will get mysteriously lost in some cases. For that reason, we use a similar fallback mechanism as we do for palin EDNS0, EDNS0+DO, etc.: The large UDP size feature is different from the other supported feature, as we cannot simply verify that it works based on receiving a reply (as the server will usually send us much smaller packets than what we claim to support, so simply receiving a reply does not mean much). For that reason, we keep track of the largest UDP packet we ever received, as this is the smallest known good size (defaulting to the standard 512 bytes). If announcing the default large size of 4096 fails (in the same way as the other features), we fall back to the known good size. The same logic of retrying after a grace-period applies.
2015-11-27resolved: set the DNSSEC OK (DO) flagTom Gundersen
This indicates that we can handle DNSSEC records (per RFC3225), even if all we do is silently drop them. This feature requires EDNS0 support. As we do not yet support larger UDP packets, this feature increases the risk of getting truncated packets. Similarly to how we fall back to plain UDP if EDNS0 fails, we will fall back to plain EDNS0 if EDNS0+DO fails (with the same logic of remembering success and retrying after a grace period after failure).
2015-11-27resolved: implement minimal EDNS0 supportTom Gundersen
This is a minimal implementation of RFC6891. Only default values are used, so in reality this will be a noop. EDNS0 support is dependent on the current server's feature level, so appending the OPT pseudo RR is done when the packet is emitted, rather than when it is assembled. To handle different feature levels on retransmission, we strip off the OPT RR again after sending the packet. Similarly, to how we fall back to TCP if UDP fails, we fall back to plain UDP if EDNS0 fails (but if EDNS0 ever succeeded we never fall back again, and after a timeout we will retry EDNS0).
2015-11-27resolved: rr - add OPT pseudo-rr supportTom Gundersen
Needed for EDNS0.
2015-11-27resolved: degrade the feature level on explicit failureTom Gundersen
Previously, we would only degrade on packet loss, but when adding EDNS0 support, we also have to handle the case where the server replies with an explicit error.
2015-11-27resolved: fallback to TCP if UDP failsTom Gundersen
This is inspired by the logic in BIND [0], follow-up patches will implement the reset of that scheme. If we get a server error back, or if after several attempts we don't get a reply at all, we switch from UDP to TCP for the given server for the current and all subsequent requests. However, if we ever successfully received a reply over UDP, we never fall back to TCP, and once a grace-period has passed, we try to upgrade again to using UDP. The grace-period starts off at five minutes after the current feature level was verified and then grows exponentially to six hours. This is to mitigate problems due to temporary lack of network connectivity, but at the same time avoid flooding the network with retries when the feature attempted feature level genuinely does not work. Note that UDP is likely much more commonly supported than TCP, but depending on the path between the client and the server, we may have more luck with TCP in case something is wrong. We really do prefer UDP though, as that is much more lightweight, that is why TCP is only the last resort. [0]: <https://kb.isc.org/article/AA-01219/0/Refinements-to-EDNS-fallback-behavior-can-cause-different-outcomes-in-Recursive-Servers.html>
2015-11-27resolved: never cache RRs originating from localhostLennart Poettering
After all, this is likely a local DNS forwarder that caches anyway, hence there's no point in caching twice. Fixes #2038.
2015-11-27resolved: flush the global DNS cache if /etc/resolv.conf is touchedLennart Poettering
After all /etc/resolv.conf is usually done when the network configuration changes, which is a good reason to flush the global cache. See: #2038
2015-11-27resolved: don't clear the server list too eagerlyLennart Poettering
If /etc/resolv.conf is missing, this should not result in the server list to be cleared, after all the native data from resolved.conf shouldn't be flushed out then. Hence flush out the data only if /etc/resolv.conf exists, but we cannot read it for some reason.
2015-11-27resolved: fix buildLennart Poettering
2015-11-27resolved: don't follow the global search list on local scopesLennart Poettering
It probably doesn't make sense to mix local and global configuration. Applying global search lists to local DNS servers appears unnecessary and creates problems because we'll traverse the search domains non-simultaneously on multiple scopes. Also see: https://github.com/systemd/systemd/pull/2031
2015-11-27resolved: handle properly if there are multiple transactions for the same ↵Lennart Poettering
key per scope When the zone probing code looks for a transaction to reuse it will refuse to look at transactions that have been answered from cache or the zone itself, but insist on the network. This has the effect that there might be multiple transactions around for the same key on the same scope. Previously we'd track all transactions in a hashmap, indexed by the key, which implied that there would be only one transaction per key, per scope. With this change the hashmap will only store the most recent transaction per key, and a linked list will be used to track all transactions per scope, allowing multiple per-key per-scope. Note that the linked list fields for this actually already existed in the DnsTransaction structure, but were previously unused.
2015-11-27resolved: for a transaction, keep track where the answer data came fromLennart Poettering
Let's track where the data came from: from the network, the cache or the local zone. This is not only useful for debugging purposes, but is also useful when the zone probing wants to ensure it's not reusing transactions that were answered from the cache or the zone itself.
2015-11-27resolved: store just the DnsAnswer instead of a DnsPacket as answer in ↵Lennart Poettering
DnsTransaction objects Previously we'd only store the DnsPacket in the DnsTransaction, and the DnsQuery would then take the DnsPacket's DnsAnswer and return it. With this change we already pull the DnsAnswer out inside the transaction. We still store the DnsPacket in the transaction, if we have it, since we still need to determine from which peer a response originates, to implement caching properly. However, the DnsQuery logic doesn't care anymore for the packet, it now only looks at answers and rcodes from the successfuly candidate. This also has the benefit of unifying how we propagate incoming packets, data from the local zone or the local cache.
2015-11-27resolved: change query flag definitionsLennart Poettering
Let's use a more useful way to write the flags. Also, leave some space in the middle for the mDNS flags. After all, these flags are exposed on the bus, and we should really make sure to expose flags that are going to be stable, hence allow some room here... (Not that the room really mattered, except to be nice to one's OCD)
2015-11-26Merge pull request #2031 from poettering/resolved-search-domainsTom Gundersen
resolved. Fully implement search domains for single-label names
2015-11-26resolved: bus - follow CNAME chains when resolving addressesTom Gundersen
It may be unexpected to find a CNAME record when doing a reverse lookup, as we expect to find a PTR record directly. However, it is explicitly supported according to <https://tools.ietf.org/html/rfc2181#section-10.2>, and there seems to be no benefit to not supporting it.
2015-11-26resolved: do not reject NSEC records with empty bitmapsTom Gundersen
The assumption that no NSEC bitmap could be empty due to the presence of the bit representing the record itself turns out to be flawed. See (the admittedly experimental) RFC4956 for a counter example.
2015-11-25dns-domain: rework dns_label_escape() to not imply memory allocationLennart Poettering
The new dns_label_escape() call now operates on a buffer passed in, similar to dns_label_unescape(). This should make decoding a bit faster, and nicer.
2015-11-25dns-domain: change dns_srv_type_is_valid() return value to boolLennart Poettering
For similar reasons as dns_name_is_root() got changed in the previous commit.
2015-11-25dns-domain: simplify dns_name_is_root() and dns_name_is_single_label()Lennart Poettering
Let's change the return value to bool. If we encounter an error while parsing, return "false" instead of the actual parsing error, after all the specified hostname does not qualify for what the function is supposed to test. Dealing with the additional error codes was always cumbersome, and easily misused, like for example in the DHCP code. Let's also rename the functions from dns_name_root() to dns_name_is_root(), to indicate that this function checks something and returns a bool. Similar for dns_name_is_signal_label().
2015-11-25resolved: fully support DNS search domainsLennart Poettering
This adds support for searching single-label hostnames in a set of configured search domains. A new object DnsQueryCandidate is added that links queries to scopes. It keeps track of the search domain last used for a query on a specific link. Whenever a host name was unsuccessfuly resolved on a scope all its transactions are flushed out and replaced by a new set, with the next search domain appended. This also adds a new flag SD_RESOLVED_NO_SEARCH to disable search domain behaviour. The "systemd-resolve-host" tool is updated to make this configurable via --search=. Fixes #1697
2015-11-25resolved: expose some properties on the busLennart Poettering
For now, let's just expose the LLMNR hostname currently in use; a combined list of all dns servers with their interface indexes; a combined list of all search domains with their interface indexes.
2015-11-25resolved: split out calls to compile full list of dns servers and search domainsLennart Poettering
Let's split this out from the resolv.conf parser, so that this becomes generically useful.
2015-11-25resolved: enforce a maximum limit on both dns servers and search domainsLennart Poettering
2015-11-25resolved: unify DnsServer handling code between Link and ManagerLennart Poettering
This copies concepts we introduced for the DnsSearchDomain stuff, and reworks the operations on lists of dns servers to be reusable and generic for use both with the Link and the Manager object.
2015-11-25resolved: add a generic DnsSearchDomain conceptLennart Poettering
With this change, we add a new object to resolved, "DnsSearchDomain=" which wraps a search domain. This is then used to introduce a global search domain list, in addition to the existing per-link search domain list which is reword to make use of this new object too. This is preparation for implement proper unicast DNS search domain support.
2015-11-25resolved: make sure order of dns servers is stableLennart Poettering
Previously, we'd keep adding new dns servers we discover to the end of our linked list of servers. When we encountered a pre-existing server, we'd just leave it where it was. In essence that meant that old servers ended up at the front, and new servers at the end, but not in an order that would reflect the configuration. With this change we ensure that every pre-existing server we want to add again we move to the back of the linked list, so that the order is stable and in sync with the requested configuration.
2015-11-25resolved: drop unused enum typeLennart Poettering
2015-11-25resolved: make sure FallbackDNS= overrides built-in servers, doesn't extend themLennart Poettering
Closes #342.
2015-11-25resolved: rework dns server lifecycle logicLennart Poettering
Previously, there was a chance of memory corruption, because when switching to the next DNS server we didn't care whether they linked list of DNS servers was still valid. Clean up lifecycle of the dns server logic: - When a DnsServer object is still in the linked list of DnsServers for a link or the manager, indicate so with a "linked" boolean field, and never follow the linked list if that boolean is not set. - When picking a DnsServer to use for a link ot manager, always explicitly take a reference. This also rearranges some logic, to make the tracking of dns servers by link and globally more alike.
2015-11-25resolved: move dns server picking code from resolved-manager.c to ↵Lennart Poettering
resolved-dns-server.c
2015-11-25resolved: indent less, by exiting earlierLennart Poettering
2015-11-25resolved: split out all code dealing with /etc/resolv.conf into its own .c fileLennart Poettering
No functional changes.
2015-11-25resolved: unify code for parsing dns server informationLennart Poettering
Let's use the same parser when parsing dns server information from /etc/resolv.conf and our native configuration file. Also, move all code that manages lists of dns servers to a single place. resolved-dns-server.c
2015-11-25resolved: /etc/resolved.conf missing is not an errorLennart Poettering
Don't propagate any error in this case, it's really not an error.
2015-11-25resolved: don't claim DnsQuestion have to have the same namesLennart Poettering
Wen DnsQuestion objects are used for DnsQuery objects all contained keys have to share the same name, but otherwise they generally don't have to, and this can actually happen in real-life because DnsPacket objects for mDNS use DnsQuestion for the question section. Hence, rename: dns_question_is_valid() to dns_question_is_valid_for_query(), since the name uniqueness check it does is only relevant when used for a query. Similar, rename dns_question_name() to dns_question_first_name(), to be more accurate, as this difference matters if we keys don#t have to share the same name.
2015-11-24resolved: remove unused variableThomas Hindoe Paaboel Andersen
2015-11-24resolved: implement client-side DNAME resolutionLennart Poettering
Most servers apparently always implicitly convert DNAME to CNAME, but some servers don't, hence implement this properly, as this is required by edns0.
2015-11-24question: drop dns_question_is_superset() which we don't use anymoreLennart Poettering
2015-11-23resolved: add ResolveService() bus call for resolving SRV and DNS-SD servicesLennart Poettering
This also adds client-side support for this to systemd-resolve-host. Note that the ResolveService() API can deal both with DNS-SD service (consisting of service name, type and domain), as well as classic SRV services (consisting just of a type and a domain), all exposed in the same call. This patch also reworks CNAME handling in order to reuse it between hostname, RR and service lookups. In contrast to Avahi and Bonjour, this new API will actually reolve the A/AAAA RRs the SRV RRs point to in one go (unless this is explicitly disabled). This normally comes for free, as these RRs are sent along the SRV responses anyway, hence let's make use of that. This makes the API considerably easier to use, as a single ResolveService() invocation will return all necessary data to pick a server and connect() to it. Note that this only implements the DNS-SD resolving step, it does not implement DNS-SD browsing, as that makes sense primarily on mDNS, due to its continuous nature.
2015-11-23resolved: fix minor memory leak when shuttin downLennart Poettering
We need to free the rtnl watch too.
2015-11-23resolved: accept TXT records with non-UTF8 stringsLennart Poettering
RFC 6763 is very clear that TXT RRs should allow arbitrary binary content, hence let's actually accept that. This also means accepting NUL bytes in the middle of strings.
2015-11-19Merge pull request #1947 from phomes/sort-includes2Lennart Poettering
tree-wide: sort includes in *.h
2015-11-18tree-wide: sort includes in *.hThomas Hindoe Paaboel Andersen
This is a continuation of the previous include sort patch, which only sorted for .c files.
2015-11-18resolved: shortcut lookups names in the local zoneLennart Poettering
Previously, we'd always generate a packet on the wire, even for names that are within our local zone. Shortcut this, and always check the local zone first. This should minimize generated traffic and improve security.