summaryrefslogtreecommitdiffstats
path: root/src/resolve/resolved-dns-answer.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* resolved: add DNS_ANSWER_REPLACEZbigniew Jędrzejewski-Szmek2022-05-121-0/+8
| | | | C.f. ce913e0ec4c97651c7c1509b72fb81ee61d80c6a.
* resolve: manage DnsAnswerItem with OrderedSetYu Watanabe2022-05-071-52/+41
| | | | | | | | | | Previously, we manage DnsAnswerItem by an array and Set, The array was used for the order of the items, and the set is used to dedup items. Let's use OrderedSet, then we can simplify the logic. This fixes dns_answer_remove_by_key() and dns_answer_remove_by_rr() which makes the set in a broken state.
* resolve: dns_answer_contains() does not return negative errnoYu Watanabe2021-03-231-2/+2
|
* resolve: use dns_answer_size() and dns_answer_isempty()Yu Watanabe2021-03-231-16/+17
|
* resolve: rename function argument in prototype to match its declarationYu Watanabe2021-03-231-1/+1
|
* resolved: add new helper dns_answer_min_ttl()Lennart Poettering2021-03-151-0/+2
|
* resolved: when synthesizing stub replies from multiple upstream packet, ↵Lennart Poettering2021-03-061-0/+1
| | | | | | | | | | | let's avoid RR duplicates If we synthesize a stub reply from multiple upstream packet (i.e. a series of CNAME/DNAME redirects), it might happen that we add the same RR to a different reply section at a different CNAME/DNAME redirect chain element. Let's clean this up once we are about to send the reply message to the client: let's remove sections from "lower-priority" sections when they are already listed in a "higher-priority" section.
* resolved: stick CNAME targets into main answer section in stub repliesLennart Poettering2021-02-221-0/+4
|
* answer: add helper for randomizing RR of answersLennart Poettering2021-02-141-0/+2
|
* resolved: add RRSIG field to DnsAnswerItemLennart Poettering2021-02-091-4/+5
|
* resolved: add new DnsAnswerFlags indicating originating section when parsingLennart Poettering2021-02-091-9/+10
| | | | | | | | | | Let's beef up our parser a bit: let's store in the DnsAnswerFlags field (that is stored as part of DnsAnswerItem) which DNS packet section (i.e. answer, authoritative, additional) an RR originates from. This is useful when propagating answers from an upstream DNS server eventually, as we can place the data in the right sections downstream too.
* resolved: replace DNS_ANSWER_FOREACH_FULL() iterator macro with ↵Lennart Poettering2021-02-091-9/+5
| | | | | | | | | | DNS_ANSWER_FOREACH_ITEM() The more fields DnsAnswerItem gains the less sense it makes to pass every field of it as separate parameter to an iterator macro. Let's simplify things here, in preparation of adding more fields to the structure later on: let's just return the structure itself in the loop, rather than the individual fields.
* resolved: slight modernizations of resolved-dns-answer.c functionsLennart Poettering2021-02-091-2/+2
| | | | | Let's follow our own coding style an initialized return values on all cases of "success".
* resolved: add dns_answer_contains() helperLennart Poettering2021-02-091-0/+1
|
* resolve: slightly optimize dns_answer_add()Yu Watanabe2020-12-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, dns_answer_add() was O(n^2). With this change dns_packet_extract() becomes ~15 times faster for some extremal case. Before: ``` $ time ./fuzz-dns-packet ~/downloads/clusterfuzz-testcase-minimized-fuzz-dns-packet-5631106733047808 /home/watanabe/downloads/clusterfuzz-testcase-minimized-fuzz-dns-packet-5631106733047808... ok real 0m15.453s user 0m15.430s sys 0m0.007s ``` After: ``` $ time ./fuzz-dns-packet ~/downloads/clusterfuzz-testcase-minimized-fuzz-dns-packet-5631106733047808 /home/watanabe/downloads/clusterfuzz-testcase-minimized-fuzz-dns-packet-5631106733047808... ok real 0m0.831s user 0m0.824s sys 0m0.006s ``` Hopefully fixes oss-fuzz#19227. https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19227
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: always declare bitflag enums the same wayLennart Poettering2019-01-071-5/+5
| | | | | let's always use the 1 << x syntax. No change of behaviour or even of the compiled binary.
* tree-wide: remove various unused functionsLennart Poettering2018-12-021-2/+0
| | | | All found with "cppcheck --enable=unusedFunction".
* resolve: fix return value type of dns_answer_has_dname_for_cname()Yu Watanabe2018-06-251-1/+1
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-4/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: be more careful with the type of array sizesLennart Poettering2018-04-271-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we were a bit sloppy with the index and size types of arrays, we'd regularly use unsigned. While I don't think this ever resulted in real issues I think we should be more careful there and follow a stricter regime: unless there's a strong reason not to use size_t for array sizes and indexes, size_t it should be. Any allocations we do ultimately will use size_t anyway, and converting forth and back between unsigned and size_t will always be a source of problems. Note that on 32bit machines "unsigned" and "size_t" are equivalent, and on 64bit machines our arrays shouldn't grow that large anyway, and if they do we have a problem, however that kind of overly large allocation we have protections for usually, but for overflows we do not have that so much, hence let's add it. So yeah, it's a story of the current code being already "good enough", but I think some extra type hygiene is better. This patch tries to be comprehensive, but it probably isn't and I missed a few cases. But I guess we can cover that later as we notice it. Among smaller fixes, this changes: 1. strv_length()' return type becomes size_t 2. the unit file changes array size becomes size_t 3. DNS answer and query array sizes become size_t Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=76745
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* resolved: implement sending goodbye mDNS packetDmitry Rozhkov2017-01-191-4/+5
| | | | | | resolved: remove unneeded braces Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
* resolved: add cache-flush bit to answers in mDNS announcementsDmitry Rozhkov2017-01-191-0/+1
| | | | | | See the section 10.2 of RFC6762 for details. Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
* resolved: add dns_answer_is_empty() and dns_question_is_empty() helpersLennart Poettering2016-06-211-0/+4
| | | | And make use of them at a few places.
* resolved: make sure we initialize the ifindex of direct zone answers properlyLennart Poettering2016-06-141-1/+1
| | | | | Previously, after checking the local zone for a reply and finding one we'd not initialize the answer ifindex from that. Let's fix that.
* Typo fixesMichael Biebl2016-02-121-1/+1
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* resolved: when we find a DNAME RR, don't insist in a signed CNAME RRLennart Poettering2016-01-171-0/+2
| | | | | If we have a signed DNAME RR response, there's no need to insist on a signature for a CNAME RR response, after all it is unlikely to be signed, given the implicit synthethis of CNAME through DNAME RRs.
* resolved: implement the full NSEC and NSEC3 postive wildcard proofsLennart Poettering2016-01-131-0/+1
|
* resolved: partially implement RFC5011 Trust Anchor supportLennart Poettering2016-01-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | With this patch resolved will properly handle revoked keys, but not augment the locally configured trust anchor database with newly learned keys. Specifically, resolved now refuses validating RRsets with revoked keys, and it will remove revoked keys from the configured trust anchors (only until reboot). This patch does not add logic for adding new keys to the set of trust anchors. This is a deliberate decision as this only can work with persistent disk storage, and would result in a different update logic for stateful and stateless systems. Since we have to support stateless systems anyway, and don't want to encourage two independent upgrade paths we focus on upgrading the trust anchor database via the usual OS upgrade logic. Whenever a trust anchor entry is found revoked and removed from the trust anchor a recognizable log message is written, encouraging the user to update the trust anchor or update his operating system.
* resolved: add a call that dumps the contents of a DnsAnswer structureLennart Poettering2015-12-181-0/+2
| | | | This is not used anywhere, but it's extremely useful when debugging.
* resolved: rework mDNS cache-flush bit handlingLennart Poettering2015-12-181-2/+3
| | | | | | | | | This adds a new DnsAnswer item flag "DNS_ANSWER_SHARED_OWNER" which is set for mDNS RRs that lack the cache-flush bit. The cache-flush bit is removed from the DnsResourceRecord object in favour of this. This also splits out the code that removes previous entries when adding new positive ones into a new separate call dns_cache_remove_previous().
* resolved: check SOA authentication state when negative cachingLennart Poettering2015-12-181-1/+1
| | | | | We should never use the TTL of an unauthenticated SOA to cache an authenticated RR.
* resolved: add support NSEC3 proofs, as well as proofs for domains that are ↵Lennart Poettering2015-12-181-8/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OK to be unsigned This large patch adds a couple of mechanisms to ensure we get NSEC3 and proof-of-unsigned support into place. Specifically: - Each item in an DnsAnswer gets two bit flags now: DNS_ANSWER_AUTHENTICATED and DNS_ANSWER_CACHEABLE. The former is necessary since DNS responses might contain signed as well as unsigned RRsets in one, and we need to remember which ones are signed and which ones aren't. The latter is necessary, since not we need to keep track which RRsets may be cached and which ones may not be, even while manipulating DnsAnswer objects. - The .n_answer_cachable of DnsTransaction is dropped now (it used to store how many of the first DnsAnswer entries are cachable), and replaced by the DNS_ANSWER_CACHABLE flag instead. - NSEC3 proofs are implemented now (lacking support for the wildcard part, to be added in a later commit). - Support for the "AD" bit has been dropped. It's unsafe, and now that we have end-to-end authentication we don't need it anymore. - An auxiliary DnsTransaction of a DnsTransactions is now kept around as least as long as the latter stays around. We no longer remove the auxiliary DnsTransaction as soon as it completed. THis is necessary, as we now are interested not only in the RRsets it acquired but also in its authentication status.
* resolved: cache - do negative caching only on the canonical nameTom Gundersen2015-12-101-0/+1
| | | | | | | | | | | | | | | | Apart from dropping redundant information, this fixes an issue where, due to broken DNS servers, we can only be certain of whether an apparent NODATA response is in fact an NXDOMAIN response after explicitly resolving the canonical name. This issue is outlined in RFC2308. Moreover, by caching NXDOMAIN for an existing name, we would mistakenly return NXDOMAIN for types which should not be redirected. I.e., a query for AAAA on test-nx-1.jklm.no correctly returns NXDOMAIN, but a query for CNAME should return the record and a query for DNAME should return NODATA. Note that this means we will not cache an NXDOMAIN response in the presence of redirection, meaning one redundant roundtrip in case the name is queried again.
* resolved: chase DNSKEY/DS RRs when doing look-ups with DNSSEC enabledLennart Poettering2015-12-101-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds initial support for validating RRSIG/DNSKEY/DS chains when doing lookups. Proof-of-non-existance, or proof-of-unsigned-zones is not implemented yet. With this change DnsTransaction objects will generate additional DnsTransaction objects when looking for DNSKEY or DS RRs to validate an RRSIG on a response. DnsTransaction objects are thus created for three reasons now: 1) Because a user asked for something to be resolved, i.e. requested by a DnsQuery/DnsQueryCandidate object. 2) As result of LLMNR RR probing, requested by a DnsZoneItem. 3) Because another DnsTransaction requires the requested RRs for validation of its own response. DnsTransactions are shared between all these users, and are GC automatically as soon as all of these users don't need a specific transaction anymore. To unify the handling of these three reasons for existance for a DnsTransaction, a new common naming is introduced: each DnsTransaction now tracks its "owners" via a Set* object named "notify_xyz", containing all owners to notify on completion. A new DnsTransaction state is introduced called "VALIDATING" that is entered after a response has been receieved which needs to be validated, as long as we are still waiting for the DNSKEY/DS RRs from other DnsTransactions. This patch will request the DNSKEY/DS RRs bottom-up, and then validate them top-down. Caching of RRs is now only done after verification, so that the cache is not poisoned with known invalid data. The "DnsAnswer" object gained a substantial number of new calls, since we need to add/remove RRs to it dynamically now.
* resolved: fix DNS_ANSWER_FOREACH_IFINDEX() to not collide with user defined ↵Lennart Poettering2015-12-101-3/+3
| | | | ifindex variable
* resolved: make sure DNS_ANSWER_FOREACH() can be nestedLennart Poettering2015-12-021-10/+15
| | | | | Change the iterator counter so that a different varable is used for each invocation of the macro, so that it may be nested.
* resolved: fully support DNS search domainsLennart Poettering2015-11-251-4/+4
| | | | | | | | | | | | | | | | | 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
* resolved: add ResolveService() bus call for resolving SRV and DNS-SD servicesLennart Poettering2015-11-231-0/+17
| | | | | | | | | | | | | | | | | | | | | | | 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.
* resolved: cache - cache what we can of negative redirect chainsTom Gundersen2015-09-161-0/+1
| | | | | | | | | | | | | | | When a NXDATA or a NODATA response is received for an alias it may include CNAME records from the redirect chain. We should cache the response for each of these names to avoid needless roundtrips in the future. It is not sufficient to do the negative caching only for the canonical name, as the included redirection chain is not guaranteed to be complete. In fact, only the final CNAME record from the chain is guaranteed to be included. We take care not to cache entries that redirects outside the current zone, as the SOA will then not be valid.
* resolved: rework synthesizing logicLennart Poettering2015-08-211-3/+14
| | | | | | | | | | | | | | | | | | | With this change we'll now also generate synthesized RRs for the local LLMNR hostname (first label of system hostname), the local mDNS hostname (first label of system hostname suffixed with .local), the "gateway" hostname and all the reverse PTRs. This hence takes over part of what nss-myhostname already implemented. Local hostnames resolve to the set of local IP addresses. Since the addresses are possibly on different interfaces it is necessary to change the internal DnsAnswer object to track per-RR interface indexes, and to change the bus API to always return the interface per-address rather than per-reply. This change also patches the existing clients for resolved accordingly (nss-resolve + systemd-resolve-host). This also changes the routing logic for queries slightly: we now ensure that the local hostname is never resolved via LLMNR, thus making it trustable on the local system.
* resolved: properly set TTL in SOA recordsLennart Poettering2014-07-301-1/+1
|
* resolved: include SOA records in LLMNR replies for non-existing RRs to allow ↵Lennart Poettering2014-07-301-0/+1
| | | | negative caching
* resolved: when answer A or AAAA questions, order responses by whether ↵Lennart Poettering2014-07-301-0/+1
| | | | addresses are link-local or not
* resolved: most DNS servers can't handle more than one question per packet, ↵Lennart Poettering2014-07-231-0/+2
| | | | hence let's not generate that
* resolved: implement negative cachingLennart Poettering2014-07-231-0/+2
|