summaryrefslogtreecommitdiff
path: root/src/timesync
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: copy timestamp data from cmsgYu Watanabe2023-04-161-1/+1
| | | | | | | On RISCV32, time_t is 64bit and size_t is 32bit, hence the timestamp data in message header may not be aligned. Fixes #27241.
* timesync: drop unnecessary initializationYu Watanabe2023-04-141-1/+1
|
* conf: replace config_parse_many_nulstr() with config_parse_config_file()Franck Bui2023-03-141-8/+3
| | | | | | | | | | | | | | | | | 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.
* meson: Introduce userspace depJan Janssen2023-03-101-0/+1
| | | | This will help in a later commit to separate userspace from EFI builds.
* timesync: stop re-sync on network configuration change when no link servers ↵Chitoku2023-03-081-2/+2
| | | | | | | | | 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 e05dd7718d0b32e039c9e0f7bf3875079d1a359d.
* timesyncd: hook up memory pressure + sigrtmin18Lennart Poettering2023-03-012-1/+7
|
* meson: Use dicts for test definitionsJan Janssen2023-02-211-4/+8
| | | | | | | 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.
* meson: Do not include headers in source listsJan Janssen2023-01-241-5/+2
| | | | | | 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
* timesyncd: make sure to update mtime of clock file on each bootLennart Poettering2023-01-201-0/+51
| | | | | | | | 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.
* timesyncd: modernize load_clock_timestamp() a bitLennart Poettering2023-01-201-29/+26
| | | | Let's log more.
* timesyncd: write structured log messages whenever we bump the clock based on ↵Lennart Poettering2023-01-201-8/+15
| | | | | | | | | | | | 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.
* basic: Use statement expressions more in list.hDaan De Meyer2023-01-081-1/+1
| | | | | Let's use statement expressions to return values instead of passing in return arguments to the LIST macros.
* tree-wide: use -EBADF moreYu Watanabe2022-12-211-1/+1
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-192-3/+3
| | | | | | | | | | | | | | | | -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.
* Merge pull request #25743 from yuwata/timesync-ipv6Yu Watanabe2022-12-151-6/+7
|\ | | | | timesync: ignore IPv6 addresses when the kernel does not support it
| * timesync: ignore IPv6 addresses when the kernel does not support IPv6Yu Watanabe2022-12-151-5/+6
| | | | | | | | Fixes #25728.
| * timesync: downgrade log message about unsupported address familyYu Watanabe2022-12-141-1/+1
| | | | | | | | As this is mostly not user's fault.
* | timesync: Keep trying to connect even if the socket cannot be openedFelix Riemann2022-12-151-2/+4
|/ | | | | | | | 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.
* tree-wide: make constant ratelimit compound actually constLennart Poettering2022-11-221-1/+1
| | | | | | 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.
* Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | | 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.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | 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.
* sd-network: make sd_network_link_get_dns() or friends return -ENODATAYu Watanabe2022-09-271-1/+1
| | | | To make them consistent with other functions.
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-132-27/+11
|
* tree-wide: Fix format specifier warnings for %xJan Janssen2022-08-301-1/+1
| | | | | | 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.
* tree-wide: Use correct format specifiersJan Janssen2022-08-301-4/+4
| | | | gcc will complain about all these with -Wformat-signedness.
* Use https for freedesktop.orgMichael Biebl2022-06-282-2/+2
| | | | grep -l -r http:// | xargs sed -E -i s'#http://(.*).freedesktop.org#https://\1.freedesktop.org#'
* tree-wide: use LOG_MESSAGE() where possibleZbigniew Jędrzejewski-Szmek2022-05-111-1/+2
| | | | | | | 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.
* timesync: update to use new-style sd-bus macrosSonali Srivastava2022-04-111-6/+5
|
* timesync: be explicit in the integer check of poll_interval_usecDaniel Mack2022-04-091-1/+1
|
* timesyncd: clean up server_name_new()Daniel Mack2022-04-091-14/+16
| | | | | Use `LIST_APPEND()` in favour of `LIST_FIND_TAIL()` + `LIST_INSERT_AFTER()`. Also use a switch/case statement instead of if/else if.
* timesyncd: add address type information to debug logDaniel Mack2022-04-092-1/+13
| | | | | | | 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.
* timesyncd: add RUNTIME serversDaniel Mack2022-04-098-10/+139
| | | | | | | | | | | 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.
* timesync: export manager_is_connected()Daniel Mack2022-04-092-1/+4
| | | | This function use useful from other files, so let's export it.
* meson: also allow setting GIT_VERSION via templatesZbigniew Jędrzejewski-Szmek2022-04-051-1/+1
| | | | | | | | | 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.
* time-util: assume CLOCK_BOOTTIME always existsLennart Poettering2022-03-281-7/+7
| | | | | | | | 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.
* inotify-util: declare iterator in FOREACH_INOTIFY_EVENT()Yu Watanabe2022-03-241-2/+1
| | | | | 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.
* Merge pull request #22740 from yuwata/listZbigniew Jędrzejewski-Szmek2022-03-213-5/+2
|\ | | | | tree-wide: declare iterator of LIST_FOREACH() in the loop
| * strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-1/+0
| | | | | | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
| * list: make LIST_FOREACH() and LIST_FOREACH_BACKWARDS() saferYu Watanabe2022-03-191-1/+1
| |
| * list: declare iterator of LIST_FOREACH() in the loopYu Watanabe2022-03-193-3/+1
| |
* | timesyncd: improve log message whe getting a reply from serverLennart Poettering2022-03-181-3/+2
| | | | | | | | | | | | | | | | 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.
* | timesyncd: generate a structure log message the first time we set the clock ↵Lennart Poettering2022-03-182-0/+21
| | | | | | | | | | | | | | | | | | | | 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.
* | timesyncd: add debug logging in case we can't touch ↵Lennart Poettering2022-03-181-1/+3
| | | | | | | | /run/systemd/timesync/synchronized
* | timesyncd: when updating timestamp file, use best time we know, instead of ↵Lennart Poettering2022-03-181-5/+17
| | | | | | | | | | | | | | 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.
* | timesyncd: rename bool 'good' → 'talking'Lennart Poettering2022-03-182-4/+4
| | | | | | | | | | THe name is just too generic. Let's pick a name that makes clear that this is about successful communication.
* | timesyncd: don't abort packet handling if we can't save the timestamp to diskLennart Poettering2022-03-181-3/+1
| | | | | | | | | | This should not be a fatal error, and it isn't in the other place we call this.
* | sd-event: add a single implementation of an event source that runs on clock ↵Lennart Poettering2022-03-182-11/+4
| | | | | | | | | | | | | | | | | | | | 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.
* | timesyncd: move stuff that is not about setting the clock out of ↵Lennart Poettering2022-03-181-8/+7
| | | | | | | | | | | | | | | | | | | | | | 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.
* | timesyncd: use CMSG_FIND_DATA() macro where appropriateLennart Poettering2022-03-181-15/+2
| |
* | timesyncd: merge some variable declarationsLennart Poettering2022-03-182-7/+3
| |