summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-manager.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: also use CMSG_TYPED_DATA() on writing message headerYu Watanabe2023-04-161-2/+2
|
* tree-wide: port more code over to CMSG_TYPED_DATA()Lennart Poettering2023-04-131-6/+6
|
* resolve: refuse mdns scope for ipv4 broadcast addressesRonan Pigott2023-04-051-2/+3
| | | | This query can never be answered, so let's no wait for it to timeout.
* socket-util: fix socket_get_family()Lennart Poettering2023-03-101-3/+3
| | | | Function didn't actually return anything useful. Quite a shame.
* resolved: flush caches on memory pressure and support SIGRTMIN+18Lennart Poettering2023-03-011-0/+32
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-7/+7
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* resolved: handle -EINTR returned from fd_wait_for_event() betterLennart Poettering2022-11-221-4/+16
| | | | | We might get signals for various reasons (for example, somebody asking us to reload caches via a signal), hence let's handle this gracefully.
* resolved: drop unnecessary empty linesZbigniew Jędrzejewski-Szmek2022-10-201-4/+0
|
* tree-wide: inline declarations of sd_netlink_message iteratorsZbigniew Jędrzejewski-Szmek2022-10-201-3/+2
| | | | Most places were already converted, but a few weren't for some reason.
* resolve: fix typoYu Watanabe2022-10-031-1/+1
|
* resolved: beef up monitor protocol, include full query infoLennart Poettering2022-09-301-40/+78
|
* resolved: rename 'notification' → 'monitor'Lennart Poettering2022-09-301-1/+1
| | | | | We expose this externally already as "monitor", name it internally the same way. (Which is nice since it mirrors busctl monitor)
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-19/+8
|
* Implement DNS notifications from resolved via varlinkSuraj Krishnan2022-09-091-0/+59
| | | | | | | | | | | | | | | | | | | | * The new varlink interface exposes a method to subscribe to DNS resolutions on the system. The socket permissions are open for owner and group only. * Notifications are sent to subscriber(s), if any, after successful resolution of A and AAAA records. This feature could be used by applications for auditing/logging services downstream of the resolver. It could also be used to asynchronously update the firewall. For example, a system that has a tightly configured firewall could open up connections selectively to known good hosts based on a known allow-list of hostnames. Of course, updating the firewall asynchronously will require other design considerations (such as queueing packets in the user space while a verdict is made). See also: https://lists.freedesktop.org/archives/systemd-devel/2022-August/048202.html https://lists.freedesktop.org/archives/systemd-devel/2022-February/047441.html
* tree-wide: Use correct format specifiersJan Janssen2022-08-301-1/+1
| | | | gcc will complain about all these with -Wformat-signedness.
* sd-netlink: rename sd_netlink_message_request_dump to ↵Zbigniew Jędrzejewski-Szmek2022-08-191-2/+2
| | | | sd_netlink_message_set_request_dump
* tree-wide: add global ascii_isdigit() + ascii_isalpha()Lennart Poettering2022-07-051-1/+1
| | | | | | | | We now have a local implementation in string-util-fundamental.c, but it's useful at a lot of other places, hence let's give it a more expressive name and share it across the tree. Follow-up for: 8d9156660d6958c8d63b1d44692968f1b5d33920
* basic/in-addr-util: add IN_ADDR_TO_STRINGZbigniew Jędrzejewski-Szmek2022-06-061-10/+4
| | | | | | | | | | | | | | | Since we don't need the error value, and the buffer is allocated with a fixed size, the whole logic provided by in_addr_to_string() becomes unnecessary, so it's enough to wrap inet_ntop() directly. inet_ntop() can only fail with ENOSPC. But we specify a buffer that is supposed to be large enough, so this should never fail. A bunch of tests of this are added. This allows all the wrappers like strna(), strnull(), strempty() to be dropped. The guard of 'if (DEBUG_LOGGING)' can be dropped from around log_debug(), because log_debug() implements the check outside of the function call. But log_link_debug() does not, so it we need it to avoid unnecessary evaluation of the formatting.
* time-util: assume CLOCK_BOOTTIME always existsLennart Poettering2022-03-281-1/+1
| | | | | | | | Let's raise our supported baseline a bit: CLOCK_BOOTTIME started to work with timerfd in kernel 3.15 (i.e. back in 2014), let's require support for it now. This will raise our baseline only modestly from 3.13 → 3.15.
* Merge pull request #22740 from yuwata/listZbigniew Jędrzejewski-Szmek2022-03-211-8/+0
|\ | | | | tree-wide: declare iterator of LIST_FOREACH() in the loop
| * list: declare iterator of LIST_FOREACH() in the loopYu Watanabe2022-03-191-8/+0
| |
* | sd-event: add a single implementation of an event source that runs on clock ↵Lennart Poettering2022-03-181-13/+2
|/ | | | | | | | | | changes We basically had the same code in three places. Let's unify it in a common helper function. event_add_time_change() might be something we should add to the official sd-event API sooner or later, given its general usefulness.
* Revert "resolved: filter out our own stub resolvers when parsing servers"Lennart Poettering2022-02-161-15/+8
| | | | | | | | | | | | | | | | | | This reverts commit 0ad4efb14beea9148838a0d974821e3b98cafc47. See https://github.com/systemd/systemd/pull/20559#issuecomment-1028011030 for reasoning. Quoting: > I think it should be OK to advertise extra stub listeners to local > clients, but you prohibit this now. i.e. there are two different > concepts here, and we shouldn't mix them up: > > 1. tracking configured dns servers and advertise them to local programs > 2. actually using them ourselves > > I am pretty sure that our own stubs are OK for 1 but not OK for 2, > hence we should filter at the time of use not at the time of parse.
* Merge pull request #21786 from keszybz/dirent-workYu Watanabe2021-12-171-1/+0
|\ | | | | Make FOREACH_DIRENT and FOREACH_DIRENT_ALL declare the iterator variables
| * tree-wide: make FOREACH_DIRENT_ALL define the iterator variableZbigniew Jędrzejewski-Szmek2021-12-151-1/+0
| | | | | | | | | | | | | | | | | | The variable is not useful outside of the loop (it'll always be null after the loop is finished), so we can declare it inline in the loop. This saves one variable declaration and reduces the chances that somebody tries to use the variable outside of the loop. For consistency, 'de' is used everywhere for the var name.
* | resolved: filter out our own stub resolvers when parsing serversZbigniew Jędrzejewski-Szmek2021-12-151-8/+15
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We get "upstream" dns server config from ~three places: /etc/resolv.conf, config files, and runtime config via dbus. With this commit, we'll filter out our own stub listeners if they are configured in either of the first two sources. For /etc/resolv.conf this is done quitely, and for our own config files, a LOG_INFO message is emitted, since this is a small inconsistency in the config. Setting loops like this over dbus is still allowed. The reason is that in the past we didn't treat this as an error, and if we were to start responding with an error, we could break a scenario that worked previously. E.g. NM sends us a list of servers, and one happens to be the our own. We would just not use that stub server before, but it'd still be shown in the dbus properties and such. We would have to return error for the whole message, also rejecting the other valid servers. I think it's easier to just keep that part unchanged. Test case: $ ls -l /etc/resolv.conf -rw-r--r-- 1 root root 57 Dec 15 10:26 /etc/resolv.conf $ cat /etc/resolv.conf nameserver 192.168.150.1 options edns0 trust-ad search . $ cat /etc/systemd/resolved.conf.d/stub.conf [Resolve] DNSStubListenerExtra=192.168.150.1 $ resolvectl ... Global resolv.conf mode: foreign DNS Servers: 192.168.150.1 Fallback DNS Servers: ... (with the patch): Global resolv.conf mode: foreign Fallback DNS Servers: ...
* tree-wide: use ERRNO_IS_TRANSIENT()Yu Watanabe2021-11-301-3/+6
|
* resolved: include IP address info in debug output for incoming datagramsLennart Poettering2021-11-221-2/+10
|
* fix typoYu Watanabe2021-05-141-1/+1
|
* resolved: be more careful with weird links with low MTUsLennart Poettering2021-05-121-4/+13
| | | | | | | | | | | | | | | | | Apparently CAN links will show up in rtnetlink with very low MTUs. We shouldn't consider them relevant if no IP is spoken over them, since these MTUs are irrelevant for us then. Hence, let's check if there's an address assigned to the link before considering its MTU. As additional safety net filter out MTUs smaller than the minimum DNS packet size, too. Finally, in case we don't find any suitable interface MTU, let's default to 1500 as the generic Ethernet MTU. Fixes: #19396
* resolve: remove RRs from zones before an updateRoman Beranek2021-05-101-3/+4
| | | | | | | | | During an update of RRs, the records of each DNS-SD service are replaced with new ones. However the old RRs can only be removed from the mDNS scopes as long as they remain accessible from the DnssdService structures, otherwise they remain stuck there. Therefore the removal must take place before the update.
* resolved: split out function to determine the local llmnr hostnameZbigniew Jędrzejewski-Szmek2021-03-261-64/+9
|
* resolved: disable event sources before unreffing themZbigniew Jędrzejewski-Szmek2021-03-011-1/+1
| | | | | | | | | | | | | | | | | | We generally operate on the assumption that a source is "gone" as soon as we unref it. This is generally true because we have the only reference. But if something else holds the reference, our unref doesn't really stop the source and it could fire again. In particular, on_query_timeout() is called with DnsQuery* as userdata, and it calls dns_query_stop() which invalidates that pointer. If it was ever called again, we'd be accessing already-freed memory. I don't see what would hold the reference. sd-event takes a temporary reference, but on the sd_event object, not on the individual sources. And our sources are non-floating, so there is no reference from the sd_event object to the sources. For #18427.
* resolved: unref event object after the sourcesZbigniew Jędrzejewski-Szmek2021-03-011-2/+2
| | | | It shouldn't matter because of all the refcounting, but it looks unclean.
* resolved: fix minor memory leakLennart Poettering2021-02-231-1/+7
| | | | Coverity 1446992
* Allow the fallback hostname to be overriden using an environment variableZbigniew Jędrzejewski-Szmek2021-02-221-15/+18
| | | | | | | | | | | | | | See https://bugzilla.redhat.com/show_bug.cgi?id=1893417 for the back story: the fallback hostname matters a lot in certain environments. Right now the only way to configure the fallback hostname is by recompiling systemd, which is obviously problematic in case when the fallback hostname shall differ between different editions of the same distro that share a single compiled rpm. By making this overridable through an envvar, we're providing an escape hatch without making this a top-level api. Later on a way to set this through os-release is added, but I think the approach with the variable is still useful. It it very convenient for testing, or to override settings only in a particular service, etc.
* resolved: improve debug logging on incoming messages a bitLennart Poettering2021-02-181-1/+3
|
* resolved: collect incoming fragment size when receiving UDP datagramsLennart Poettering2021-02-181-0/+8
| | | | | | We can later use this to adapt our announced EDNS buffer size in order to avoid fragmentation to make the best of large datagrams while still avoiding he security weaknesses of it.
* resolved: disable path MTU discovery for UDP trafficLennart Poettering2021-02-181-0/+60
| | | | | | | | | This disables path MTU discovery both for our UDP upstream connections and our UDP stub, following the suggestions of: https://blog.apnic.net/2019/07/12/its-time-to-consider-avoiding-ip-fragmentation-in-the-dns/ This more or less follows the model of other DNS servers on this.
* resolve: make manager_find_ifindex() or friends return earlierYu Watanabe2021-02-181-0/+12
|
* resolved: instead of closing DNS UDP transaction fds right-away, add them to ↵Lennart Poettering2021-02-151-0/+2
| | | | | | | | | | | | | a socket "graveyard" The "socket graveyard" shall contain sockets we have sent a question out of, but not received a reply. If we'd close thus sockets immediately when we are not interested anymore, we'd trigger ICMP port unreachable messages once we after all *do* get a reply. Let's avoid that, by leaving the fds open for a bit longer, until a timeout is reached or a reply datagram received. Fixes: #17421
* resolved: filter repeated stub queriesLennart Poettering2021-02-151-0/+2
| | | | | | | Let's suppress repeated stub queries coming in, to minimize resource usage. Many DNS clients are pretty aggressive regarding repeating DNS requests, hence let's find them and suppress the follow-ups should we need more time to fulfill the queries.
* resolved: refuse sending packets to our own stub listenersLennart Poettering2021-02-141-0/+24
| | | | | | | | | A previous commit made sure that when one of our own packets is looped back to us, we ignore it. But let's go one step further, and refuse operation if we notice the server we talk to is our own. This way we won't generate unnecessary traffic and can return a cleaner error. Fixes: #17413
* resolved: refuse packets looped back to usLennart Poettering2021-02-141-0/+16
| | | | Fixes: #17413
* resolved: rename manager_our_packet() → manager_packet_from_local_address()Lennart Poettering2021-02-141-1/+3
| | | | | | | | | Let's be more precise in naming this function, after all this doesn#t actually check if the packet is really ours, but just that the source IP address is a local one. Hence name it that way. (This is preparation to add a helper that checks if packet belongs to local transaction later on)
* resolved: always take a timestamp when first seeing a packetLennart Poettering2020-12-161-0/+2
| | | | | This is later useful if we want to adjust the TTLs of packets we want to propagate to clients.
* resolved: use stat_inode_unmodified() to detect /etc/hosts changesLennart Poettering2020-12-031-3/+0
|
* resolved: automatically flush caches on clock changeLennart Poettering2020-12-031-3/+56
| | | | | | | | | | | | DNSSEC validation takes the system clock into account to validate signatures. This means if we had incorrect time and the time is then changed to the correct one we should flush out everything and re-validate taking the new time into account. (This logic will also trigger after system suspend, which is not bad either, given that quite possibly we are connected to a different network, and thus would get different DNS data, without us noticing otherwise via link beat).
* Merge pull request #17478 from yuwata/split-network-internalYu Watanabe2020-11-271-1/+0
|\ | | | | libsystemd-network: split network-internal.c
| * tree-wide: drop unnecessary inclusion of network-internal.hYu Watanabe2020-10-291-1/+0
| |