Commit Graph
2869 Commits
Author SHA1 Message Date
Frantisek Sumsal 90f5d2a202 tree-wide: various fixlets suggested by Coccinelle 2026-03-05 10:27:58 +01:00
Mike Yuan 18d1f2dced tree-wide: make private hash ops static 2026-03-04 14:32:15 +01:00
Yu Watanabe 4b4eba1666 tree-wide: use _contains() rather than _get()/_find() 2026-03-02 23:10:22 +09:00
Anton Tiurin ce1361d7b3 resolved: use DNS_TYPE_DNSKEY for trust anchor support (#40850)
Fix typo: DNS_TYPE_DNSKEY should be used instead of DNS_TYPE_KEY.
- DNS_TYPE_KEY is deprecated
- Source code at resolved-dns-trust-anchor.c#L313 handles
DNS_TYPE_DNSKEY records, but not DNS_TYPE_KEY
So DNS_TYPE_KEY is not referenced anywhere
2026-03-02 13:44:26 +09:00
Christian Glombek 9ed12a81b2 resolved: Add ifindex=0 support for BrowseServices to browse all mDNS interfaces
Avahi provides AVAHI_IF_UNSPEC (-1) to browse mDNS services on all
interfaces simultaneously. Currently, systemd-resolved's BrowseServices
varlink API requires a specific interface index and lacks the ability to browse on
all available interfaces.

This change adds support for ifindex = 0 to mean \"browse on all mDNS-enabled
interfaces\" to match the Avahi API.

When ifindex = 0 is specified the browser will now iterate all mDNS scopes
instead of a single interface.

This enables applications to discover services on any network interface
without needing to know the specific interface index in advance.

Assisted-by: Claude Opus 4.6 (Eclipse Theia IDE AI)
2026-02-23 02:54:56 +01:00
Christian Glombek f753f898ed resolved: Track per-service item ifindex in DnssdDiscoveredService
The interface where each service was discovered needs to be remembered
so it can be correctly reported when the service is later removed.

Previously, service removal would use sb->ifindex, losing the actual
interface information from the original discovery.

This change:
- Adds an ifindex field to DnssdDiscoveredService struct
- Stores the discovered interface index when adding new services,
  preferring the per-item ifindex from DnsAnswerItem over the service
  browser's ifindex
- Uses the stored ifindex when reporting service removal events

This ensures that service removal notifications include the correct
interface index where the service was originally discovered, matching
the behavior of the corresponding service addition notifications.

Assisted-by: Claude Opus 4.6 (Eclipse Theia IDE AI)
2026-02-22 23:38:59 +01:00
Mike Yuan 603a899720 resolved-dns-scope: fix typo 2026-02-17 16:26:36 +01:00
r-vdp e271497d97 dns-delegates: add support for setting a firewall mark
This makes it possible to have DNS requests for certain domains routed
differently than normal requests, which is for instance useful when
using policy routing to route traffic over a VPN but DNS requests for
the VPN endpoint itself, should be routed differently.

It doesn't make much sense to configure a firewall mark at the level of
a network interface, but at the level of a DNS delegate it can be very
useful.
2026-02-16 11:09:48 +01:00
Mike Yuan 03023fd12c resolve: io.systemd.Resolve.BrowseServices requires 'more' 2026-02-16 09:44:55 +01:00
Mike Yuan 09388a6b9e tree-wide: drop redundant check for SD_VARLINK_METHOD_MORE flag
If the IDL declares the method requires 'more' yet the call doesn't
have it set, varlink_idl_validate_method_call() should have rejected
it and the callback shouldn't be reached.
2026-02-16 09:44:54 +01:00
Mike Yuan 05d1cfee90 sd-json: unify JSON_BUILD_PAIR_IN?_ADDR_*
This also swaps family and address params for
plain JSON_BUILD(_PAIR)_IN_ADDR, aligning with
_WITH_STRING flavors.
2026-02-16 09:44:54 +01:00
Yu Watanabe da86da21e9 Fixes for option parsing (#40641)
Preparatory work split out of #40624.
2026-02-14 04:58:50 +09:00
Carlos Peón Costa e6fd7a3f50 resolve: refuse traffic from the local host only for queries 2026-02-13 11:40:27 +01:00
Zbigniew Jędrzejewski-Szmek 097f130731 resolvectl: split out helper to parse stdin
No functional change, just splitting up of a lengthy function.
2026-02-13 11:07:25 +01:00
Daan De Meyer dc28940745 resolve: Make sure we free varlink subscription sets 2026-02-11 14:24:03 +01:00
Nick Rosbrook e28958315f resolvectl: include ifindex when printing link-local DNS server
Historically, resolvectl status has not included the interface
specification for DNS servers with an IPv6 link-local address, since it
is technically somewhat redundant. But, adding this extra bit of
information makes it easier to copy-and-paste to use elsewhere, etc.

For example, the previous output:

 Link 2 (enp34s0)
     Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
          Protocols: +DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
 Current DNS Server: fe80::861e:a3ff:feb1:f8e7
        DNS Servers: 192.168.1.12 192.168.1.13 fe80::861e:a3ff:feb1:f8e7
         DNS Domain: lan

now becomes:

 Link 2 (enp34s0)
     Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
          Protocols: +DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
 Current DNS Server: fe80::861e:a3ff:feb1:f8e7%2
        DNS Servers: 192.168.1.12 192.168.1.13 fe80::861e:a3ff:feb1:f8e7%2
         DNS Domain: lan
2026-02-07 00:14:37 +01:00
Nick Rosbrook a4750a6612 resolvectl: add print_configuration() to consolidate status logic
There is a lot of duplication across the functions for printing global,
link, and delegate output. Since these all use a common DNSConfiguration
type now, the logic can be consolidated.

Adapt printing and format helper functions to accept a DNSConfiguration
parameter to appropriately format output. Then, add print_configuration(),
a single function that prints the appropriate status output based on the
contents of DNSConfiguration.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 480ebdfddd resolvectl: consolidate JSON and regular status output paths
Now that varlink is always used for status output, consolidate the JSON
and regular status code paths. Add status_full(), which is the single
point that calls DumpDNSConfiguration, filters based on link names and
mode if needed, and prints the output in the appropriate format.

This simplifies status_ifindex(), and removes the need for a separate
status_json().
2026-02-03 15:07:41 -05:00
Nick Rosbrook 67746cd3b2 resolvectl: use varlink to report delegate status
This is an incremental commit to replacing dbus usage with varlink for
all status output.

Re-implement regular delegate status output using the DumpDNSConfiguration
varlink method. And, remove the DelegateInfo type and associated functions
which were used to map dbus properties.

Since this is the last type of status output to be switched to varlink,
lots of other code becomes dead with these changes, e.g.
read_dns_server_one(), map_dns_servers_internal(), etc., so remove those
too. Finally, status_all() no longer needs sd_bus, so drop that
parameter.
2026-02-03 15:07:41 -05:00
Nick Rosbrook d076d0f94f resolvectl: use varlink to report link status
This is an incremental commit to replacing dbus usage with varlink for
all status output.

Re-implement regular link status output using the DumpDNSConfiguration
varlink method. And, remove the LinkInfo type and associated functions
which were used to map dbus properties.
2026-02-03 15:07:41 -05:00
Nick Rosbrook a56366182e resolvectl: use varlink to report global status
This is an incremental commit to replacing dbus usage with varlink for
all status output.

Re-implement regular global status output using the DumpDNSConfiguration
varlink method. And, remove the GlobalInfo type and associated functions
which were used to map dbus properties.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 9b2f263f30 resolve: add DNSConfiguration field to indicate DNSSEC support
The varlink API is currently missing the "DNSSEC supported" field, which
is required for to re-implement the existing resolvectl status output
with varlink instead of dbus.

Add this field to DNSConfiguration.
2026-02-03 15:07:41 -05:00
Lennart Poettering 6ecfa12af0 conf-files: add support for root_fd based operation
Let's make sure we can safely load configuration files based on a root
fd, including XAT_FDROOT.

(While we are at it, always pass path to root fs before fd to root fs,
following our recently updated CODING_STYLE)
2026-01-25 20:51:50 +01:00
Nick Rosbrook d990b426b9 resolve: include current DNS server in JSON again
The current_dns_server_json object in dns_configuration_json_append() is
always NULL, because the logic to dump the current DNS server to JSON
was removed by mistake in a re-factoring commit. Add that logic back.

Fixes c6b6ac63ea ("resolve: drop unnecessary preparation of empty arrays").
2026-01-19 13:29:52 -05:00
Yu Watanabe 2aa496312e conf-files: introduce CONF_FILES_WARN flag and set it at various places
Closes #40285.
2026-01-16 23:05:33 +09:00
Mike Yuan 429cbac508 idn: drop support for libidn
The current tree doesn't even compile with libidn(1) after
2c7bdaf9f1, which included
a non-existent call to check_dlopen_blocked() somehow.
Hence, it feels safe to just nuke legacy support from
our repo.
2026-01-05 21:29:52 +09:00
Daan De Meyer 52ecf376fa tree-wide: Migrate to pidref_safe_fork()
Let's migrate all remaining callers of safe_fork()
to pidref_safe_fork() and get rid of safe_fork().
2026-01-02 20:08:41 +01:00
Yu Watanabe 99d0a9fdb0 Bump required minimum version of OpenSSL to 3.0.0
All major distributions have switched to OpenSSL version 3.x.
Let's drop support of OpenSSL version 1.x.

Note, OpenSSL 3.0 was released on 2021-09-07 (and will be EOL on 2026-09-07).

See also #38608.
2026-01-02 11:09:52 +09:00
Daan De Meyer aec52c1e6e string-table: Introduce DECLARE_STRING_TABLE_LOOKUP() and friends
Let's introduce these for the following two reasons:
- Using them makes sure the parameter names match between declaration
  and definition (if both use the corresponding macros).
- They make sure developers can't forget the _const_ and _pure_
  attributes for the declarations.

This commit also includes some include sorting fixes
2026-01-02 04:05:45 +09:00
Daan De Meyer daff8ea8bb tree-wide: Introduce DECLARE_TRIVIAL_REF_UNREF_FUNC() and friends 2026-01-02 04:04:19 +09:00
Yu Watanabe 93378148d4 tree-wide: normalize comment style 2025-12-15 08:50:13 +09:00
Fletcher Woodruff 65eebee9bf resolve: use strcmp when comparing DnsServer names
This fixes an issue where duplicate DNS Servers are added to
to resolv.conf files even when all fields are the same.
2025-12-12 10:12:21 +01:00
Pasquale van Heumen ca1d2ae5d6 resolve: always read /etc/resolv.conf on reload systemd-resolved
When systemd-resolved is used in resolv.conf foreign mode, reloading the
systemd-resolved daemon does not read resolv.conf when not touched since
the last time resolved read the file. Since the DNS servers list is
flushed during a reload, resolved forgets about the servers
in /etc/resolv.conf

When reloading the daemon it is expected that all configuration is
reloaded regardless of the disk timestamps.
2025-12-10 04:56:23 +09:00
Yu Watanabe 929ce35f8d meson: rework include_directories() and finding of tools (#39956)
This is a cleanup in preparation for later additions.
2025-12-02 20:07:37 +09:00
Zbigniew Jędrzejewski-Szmek 963bebd7b0 meson: add source dir to include_directories automatically
Quite often we need to specify include_directories('.'). Normally, meson
does this automatically, but we specify implicit_include_directories : false,
see 30d20907bd for an explanation.
Passing the include_directories argument through the template layers was rather
cumbersome. Let's simplify things by always including the directory of the
first source file. This makes the definitions simpler, at the cost of having an
unnecessary include directory in the list in some cases.

(Tests are excluded from this change, because they happen to not need this, but
also because some tests have source[0] which is a custom target, and we'd need
newer meson to support that.)
2025-12-01 15:35:22 +01:00
Daan De Meyer 6a9f0641cd tree-wide: Fix declaration/definition parameter name mismatches 2025-11-26 19:02:31 +09:00
Yu Watanabe caf7cb2737 SD_JSON_BUILD_PAIR() conversions with coccinelle script (#39858) 2025-11-26 16:35:35 +09:00
Daan De Meyer 9a6a8f35eb tree-wide: Small fixes for various clang-tidy warnings 2025-11-26 16:22:00 +09:00
Jelle van der Waa c12966c14f treewide: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR()
Include a coccinelle script that patches this automatically.
2025-11-24 21:05:10 +01:00
Daan De Meyer 87fbd33372 clang-tidy: Fix all remaining misc-include-cleaner violations
- Remove unused includes
- Add common false positive headers to misc-include-cleaner.IgnoreHeaders
- Add IWYU pragma keep for uncommon false positive headers
2025-11-22 10:19:41 +01:00
Jelle van der Waa 2a3f05400a resolve: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR()
No functional change, just refactoring.
2025-11-21 17:34:58 +01:00
Zbigniew Jędrzejewski-Szmek 5220bb8c3f meson: automatically add 'extract' to 'sources'
In all cases, everything that we list in 'extract', we also list in
'sources'. We can simplify things by automatically appending the first
list to the second.

In the listings, move 'extract' key right below 'sources', since now
they are both "sources", just with slightly different meanings.
2025-11-20 10:03:48 +09:00
Yu Watanabe 4f9f6a8517 resolve: voidify one function call
Fixes CID#1643235.
2025-11-16 14:06:26 +09:00
Yu Watanabe 8c236eca78 resolve: fix typo
Follow-up for 8209f4adcd.
2025-11-16 11:13:56 +09:00
Lennart Poettering 8209f4adcd resolved: add hook api
This introduces /run/systemd/resolve.hook/ as a new directory that local
(privileged) programs can bind a Varlink socket into. If they do they'll
get a method call for each attempted resolved lookup, which they can
then either process themselves (and generate new records for, or return
errors to block stuff) or let pass so that the regular resolution is
done.

Usecase for this is primarily two things:

1. in machined we can add local resolution of machine names to their IP
   addresses, similar in fashion to nss-mymachines, but working also if
   the non-NSS interfaces to name resolution are used, i.e. the local
   DNS responder. In fact, I think we should eventually remove
   nss-mymachines from our tree, as soon as this code in resolved is
   setlled.

2. in networkd we can add local resolution of names specified in DHCP
   leases we hand out.

But beyond that there should be many other uses, for example people
could write "dns firewalls" with this if they like where they
dynamically block certain names from resolution.

Fixes: #8518
2025-11-15 07:44:24 +01:00
Luca Boccassi 555d878749 varlink: say which socket failed to bind in log message
Makes it a lot easier to debug failures
2025-11-15 10:02:10 +09:00
Yu Watanabe b1a95a3aa7 resolvectl: drop an empty line between function call and error handling
Follow-up for 0536b37629.
2025-11-10 11:02:51 +09:00
Yu Watanabe f2f89678ec resolvectl: use string table
Follow-up for 0536b37629.
2025-11-10 11:02:51 +09:00
Yu Watanabe fa05718dea resolvectl: rename STATUS_PRIVATE -> STATUS_DNS_OVER_TLS 2025-11-10 11:02:51 +09:00
Yu Watanabe 6f841e58b1 resolve: do not dump cache entries when not necessary
Follow-up for 306375c368.
2025-11-10 11:02:51 +09:00