Commit Graph
2718 Commits
Author SHA1 Message Date
Yu Watanabe 13e4201dc9 Bugprone argument comments - round 3 (#37356)
Follow up from https://github.com/systemd/systemd/pull/37346
2025-05-07 01:38:34 +09:00
Daan De Meyer 38c9ca5380 tree-wide: Remove strv_from_stdarg_alloca()
It's trivial to replace all uses of this function with STRV_MAKE()
and strv_new_ap() so let's get rid of this variant.
2025-05-06 17:40:01 +02:00
Jelle van der Waa c147cd9acb treewide: correct argument comments for sd_notify 2025-05-06 16:26:47 +02:00
Daan De Meyer e4a08721c3 string-util: Remove utf8.h and alloc-util.h includes 2025-05-06 13:27:54 +02:00
Yu Watanabe 8d7f05abc8 cleanup: bugprone argument issues (#37346)
Follow up from https://github.com/systemd/systemd/pull/37281
2025-05-06 18:56:07 +09:00
Daan De Meyer 76d62b63ef main-func: Reduce transitive includes
Let's move some logic from _DEFINE_MAIN_FUNCTION() and other places
in main-func.h into functions that we implement in main-func.c to
allow moving some included headers from the header to the .c file.
2025-05-06 10:07:27 +02:00
Jelle van der Waa 160159a709 resolve: update argument comments 2025-05-05 19:32:23 +02:00
Daan De Meyer a0233fcd86 socket-util: Replace sockaddr length macros with functions
There's no need for these to be macros, let's just make them regular
functions instead.
2025-05-02 09:41:41 +02:00
Daan De Meyer 792a8bfb8a daemon-util: Rename starting/stopping message constants
Currently, NOTIFY_READY from daemon-util.h conflicts with NOTIFY_READY
from NotifyState from service.h so let's rename the constants to avoid
the conflict.
2025-05-01 14:02:17 +02:00
Daan De Meyer 40e0342e60 resolve: Simplify and optimize meson file
We were compiling the same resolved sources over and over again (up to
10 times) which had a substantial effect on build times. Let's make sure
we only compile the resolved sources once by having one static library
containing the objects for all the resolved sources.

While we're at it, get rid of unnecessary variables and includes in the
resolve meson file and generally clean things up a bit.

Before (recorded with ClangBuildAnalyzer):

**** Time summary:
Compilation (1823 times):
  Parsing (frontend):          675.5 s
  Codegen & opts (backend):     81.6 s

After:

**** Time summary:
Compilation (1585 times):
  Parsing (frontend):          553.6 s
  Codegen & opts (backend):     70.7 s
2025-05-01 12:23:43 +09:00
Yu Watanabe 366dd4a662 wait-online: handle varlink connection errors while waiting for DNS (#37283)
Currently, if systemd-networkd-wait-online is started with --dns, and
systemd-resolved is not running, it will exit with an error right away.
Similarly, if systemd-resolved is restarted while waiting for DNS
configuration, systemd-networkd-wait-online will not attempt to
re-connect, and will potentially never see subsequent DNS
configurations.

Improve this by adding socket units for the systemd-resolved varlink
servers, and re-establish the connection in systemd-networkd-wait-online
when we receive `SD_VARLINK_ERROR_DISCONNECTED`.
2025-05-01 01:55:04 +09:00
Nick Rosbrook 0fa188307b resolved: support socket activation via varlink sockets
Add two new socket units, one for each of systemd-resolved's varlink
servers:

 systemd-resolved-varlink.socket
 systemd-resolved-monitor.socket

Add logic to grab socket fds via sd_varlink_server_listen_name(), but
fallback to the existing sd_varlink_server_listen_address() calls if no
fds were given.

This will be used to make systemd-networkd-wait-online --dns more robust
against systemd-resolved restarts etc.
2025-04-30 11:12:15 -04:00
Daan De Meyer 1cf40697e3 tree-wide: Sort includes
This was done by running a locally built clang-format with
https://github.com/llvm/llvm-project/pull/137617 and
https://github.com/llvm/llvm-project/pull/137840 applied on all .c
and .h files.
2025-04-30 09:30:51 +02:00
Daan De Meyer becc0256d8 resolve: Remove unnecessary ENABLE_DNS_OVER_TLS check 2025-04-30 09:30:14 +02:00
Daan De Meyer d559f46384 basic: Add our own <netinet/in.h> and <net/if.h> headers
These glibc headers conflicts with the corresponding linux headers
(<linux/in.h> and <linux/if.h>) and impose an include order (the glibc one
has to be included before any linux header is included). This makes sorting
includes a royal pain so let's define our own versions of these headers using
various linux headers to do all the work and filling in the missing bits
ourselves.
2025-04-30 07:50:03 +02:00
Yu Watanabe 497b7a30a9 Several cleanups for reading IP address from DBus message (#37230) 2025-04-25 06:07:18 +09:00
Daan De Meyer 44e86153d1 meson: Define our own clang-tidy target
meson's target has a few issues:
- Runs on all source files regardless if they're included in the
  build or not
- Doesn't have any dependencies on generated sources which means we
  have to do a full build first before we can run clang-tidy
- Doesn't allow us to pass any extra arguments

To work around these, let's define our own clang-tidy target instead
using llvm's run-clang-tidy script. Alongside the clang-tidy target,
let's start keeping track of all generated sources which we make the
clang-tidy target depend on. We also add a new target which will only
generate source files which is useful for setting up the source tree
for running code analysis against it.
2025-04-24 12:36:36 +02:00
Yu Watanabe 06a5d24d78 resolvectl: skip reading remaining elements when an invalid address is specified
Previous code assumed that both family and address are read when
-EINVAL, hence the following read of port and name could succeed.

Let's drop the assumption, and skip reading remaining elements.

No functional change, just refactoring and preparation for later change.
2025-04-24 10:11:07 +09:00
Yu Watanabe 90293a9583 resolvectl: make three booleans for read_dns_server_one() into one enum 2025-04-24 10:11:07 +09:00
Daan De Meyer 68527d3051 resolved: Remove circular header dependencies 2025-04-23 10:33:37 +02:00
Daan De Meyer 834dc38310 resolve: Move implementations of some functions to resolved-dns-packet.c
These depend on a full definition of DnsResourceRecord which we want
to forward declare in the next commit, so let's move the implementation
of these functions to the implementation file and make them lowercase.
2025-04-23 10:33:37 +02:00
Daan De Meyer 6f502df478 resolve: Move two functions from resolved-conf.h to resolved-dns-server.h
Preparation for getting rid of circular header dependencies.
2025-04-23 10:33:37 +02:00
Daan De Meyer 3bb398c299 resolve,import: always use openssl (#36937) 2025-04-18 15:30:33 +02:00
Daan De Meyer 93a1f7921a basic: Stop including log.h in macro.h
Now that the necessary functions from log.h have been moved to macro.h,
we can stop including log.h in macro.h. This requires modifying source
files all over the tree to include log.h instead.
2025-04-18 14:19:15 +02:00
Daan De Meyer b14f74f9ab basic: Move trivial cleanup/ref/unref macros from macro.h to memory-util.h
Let's keep macro.h for the extremely generic macros that don't fit anywhere
else. Since CLEANUP_ARRAY() is already in memory-util-fundamental.h, we can
make a good case for moving the other cleanup macros in there as well.
2025-04-18 13:59:04 +02:00
MaxHearnden 49ff90c70d resolve: query the parent zone for DS records
RFC 4035 Section 4.2 requires that missing DS records are queried for in
the parent zone rather than the child zone, the old behaviour could
cause subdomains under home.arpa (RFC 8375) to fail validation.

This commit assumes that QDCOUNT = 1 as per RFC 9619

Fixes https://github.com/systemd/systemd/issues/19496
2025-04-17 03:24:11 +09:00
Yu Watanabe dcf1c14b95 resolve: use set_dump_sorted() at one more place 2025-04-16 08:16:21 +09:00
Yu Watanabe a0fa3f1616 resolve: fix memleak
Follow-up for 5c274555c3.
2025-04-15 23:34:49 +01:00
Yu Watanabe 9fdb01ed66 resolve: hash_ops related cleanups (#37116) 2025-04-15 22:31:57 +09:00
Yu Watanabe d50cfa98aa tree-wide: IFA_FLAGS is supported since kernel v3.14
Now our baseline on the kernel is v5.4.
Let's unconditionally use the IFA_FLAGS attribute, and drop the getter
and setter for the deprecated header element.

Continuation of 29c2d4e158.
2025-04-15 03:41:16 +09:00
Yu Watanabe cc983fc9dc resolve: drop code for supporting old kernels (<3.2)
Now our baseline on the kernel is 5.4.

Note, the removed code triggered assert_return() in
sd_event_source_set_description().
2025-04-14 22:26:40 +09:00
Yu Watanabe d6c8db650d resolved-dns-trust-anchor: use hash_ops with destructor for managing DnsAnswer 2025-04-13 09:58:49 +09:00
Yu Watanabe 442ac1b1b0 resolved-dns-trust-anchor: use hash_ops with destructor for managing RRs 2025-04-13 09:58:49 +09:00
Yu Watanabe f7880e58f2 resolved-dns-scope: use hash_ops with destructor for conflict_queue 2025-04-13 09:58:49 +09:00
Yu Watanabe 5c274555c3 resolve: use dns_name_hash_ops_free for dnssec negative trust anchor 2025-04-13 09:58:49 +09:00
Yu Watanabe e9d4b88b81 resolve,import: always use openssl
This deprecate cryptolib meson option.
2025-04-02 05:47:47 +09:00
Yu Watanabe 0baf937763 resolve: rename resolved-dnstls-openssl.c -> resolved-dnstls.c
and merge resolved-dnstls.h and resolved-dnstls-openssl.h.
2025-04-02 05:30:28 +09:00
Yu Watanabe b1c3f57e76 resolve: always use openssl as backend of DNS-over-TLS
This drops support for dns-over-tls=gnutls meson option.
2025-04-02 05:20:40 +09:00
Yu Watanabe 3cf6a3a3d4 tree-wide: check more log message format in log_struct() and friends
This introduce LOG_ITEM() macro that checks arbitrary formats in
log_struct().
Then, drop _printf_ attribute from log_struct_internal(), as it does not
help so much, and compiler checked only the first format string.

Hopefully, this silences false-positive warnings by Coverity.
2025-03-19 01:56:48 +09:00
Zbigniew Jędrzejewski-Szmek 1ae9b0cfa8 basic/glyph-util: rename "special glyph" to just "glyph"
Admittedly, some of our glyphs _are_ special, e.g. "O=" for SPECIAL_GLYPH_TOUCH ;)
But we don't need this in the name. The very long names make some invocations
very wordy, e.g. special_glyph(SPECIAL_GLYPH_SLIGHTLY_UNHAPPY_SMILEY).
Also, I want to add GLYPH_SPACE, which is not special at all.
2025-03-15 14:40:39 +01:00
Michael Catanzaro 780f320229 resolve: add warning comment to config file
There are way too many users configuring the DNS= setting by mistake,
because what it seems to do is different from what it actually does. We
do not have consensus to change its behavior, so let's at least add a
warning comment.

Fixes #33973
2025-03-13 04:12:18 +09:00
Lennart Poettering 98b7c5e2f2 basic: move gethostname_full() from basic/hostname-util.c → shared/hostname-setup.c
In one of the next commits we'd like to introduce a concept of
optionally hashing the hostname from the machine ID. For that we we need
to optionally back gethostname_full() by code involving sd-id128, hence
let's move it from src/basic/ to src/shared/, since only there we are
allowed to use our public APIs.
2025-03-11 17:54:44 +01:00
Yu Watanabe c0cc01de8a meson: use install_symlink() where applicable
Now our baseline of meson is 0.62, hence install_symlink() can be used.

Note, install_symlink() implies install_emptydir() for specified
install_dir. Hence, this also drops several unnecessary
install_emptydir() calls.

Note, the function currently does not support 'relative' and 'force' flags,
so several 'ln -frsT' inline calls cannot be replaced.
2025-03-10 02:41:40 +09:00
Yu Watanabe 5c9feb2d6e tree-wide: drop unnecessary break in default branch 2025-03-06 11:42:20 +01:00
Lennart Poettering facc9439a7 dns-stream: only read DNS packet data if we identified the peer properly
If we use TCP fastopen to connect to a DNS server via TCP, and it
responds really quickly between our connection attempt and our immediate
check back, then we have not identified the peer yet, and will not be
able to use the peer metadata to fill in our packet info.

Let's fix that, and simply not read from the socket until identification
is complete.

Fixes: #34956
2025-03-04 12:33:53 +00:00
Lennart Poettering 8113361e82 resolved: pick up new DNSSEC KSC from 2024
Import thew new key from https://data.iana.org/root-anchors/root-anchors.xml.

The old one remains valid, as per provided data.

Fixes: #36260
2025-03-04 11:51:34 +00:00
Yu Watanabe aa14f19398 basic/linux: import capability.h from kernel 6.14-rc4 2025-03-04 02:24:49 +09:00
Yu Watanabe 0592f3f413 resolve: refuse ResolveService method if SRV is filtered
Follow-up for 81ae2237c1.
2025-02-16 22:54:56 +09:00
Yu Watanabe 9ec25fba5a resolve: if both A and AAAA are refused, do not resolve address when resolving service
Similarly, set NO_TXT flag if TXT is filtered.

Follow-up for 81ae2237c1.
Fixes https://github.com/systemd/systemd/pull/36353#issuecomment-2659558382.
2025-02-16 22:54:00 +09:00
Yu Watanabe 3c31cc3981 resolve: allow to specify SD_RESOLVED_NO_SEARCH flag in ResolveRecord
The varlink method io.systemd.Resolve.ResolveRecord already accepts the
flag. Let's also the bus method accept the flag, for consistency.
2025-02-16 22:41:10 +09:00