Commit Graph
311 Commits
Author SHA1 Message Date
Yu Watanabe 789f5c6f70 tree-wide: copy timestamp data from cmsg
On RISCV32, time_t is 64bit and size_t is 32bit, hence the timestamp
data in message header may not be aligned.

Fixes #27241.
2023-04-16 13:26:58 +09:00
Yu Watanabe 924937cbc0 timesync: drop unnecessary initialization 2023-04-14 13:49:35 +09:00
Franck Bui 07e0ffc823 conf: replace config_parse_many_nulstr() with config_parse_config_file()
All daemons use a similar scheme to read their main config files and theirs
drop-ins. The main config files are always stored in /etc/systemd directory and
it's easy enough to construct the name of the drop-in directories based on the
name of the main config file.

Hence the new helper does that internally, which allows to reduce and simplify
the args passed previously to config_parse_many_nulstr().

Besides the overall code simplification it results:

  16 files changed, 87 insertions(+), 159 deletions(-)

it allows to identify clearly the locations in the code where configuration
files are parsed.
2023-03-14 03:31:21 +09:00
Jan Janssen 9214828313 meson: Introduce userspace dep
This will help in a later commit to separate userspace from EFI builds.
2023-03-10 11:40:14 +01:00
Chitoku 0f9c8d0291 timesync: stop re-sync on network configuration change when no link servers are configured (#26708)
This commit fixes an issue where systemd-timesyncd re-synchronizes the
system clock every time the network configuration is updated, no matter
whether link servers are actually changed.

Fixes a bug introduced by e05dd7718d.
2023-03-08 19:52:55 +09:00
Lennart Poettering 6e6e45076b timesyncd: hook up memory pressure + sigrtmin18 2023-03-01 09:43:23 +01:00
Jan Janssen 822cd3ff25 meson: Use dicts for test definitions
Although this slightly more verbose it makes it much easier to reason
about. The code that produces the tests heavily benefits from this.

Test lists are also now sorted by test name.
2023-02-21 15:10:26 +01:00
Jan Janssen 4a7ee0a521 meson: Do not include headers in source lists
Meson+ninja+compiler do this for us and are better at it.

https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
2023-01-24 22:04:03 +01:00
Lennart Poettering 1acb4f6157 timesyncd: make sure to update mtime of clock file on each boot
Let's make sure the timestamp file's mtime is guaranteed to change for
each boot, so that it is a useful indicator of time. Or in other words
this gurantees that systemd-timesyncd.service acts as a new kind of
milestone: that time definitely progressed on this boot even the machine
died abnormally imediately after.
2023-01-20 22:33:05 +01:00
Lennart Poettering 84447fe79d timesyncd: modernize load_clock_timestamp() a bit
Let's log more.
2023-01-20 22:33:05 +01:00
Lennart Poettering 29920c5b1f timesyncd: write structured log messages whenever we bump the clock based on disk timestamp
It's useful being able to easily detect if a disk-based clock bump was
done, let's make it a structure message, the same way as acquiring an
NTP fix already is.

Also, set the clock to 1 µs further than the timestamp from the disk,
after all we know that that timestamp was current when it was written,
hence it can't be the right one right now anymore.
2023-01-20 22:33:04 +01:00
Daan De Meyer cc232fa094 basic: Use statement expressions more in list.h
Let's use statement expressions to return values instead of passing
in return arguments to the LIST macros.
2023-01-08 16:31:15 +01:00
Yu Watanabe 5bb1d7fbab tree-wide: use -EBADF more 2022-12-21 01:50:33 +09:00
Zbigniew Jędrzejewski-Szmek 254d1313ae tree-wide: use -EBADF for fd initialization
-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.
2022-12-19 15:00:57 +01:00
Yu Watanabe 993681def8 Merge pull request #25743 from yuwata/timesync-ipv6
timesync: ignore IPv6 addresses when the kernel does not support it
2022-12-15 12:57:54 +09:00
Yu Watanabe 713e6e631d timesync: ignore IPv6 addresses when the kernel does not support IPv6
Fixes #25728.
2022-12-15 03:30:13 +09:00
Felix Riemann 9b4e04f0cd timesync: Keep trying to connect even if the socket cannot be opened
This makes sure that after a server could not be contacted due to a
socket error, other (possibly working) NTP servers in the list of
configured NTP servers are (re-)tried.

Fixes #25728.
2022-12-15 02:21:25 +09:00
Yu Watanabe 7a12328735 timesync: downgrade log message about unsupported address family
As this is mostly not user's fault.
2022-12-14 23:55:21 +09:00
Lennart Poettering 7d1e61cab6 tree-wide: make constant ratelimit compound actually const
The compiler should recognize that these are constant expressions, but
let's better make this explicit, so that the linker can safely share the
initializations all over the place.
2022-11-22 01:30:55 +01:00
Zbigniew Jędrzejewski-Szmek 28db6fbff1 Rename def.h to constants.h
The name "def.h" originates from before the rule of "no needless abbreviations"
was established. Let's rename the file to clarify that it contains a collection
of various semi-related constants.
2022-11-08 18:21:10 +01:00
Zbigniew Jędrzejewski-Szmek 3ae6b3bf72 basic: rename util.h to logarithm.h
util.h is now about logarithms only, so we can rename it. Many files included
util.h for no apparent reason… Those includes are dropped.
2022-11-08 18:21:10 +01:00
Yu Watanabe e05dd7718d sd-network: make sd_network_link_get_dns() or friends return -ENODATA
To make them consistent with other functions.
2022-09-27 10:42:31 +09:00
David Tardon 995340074e tree-wide: use ASSERT_PTR more 2022-09-13 08:13:27 +02:00
Jan Janssen 5570a09702 tree-wide: Fix format specifier warnings for %x
Unfortunately, hex output can only be produced with unsigned types. Some
cases can be fixed by producing the correct type, but a few simply have
to be cast. At least casting makes it explicit.
2022-08-30 12:03:33 +02:00
Jan Janssen c0f86d66f3 tree-wide: Use correct format specifiers
gcc will complain about all these with -Wformat-signedness.
2022-08-30 12:03:28 +02:00
Michael Biebl 41d6f3bf4d Use https for freedesktop.org
grep -l -r http:// | xargs sed -E -i s'#http://(.*).freedesktop.org#https://\1.freedesktop.org#'
2022-06-28 13:10:05 +02:00
Zbigniew Jędrzejewski-Szmek 92663a5e5b tree-wide: use LOG_MESSAGE() where possible
Also break some long lines for more uniform formatting. No functional change.

I went over all log_struct, log_struct_errno, log_unit_struct,
log_unit_struct_errno calls, and they seem fine.
2022-05-11 16:47:40 +02:00
Sonali Srivastava e3d76a8efd timesync: update to use new-style sd-bus macros 2022-04-11 10:50:33 +02:00
Daniel Mack a08ea29596 timesync: be explicit in the integer check of poll_interval_usec 2022-04-09 10:23:14 +09:00
Daniel Mack feb219c997 timesyncd: clean up server_name_new()
Use `LIST_APPEND()` in favour of `LIST_FIND_TAIL()` + `LIST_INSERT_AFTER()`.
Also use a switch/case statement instead of if/else if.
2022-04-09 10:23:14 +09:00
Daniel Mack 5dfb11097d timesyncd: add address type information to debug log
When looking at debug logs, it's helpful to know what type of server
address has been added.

For that, introduce a string lookup table for the ServerType type.
2022-04-09 10:23:14 +09:00
Daniel Mack 57b82eaaca timesyncd: add RUNTIME servers
This new server type can only be set at runtime through a D-Bus method
and is exposed for reading through a D-Bus property.

`CAP_NET_ADMIN` and a PolKit acknowledge is required for setting
runtime servers.

Entries submitted that way are used before system and link servers
are being looked at.
2022-04-09 10:23:14 +09:00
Daniel Mack f1b42a0b23 timesync: export manager_is_connected()
This function use useful from other files, so let's export it.
2022-04-09 10:23:14 +09:00
Zbigniew Jędrzejewski-Szmek 8f04a1ca2b meson: also allow setting GIT_VERSION via templates
GIT_VERSION is not available as a config.h variable, because it's rendered
into version.h during builds. Let's rework jinja2 rendering to also
parse version.h. No functional change, the new variable is so far unused.

I guess this will make partial rebuilds a bit slower, but it's useful
to be able to use the full version string.
2022-04-05 22:18:31 +02:00
Lennart Poettering ba4e0427e9 time-util: assume CLOCK_BOOTTIME always exists
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.
2022-03-28 16:55:41 +02:00
Yu Watanabe 00adc340bb inotify-util: declare iterator in FOREACH_INOTIFY_EVENT()
This also makes the macro check if the event is actually in the buffer,
and if it is not, then log about that and finish the loop.
2022-03-24 23:12:34 +00:00
Zbigniew Jędrzejewski-Szmek b0a5e59622 Merge pull request #22740 from yuwata/list
tree-wide: declare iterator of LIST_FOREACH() in the loop
2022-03-21 10:52:03 +01:00
Yu Watanabe de010b0b2e strv: make iterator in STRV_FOREACH() declaread in the loop
This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
2022-03-19 08:33:33 +09:00
Yu Watanabe 80a226b26b list: make LIST_FOREACH() and LIST_FOREACH_BACKWARDS() safer 2022-03-19 08:10:29 +09:00
Yu Watanabe 03677889f0 list: declare iterator of LIST_FOREACH() in the loop 2022-03-19 08:10:29 +09:00
Lennart Poettering 922a650829 timesyncd: improve log message whe getting a reply from server
The message is misleading: it's not about synchronization but about
successful communicaiton. And it's not about "initial", but only about
first contact since we siwtched to this server.

Let's hence reword the message a bit.
2022-03-18 23:54:18 +01:00
Lennart Poettering b016e77efd timesyncd: generate a structure log message the first time we set the clock correctly
Usecase: later on we can use this to retroactively adjust log output in
journalctl or similar on systems lacking an RTC: we just have to search
for this sructured log message that indicates the first sync point and
can then retroactively adjust the incorrect timestamps collected before
that.
2022-03-18 23:54:05 +01:00
Lennart Poettering 1aa7ca2241 timesyncd: add debug logging in case we can't touch /run/systemd/timesync/synchronized 2022-03-18 23:54:01 +01:00
Lennart Poettering 1f129b7fb7 timesyncd: when updating timestamp file, use best time we know, instead of system clock
We adjust the system clock slowly after all, even if we know a more
accurate time. Use the accurate time for the timestamp.
2022-03-18 23:53:58 +01:00
Lennart Poettering 87057128e6 timesyncd: rename bool 'good' → 'talking'
THe name is just too generic. Let's pick a name that makes clear that
this is about successful communication.
2022-03-18 23:53:54 +01:00
Lennart Poettering 20c1a21066 timesyncd: don't abort packet handling if we can't save the timestamp to disk
This should not be a fatal error, and it isn't in the other place we
call this.
2022-03-18 23:53:50 +01:00
Lennart Poettering ec75e8e07a sd-event: add a single implementation of an event source that runs on clock 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.
2022-03-18 23:53:34 +01:00
Lennart Poettering 7cb08ea80f timesyncd: move stuff that is not about setting the clock out of manager_adjust_clock()
Let's make sure manager_adjust_clock() is purely about setting the
clock, and nothing else.

Let's clean up logging this way. manager_adjust_clock() now won#t log
about errors, but the caller can safely do that, and do with the right
log message string.
2022-03-18 23:53:31 +01:00
Lennart Poettering adc07c2bf5 timesyncd: use CMSG_FIND_DATA() macro where appropriate 2022-03-18 23:53:27 +01:00
Lennart Poettering 5ba674cca5 timesyncd: merge some variable declarations 2022-03-18 23:53:24 +01:00