Commit Graph

57 Commits

Author SHA1 Message Date
Lennart Poettering ad44b56b0f resolved: teach resolved the difference between "routing" and "search" domains
Following the changes to expose the "routing" and "search" domain concepts in networkd, actually make resolved use
them. It will now use routing domains exclusively for making DNS routing decisions, and use search domains additionally
for extending single-label names.
2016-01-26 14:42:04 +01:00
Lennart Poettering 3df9bec57c networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.

With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.

This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-26 14:42:03 +01:00
Lennart Poettering 6955a3ba9d resolved: when checking whether a link is relevant, check kernel operstate
This mimics what networkd is doing to detect a carrier.
2016-01-25 15:59:40 +01:00
Lennart Poettering c69fa7e3c4 resolved: rework DNSSECSupported property
Not only report whether the server actually supports DNSSEC, but also first check whether DNSSEC is actually enabled
for it in our local configuration.

Also, export a per-link DNSSECSupported property in addition to the existing manager-wide property.
2016-01-19 21:56:54 +01:00
Lennart Poettering 97e5d693c0 resolved: add bus API for configuring per-link DNS settings
This is useful for alternative network management solutions (such as NetworkManager) to push DNS configuration data
into resolved.

The calls will fail should networkd already have taken possesion of a link, so that the bus API is only available if
we don't get the data from networkd.
2016-01-19 18:37:45 +01:00
Lennart Poettering dfc1091b2f resolved: allocate DNS scope for links only if the interface is up
For mDNS and LLMNR we already created the scopes only if the specific interfaces where actually up and suitable for
Multicasting. Add a similar (but weaker) logic for unicast DNS as well.
2016-01-19 18:37:45 +01:00
Lennart Poettering 2e1bab34bd resolved: when switching between DNSSEC modes, possibly flush caches
If the networkd configuration changes during runtime, make sure to flush all caches when we switch from a less trusted
to a more trusted mode.
2016-01-17 20:47:46 +01:00
Lennart Poettering 6cb08a8930 resolved: cache formatted server string in DnsServer structure
This makes it easier to log information about a specific DnsServer object.
2016-01-11 19:40:00 +01:00
Lennart Poettering 8a516214c4 resolved: introduce support for per-interface negative trust anchors 2016-01-06 18:36:32 +01:00
Lennart Poettering ad6c047561 resolved,networkd: add a per-interface DNSSEC setting
This adds a DNSSEC= setting to .network files, and makes resolved honour
them.
2016-01-05 20:10:31 +01:00
Lennart Poettering 125ae29d1b resolved: log about per-interface setting parse errors 2016-01-05 20:00:59 +01:00
Lennart Poettering 00f0a16ab4 resolved: properly release all DnsServers that belong to a link 2016-01-05 20:00:59 +01:00
Lennart Poettering aaa297d4e5 networkd,resolved: add a per-interface mdns configuration option 2016-01-05 17:41:41 +01:00
Lennart Poettering af49ca27ff resolved,networkd: unify ResolveSupport enum
networkd previously knew an enum "ResolveSupport" for configuring
per-interface LLMNR support, resolved had a similar enum just called
"Support", with the same value and similar pasers.

Unify this, call the enum ResolveSupport, and port both daemons to it.
2016-01-05 17:30:51 +01:00
Lennart Poettering 1ade96e980 resolved: don't complain if networkd doesn't know an interface we care about 2015-12-18 14:48:49 +01:00
Daniel Mack b4f1862df2 resolved: create dns scopes for mDNS
Follow what LLMNR does, and create per-link DnsScope objects.
2015-12-08 16:41:45 +01:00
Lennart Poettering 4b95f1798f resolved: unify DnsServer handling code between Link and Manager
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-25 21:58:38 +01:00
Lennart Poettering a51c10485a resolved: add a generic DnsSearchDomain concept
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-25 21:58:38 +01:00
Lennart Poettering 0b58db658b resolved: make sure order of dns servers is stable
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-25 21:58:38 +01:00
Lennart Poettering 0eac462399 resolved: rework dns server lifecycle logic
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-25 21:58:37 +01:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 6bedfcbb29 util-lib: split string parsing related calls from util.[ch] into parse-util.[ch] 2015-10-27 13:25:55 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Lennart Poettering 6796073e33 tree-wide: make use of the fact that strv_free() returns NULL
Another Coccinelle patch.
2015-09-09 23:05:58 +02:00
Lennart Poettering 78c6a153c4 resolved: rework synthesizing logic
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.
2015-08-21 12:41:08 +02:00
Tom Gundersen 91b14d6ff3 resolved: reference count the dns servers
We want to reference the servers from their active transactions, so make sure
they stay around as long as the transaction does.
2015-07-14 12:03:04 +02:00
Tom Gundersen 1c4baffc18 sd-netlink: rename from sd-rtnl 2015-06-13 19:52:54 +02:00
Lennart Poettering cab5b05903 resolved: fix crash when shutting down
Reported by Cristian Rodríguez

http://lists.freedesktop.org/archives/systemd-devel/2015-May/031626.html
2015-05-18 23:23:17 +02:00
Michal Schmidt da927ba997 treewide: no need to negate errno for log_*_errno()
It corrrectly handles both positive and negative errno values.
2014-11-28 13:29:21 +01:00
Michal Schmidt 0a1beeb642 treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:

find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'

Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
2014-11-28 12:04:41 +01:00
Michal Schmidt d5099efc47 hashmap: introduce hash_ops to make struct Hashmap smaller
It is redundant to store 'hash' and 'compare' function pointers in
struct Hashmap separately. The functions always comprise a pair.
Store a single pointer to struct hash_ops instead.

systemd keeps hundreds of hashmaps, so this saves a little bit of
memory.
2014-09-15 16:08:50 +02:00
Tom Gundersen bda2c408f8 resolved: pull in domain names from sd-network 2014-08-14 23:38:38 +02:00
Lennart Poettering db97a66aa6 resolved: enable LLMNR
THis was accidentally broken, as we truned off LLMNR far to frequently,
where we only wanted to turn off LLMNr on IPV6 on kernels lacking
support for it.
2014-08-14 01:01:43 +02:00
Tom Gundersen d6731e4c79 sd-network: /_get_link_/_link_get_/
The link is the 'object', so make this in line with our usual naming convention.

Suggested by Kay and Lennart.
2014-08-13 22:37:45 +02:00
Lennart Poettering 90ab504273 resolved: skip IPv6 LLMNR if IPv6 is not available 2014-08-13 15:00:12 +02:00
Lennart Poettering 6436165dbc sd-network: rename the per-ifindex calls to sd_network_get_link_xxx()
This way we can introduce system-wide versions of these calls that are
called the same way, but without the "link" in the name.
2014-08-11 22:56:52 +02:00
Lennart Poettering 7b85d72f82 resolved: don't consider tentative addresses relevant 2014-08-05 04:18:23 +02:00
Lennart Poettering cc7844e787 resolved: fix a message typo 2014-08-05 04:18:01 +02:00
Lennart Poettering 19b50b5ba7 resolved: read the per-interface LLMNR setting from networkd and act on it 2014-08-04 23:08:03 +02:00
Lennart Poettering 2c27fbca2d resolved: flush cache each time we change to a different DNS server 2014-08-01 18:10:01 +02:00
Lennart Poettering 5cb36f41f0 resolved: read the system /etc/resolv.conf unless we wrote it ourselves
This way we integrate nicely with foreign network management stacks,
such as NM.
2014-08-01 18:10:01 +02:00
Lennart Poettering 4e945a6f79 resolved: beef up DNS server configuration logic
We now maintain two lists of DNS servers: system servers and fallback
servers.

system servers are used in combination with any per-link servers.

fallback servers are only used if there are no system servers or
per-link servers configured.

The system server list is supposed to be populated from a foreign tool's
/etc/resolv.conf (not implemented yet).

Also adds a configuration switch for LLMNR, that allows configuring
whether LLMNR shall be used simply for resolving or also for responding.
2014-08-01 16:06:39 +02:00
Lennart Poettering ec2c5e4398 resolved: implement LLMNR uniqueness verification 2014-07-31 17:47:19 +02:00
Lennart Poettering 57f5ad3149 resolved: properly set TTL in SOA records 2014-07-30 19:34:50 +02:00
Lennart Poettering 8bea3d6f88 resolved: don't do llmnr on interfaces lacking multicasting 2014-07-30 01:48:22 +02:00
Lennart Poettering 0c903ae7db resolved: follow more closely the recommend timeouts and TTLs from the LLMNR spec 2014-07-30 01:47:48 +02:00
Lennart Poettering 623a4c97b9 resolve: add llmnr responder side for UDP and TCP
Name defending is still missing.
2014-07-29 20:57:58 +02:00
Tom Gundersen 6f4dedb250 sd-network: expose DNS/NTP servers as strings
This avoids having to distinguish between IPv4 and IPv6, allowing us
to keep their internal orderings. The consumers now has to turn the
strings into addresses.
2014-07-23 23:54:52 +02:00
Tom Gundersen 6073b6f26a resolved: don't read DHCP leases
networkd will expose both statically configured DNS servers and servers
receieved over DHCP in sd_network_get_dns(), so no need to keep
the distinction in resolved.
2014-07-23 23:54:52 +02:00
Tom Gundersen b0e39c8284 networkd: merge DNS and NTP entries when exporting
In the state files, do not distinguish where the various entries came from
(static or DHCP), but include them all in the same list.
2014-07-23 23:54:51 +02:00