Commit Graph
100 Commits
Author SHA1 Message Date
Yu WatanabeandFranck Bui 331aa7aa15 udev-node: optimize device node symlink creation
If multiple devices requested the same device node symlink with the same
priority, then previously we read O(N^2) of files saved in
/run/udev/links.

This makes if the requested symlink already exists with equal or higher
priority, then the symlink is kept, and skip to read all existing files,
except for one related to the current device node, in /run/udev/links.
Hence, the total amount of file read becomes O(N).

This improves performance of testcase_simultaneous_events_2 added by the
previous commit about 30%.
Before (32.8 sec):
```
 ## 3 iterations start: 11:13:44.690953163
 ## 3 iterations end: 11:14:17.493974927
```
After (23.8 sec):
```
 ## 3 iterations start: 11:17:53.869938387
 ## 3 iterations end: 11:18:17.624268345
```

This is based on the idea and analysis by Franck Bui.

Replaces #25839.

Co-authored-by: Franck Bui <fbui@suse.com>
2023-06-13 22:51:00 +02:00
Yu Watanabe 2824385c4e test: drop test for IFLA_NUM_RX_QUEUES
The attribute is not included in the netlink message if the kernel
built with CONFIG_RPS disabled.

Fixes #27969.
2023-06-12 09:37:11 +02:00
Yu Watanabe 628d56bcf6 Merge pull request #27980 from bluca/tests
add unit tests for *DirectorySymlink= and deserialize_strv helper
2023-06-10 17:46:10 +09:00
Yu Watanabe 3db7f3c58c Merge pull request #27912 from mrc0mmand/cryptsetup-tests
test: add a couple more tests for systemd-cryptsetup
2023-06-06 03:34:59 +09:00
Yu Watanabe 308b189511 chase: fix triggering assertion 2023-06-05 10:22:47 +02:00
Yu Watanabe 3991f35fbd chase: handle root path more carefully in chase_and_open()
chase_and_open() may be called with relative root path.
2023-06-05 15:50:46 +09:00
Yu Watanabe c0dff4205b test: move intro() near DEFINE_TEST_MAIN_WITH_INTRO() 2023-06-05 14:49:54 +09:00
Yu Watanabe d7aef22724 test: add more test cases about path_startswith() 2023-06-05 14:49:54 +09:00
Yu Watanabe d1e96f2f6c test-kernel-install: add tests for --entry-token= 2023-06-05 14:23:54 +09:00
Yu Watanabe 1fd90ed3ed kernel-install: introduce --entry-token= option
For consistency with bootctl.
2023-06-05 14:23:54 +09:00
Yu Watanabe 88e94af2ab test-kernel-install: add tests for --make-entry-directory= 2023-06-05 14:23:54 +09:00
Yu Watanabe b79621aa99 kernel-install: introduce --make-entry-directory= option
For consistency with bootctl. However, unlike the same option for
bootctl, defaults to 'auto' for backward compatibility.
2023-06-05 14:23:54 +09:00
Yu Watanabe 4cff5e92a9 kernel-install: add --esp-path= and --boot-path= options
Then, kernel-install takes one more step for compatibility with bootctl.
2023-06-05 14:23:54 +09:00
Yu Watanabe 1fd2af1ab8 kernel-install: also parse KERNEL_INSTALL_LAYOUT from /etc/machine-info
For consistency with bootctl.
2023-06-05 14:23:54 +09:00
Yu Watanabe f7665b7f6c kernel-install: make inspect command optionally take kernel image
If the kernel image is provided, then we can inspect the kernel image
and may determine the layout based on the kernel image type.
2023-06-05 14:23:54 +09:00
Yu Watanabe 42551ea7e9 kernel-install: rewrite in C
This is mostly a one-to-one translation of kernel-install.sh, except for
the followings:
- BOOT_ROOT is searched with find_{esp,xbootldr}_and_warn().
- entry token is searched with boot_entry_token_ensure().
- inspect command verboses more information, e.g. found plugins,
  environment variables explicitly passed to plugins, arguments passed
  to plugins.
- paths specified in $KERNEL_INSTALL_PLUGINS must be absolute.
- LC_COLLATE is set to C.UTF-8 (or any specified on build time).

By writing kernel-install C, we can share the code used by bootctl or
so, and can introduce --root and/or --image options later.
2023-06-05 14:23:54 +09:00
Yu Watanabe 1bf3dd4153 udev: downgrade log level about style issues
And add --no-style switch that make style issues not critical.
2023-06-05 11:37:26 +09:00
Yu Watanabe 2ef0959fbe test: drop unnecessary copy of expected output 2023-06-05 11:21:28 +09:00
Yu Watanabe 4134614fc0 udev-rules: terminate log messages with period 2023-06-05 11:21:28 +09:00
Yu Watanabe c507c81ee7 Merge pull request #27907 from mrc0mmand/quick-test-tweaks
test: a couple of tweaks for recent CI fails
2023-06-04 05:22:53 +09:00
Yu Watanabe 45a6a2aace sd-journal: fix assignment of tail entry offset
Fixes a bug introduced by 206f0f397e.
2023-06-01 17:04:10 +02:00
Yu Watanabe 17bd68ca74 Merge pull request #27874 from keszybz/test-bus-server-shortening
Simplify the code in test-bus-server
2023-06-01 21:10:55 +09:00
Yu Watanabe 041d8ad857 Merge pull request #27796 from yuwata/memstream-util
util: introduce memstream-util
2023-06-01 12:07:17 +09:00
Yu Watanabe 2485b7e2b8 tree-wide: use memstream-util 2023-06-01 06:48:47 +09:00
Yu Watanabe abe72100cf util: introduce memstream-util
There is many pitfalls in using memstream.
Let's introduce a wrapper to make us safely use it.
2023-06-01 06:48:43 +09:00
Yu Watanabe 24b0c6c2c9 calendarspec: rename arguments 2023-06-01 06:47:48 +09:00
Yu Watanabe a694747d45 elf-util: rename stack_context_destroy() -> stack_context_done() 2023-06-01 06:47:48 +09:00
Yu Watanabe 3256e2027b sd-bus: rename introspect_free() -> introspect_done 2023-06-01 06:47:48 +09:00
Yu Watanabe 5d2a48da12 tree-wide: use _cleanup_set_free_ and friends
Instead of _cleanup_(set_freep) or so.
2023-06-01 06:47:48 +09:00
Yu Watanabe 64377c6089 oomd: drop unused key 2023-06-01 06:47:48 +09:00
Yu Watanabe cc4d38b14b core/cgroup: fix setting SocketBindAllow=/SocketBindDeny= through DBus 2023-06-01 06:47:48 +09:00
Yu Watanabe 322bda8241 Merge pull request #27826 from yuwata/network-link-ready-without-ndisc-when-has-static-address
network: do not request dynamic addressing protocols finished when at…
2023-06-01 06:29:55 +09:00
Yu Watanabe 2f96a29c2c wait-online: request that at least one managed online interface exists
Fixes a regression caused by ab3aed4a03.

I thought the commit does not cause any severe regression. However,
drivers for network interfaces may be loaded later. So, we should wait
if no network interface is found.

Fixes #27822.
2023-05-31 22:12:03 +02:00
Yu Watanabe 9e7d91ed97 network: do not request dynamic addressing protocols finished when at least one static address is configured
The setting IPv6AcceptRA= is defaults to yes, hence, even if a .network
file for an interface has static IP address configuration, it may takes
few seconds for the interface being configured state, as NDisc for the
interface needs to be finished. That makes wait-online.service
needlessly slow. Typically, such delay is not necessary for statically
configured networks.

Let's make the required condition slightly relaxed; if a .network file
has static IP address configurations, then let's make the matching
interface enter the 'configured' state soon after the static addresses
configured on the interface.

Note, this does not change the default for IPv6AcceptRA=, hence, NDisc
still runs on interfaces by default. So, addresses, routes, DNS servers,
and so on based on RA will be assigned on interfaces later.

Strictly speaking, this breaks backward compatibility, but the previous
behavior is not clearly documented. If a user requested both static
IPv4 address and IPv6 SLAAC address configured before an interface being
entered to the 'configured' state, then '--ipv6' for wait-online can be
used. So, the behavior change should not cause severe regression.

Closes #27779.
2023-05-30 17:39:11 +09:00
Yu Watanabe 195b83edf8 network: require DHCP protocol to be finished when an address of delegated prefix is assigned 2023-05-30 17:39:05 +09:00
Yu Watanabe 5f950e5621 network: rewrite dynamic addressing protocol checkers in link_check_ready()
Notable change is,
- UseAddress=no in [DHCPv6],
- Assign=no in [DHCPPrefixDelegation], and
- UseAutonomousPrefix=no in [IPv6AcceptRA]
are gracefully handled now.
2023-05-30 16:22:54 +09:00
Yu Watanabe 7b975e9f45 basic/syscall: update syscall list
Only notable change is that memfd_secret is now defined on s390(x).
2023-05-29 06:59:10 +08:00
Yu Watanabe 80ec3db5c7 journalctl: fix --follow with non-matching filter
When there is no matching entry stored in journal, then initial call of
`sd_journal_previous()` following `sd_journal_seek_tail()` returns
zero, and does not move the read pointer.
In the main loop, on every journal event, we call `sd_journal_next()`,
even though the current location is tail, and it takes no effect.

In such a case, we need to call `sd_journal_previous()` instead of
`sd_journal_next()`.
2023-05-28 23:53:58 +09:00
Yu Watanabe b78f9481bc sd-journal: introduce sd_journal_step_one()
After the commit 7a4ee86161,
sd_journal_next() following sd_journal_seek_tail() takes no-op,
and we need to call sd_journal_previous(). This may be useful in
some cases, e.g. to fix the issue explained in the previous commit.
2023-05-28 23:53:18 +09:00
Yu Watanabe fb35feae97 test: add testcase for 'journalctl --follow --cursor-file='
Also, add a FIXME comment to illustrate the issue uncovered after by
7a4ee86161.
2023-05-28 14:52:32 +09:00
Yu Watanabe 24d633e438 journalctl: also update cursor with --follow
Fixes #26746.
2023-05-28 14:52:32 +09:00
Yu Watanabe 713342d9b0 journalctl: replace ppoll() loop with sd_event_loop()
No functional change, just refactoring.
2023-05-28 14:52:32 +09:00
Yu Watanabe e4c4a9db87 journalctl: split out show()
No functional changes, just refactoring.
2023-05-28 14:52:32 +09:00
Yu Watanabe 8c12d3586a journalctl: split out update_cursor()
No functional change, just refactoring.
2023-05-28 14:52:32 +09:00
Yu Watanabe 2ce9a07b34 journalctl: split out action_list_fields()
No functional change, just refactoring.
2023-05-28 14:52:32 +09:00
Yu Watanabe 3f2203f64d journalctl: fix --no-tail handling
Fixes a bug introduced by 62f21ec91a.
2023-05-28 14:52:32 +09:00
Yu Watanabe 20e933ae74 journalctl: use correct variable to check if --since is specified 2023-05-28 14:52:32 +09:00
Yu Watanabe 4f0165fd34 journalctl: always initialize global variables
That's not necessary, as they are initialized with zero, but for safety
and readability.
2023-05-28 14:52:32 +09:00
Yu Watanabe 9e39cb2855 Merge pull request #27721 from yuwata/journalctl-cleanup
journalctl: split get_boots() into three
2023-05-27 07:59:22 +09:00
Yu Watanabe e44f06065b journalctl: split get_boots() into three
Previously, get_boots() used for three ways; finding boot entry by
boot ID, finding boot entry by offset, listing up all boot IDs.

Let's split it into three for each usecase.

No functional change, just refactoring.
2023-05-27 03:57:39 +09:00
Yu Watanabe c93d3c0512 logs-show: introduce add_match_boot_id() helper function 2023-05-27 03:57:01 +09:00
Yu Watanabe d4fd160f69 Merge pull request #27786 from YHNdnzj/format-timestamp-monotonic
time-util,format-table: add relative_monotonic variant for timestamp
2023-05-27 03:05:34 +09:00
Yu Watanabe f254238204 Merge pull request #27803 from mrc0mmand/even-more-nalloc-shenanigans
A couple more fixes for potential OOM-related issues
2023-05-27 02:58:32 +09:00
Yu Watanabe 998db5871f udev: introduce .PART_SUFFIX internal property
To make unify rules for disk and partition.
2023-05-26 16:38:09 +02:00
Yu Watanabe 831108245e core/unit: update bidirectional dependency simultaneously
Previously, if unit_add_dependency_hashmap() failed, then a
one-directional unit dependency reference might be created, and
triggeres use-after-free. See issue #27742 for more details.

This makes unit dependency always bidirectional, and cleanly revert
partial update on failure.

Fixes #27742.
2023-05-26 15:24:09 +09:00
Yu Watanabe 83123a4498 core/unit: search shared namespace in transitive relation of JoinsNamespaceOf=
Previously, dependency chain of JoinsNamespaceOf= did not work, e.g.
- a.service has JoinsNamespaceOf=b.service
- b.service has JoinsNamespaceOf=c.service
if, first c.service, next a.service, finally b.service is started,
then a.service is not joined to the namespace of c.service. And, as
mentioned in the document, the namespace used by b.service is not
deterministic.

This makes when searching exsiting namespace to be joined, all units in
the transitive dependency of JoinsNamespaceOf= are checked.
2023-05-26 15:23:57 +09:00
Yu Watanabe a60f96fcf5 core/unit: make JoinsNamespaceOf= implies the inverse dependency
Previously, even if a.service has JoinsNamespaceOf=b.service, the
inverse direction of reference was not introduced.
Hence, a.service is started earlier than b.service, the namespace will
not shared with b.service.
Also, even if a.service had the reference to b.service, b.service did not.
If b.service is freed earlier, then unit_clear_dependencies() does not clear
the reference from a to b, and will cause use-after-free on unit_free() for
a.service.

Let's make JoinsNamespaceOf=b.service in a.service implies the inverse
dependency, i.e. JoinsNamespaceOf=a.service for b.service. Then, we can safely
free b.service.
2023-05-26 11:50:08 +09:00
Yu Watanabe 512df9de23 core/unit: drop doubled empty line 2023-05-26 11:50:08 +09:00
Yu Watanabe 8493a82d0b test: add tests for JoinsNamespaceOf=
To illustrate the current behavior of the dependency.
2023-05-26 11:50:05 +09:00
Yu Watanabe cd8910f053 Merge pull request #27770 from mrc0mmand/more-nallocfuzz-shenanigans
A couple of fixes for potential issues during OOM situations
2023-05-25 17:15:37 +09:00
Yu Watanabe 9e7b922c8f Merge pull request #27769 from YHNdnzj/loginctl-followup
loginctl: some follow-ups
2023-05-25 05:52:06 +09:00
Yu Watanabe 1f74369c2e Merge pull request #27723 from YHNdnzj/service-restart-cleanup
core: get rid of unused Service.will_auto_restart logic
2023-05-25 05:14:52 +09:00
Yu Watanabe 290c4a4b34 Merge pull request #27173 from yuwata/update-utmp
update-utmp: do not fail when PID1 is reexecuting
2023-05-25 04:00:58 +09:00
Yu Watanabe 65d9bd5626 Merge pull request #27773 from dtardon/timestamp-cleanup
Use *timestamp_is_set() at more places
2023-05-25 03:27:15 +09:00
Yu Watanabe 3aa53842fd Merge pull request #27774 from dtardon/free-cleanup
Use free_and_*() more
2023-05-25 03:06:51 +09:00
Yu Watanabe d689f70a2c test: add test case for systemd-update-utmp vs daemon-reexec 2023-05-24 20:06:10 +09:00
Yu Watanabe 08bc702b12 test: drop a workaround
Follow-up for 61961e693d.
2023-05-24 20:06:10 +09:00
Yu Watanabe fcb2343175 update-utmp: reconnect after sleep when PID1 is reexecuting
Fixes #27167.
2023-05-24 20:06:10 +09:00
Yu Watanabe 87ae54533c update-utmp: update log message 2023-05-24 20:06:10 +09:00
Yu Watanabe 86da32ee0c update-utmp: downgrade log level of ignored failure 2023-05-24 20:06:10 +09:00
Yu Watanabe 4c40ab203c update-utmp: swap q <-> r
We usually use 'r' for general purpose.

No functional change, just refactoring.
2023-05-24 20:06:10 +09:00
Yu Watanabe 3950d8f693 update-utmp: modernize get_startup_monotonic_time()
This also downgrade error level, as the failure will be ignored.

No functional change, just refactoring.
2023-05-24 20:06:07 +09:00
Yu Watanabe 309491e4cf update-utmp: rebreak comments 2023-05-24 20:04:33 +09:00
Yu Watanabe 230f663e3e update-utmp: use verbs
No functional change, just refactoring.
2023-05-24 20:04:33 +09:00
Yu Watanabe 5f1f05b961 Merge pull request #27740 from dtardon/list-sessions-idle
Show idle status in `loginctl list-sessions`
2023-05-24 20:03:39 +09:00
Yu Watanabe 8ddc5f7699 Merge pull request #27757 from dtardon/bus-locator
Convert more DBus calls to BusLocator
2023-05-24 20:02:57 +09:00
Yu Watanabe 5c4e96c28c test: rotate journal before storing coredumps
Hopefully fixes the failure like
https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/job/upstream-vagrant-archlinux-sanitizers/2558/
---
[   66.708894] testsuite-74.sh[728]: + coredumpctl --json=off
[   66.709344] testsuite-74.sh[826]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.709773] testsuite-74.sh[826]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.711134] testsuite-74.sh[826]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.711789] testsuite-74.sh[826]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.712460] testsuite-74.sh[826]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.713505] testsuite-74.sh[728]: + coredumpctl --root=/
[   66.714144] testsuite-74.sh[828]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.714535] testsuite-74.sh[828]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.715208] testsuite-74.sh[828]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.715907] testsuite-74.sh[828]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.716565] testsuite-74.sh[828]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.717494] testsuite-74.sh[728]: + coredumpctl --directory=/var/log/journal
[   66.718188] testsuite-74.sh[830]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.882072] testsuite-74.sh[830]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.882642] testsuite-74.sh[830]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.883450] testsuite-74.sh[830]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.883944] testsuite-74.sh[830]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.885448] testsuite-74.sh[728]: + coredumpctl --file=/var/log/journal/2e1ed84be19a4e22adfc99ad849be1f6/system.journal
[   66.885989] testsuite-74.sh[728]: + at_exit
[   66.894162] coredumpctl[833]: No coredumps found.
---
2023-05-24 09:22:13 +02:00
Yu Watanabe 73d24e45f8 test-network: add tests for vlan QoS mapping 2023-05-24 11:15:44 +09:00
Yu Watanabe 4194478af8 network/vlan: paranoia about type safety
No functional change, as the struct is defined as the following:
```
struct ifla_vlan_qos_mapping {
      __u32 from;
      __u32 to;
};
```
2023-05-24 11:06:43 +09:00
Yu Watanabe 4d13d175f8 network/vlan: drop unnecessary restriction for QoS mapping
Fixes #27460.
2023-05-24 11:02:39 +09:00
Yu Watanabe 5dc0c21b31 core/slice: shorten code a bit 2023-05-24 10:26:21 +09:00
Yu Watanabe 93ec924c41 test: add test cases for defining mount and swap units from kernel cmdline 2023-05-24 08:23:22 +09:00
Yu Watanabe 55365b0a23 fstab-generator: support defining mount units through kernel command line
Now, the following kernel command line options are supported:
  systemd.mount-extra=what:where:fstype:options
  systemd.swap-extra=what:options

Closes #27260.
2023-05-24 08:23:22 +09:00
Yu Watanabe 2646f18445 fstab-generator: fix error code propagation in run_generator()
Previously, some errors might be ignored.
2023-05-24 08:23:22 +09:00
Yu Watanabe 6742eca134 fstab-generator: refuse invalid mount point path in fstab earlier 2023-05-24 08:23:22 +09:00
Yu Watanabe 9445623363 fstab-generator: refuse to add swap earlier if disabled
No functional change, preparation for later commits.
2023-05-24 08:23:22 +09:00
Yu Watanabe 256604ccdd fstab-generator: call add_swap() earlier
As 'where' field will be ignored for swap entry.
2023-05-24 08:23:22 +09:00
Yu Watanabe cfeb4d378e fstab-generator: split out several functions from parse_fstab()
No functional changes, just refactoring and preparation for later
commits.
2023-05-24 08:23:22 +09:00
Yu Watanabe 82c29dbee0 test-fstab-generator: add tests for mount options 2023-05-24 08:23:22 +09:00
Yu Watanabe 70bf9f62b9 test-fstab-generator: also check file contents
Since e683878c0f, only filenames are
checked. Let's check contents of generated unit files.
2023-05-24 08:23:22 +09:00
Yu Watanabe a484320572 Merge pull request #27755 from keszybz/fix-root-resize-new
Reload keymap and locale config after firstboot writes it out
2023-05-24 06:08:54 +09:00
Yu Watanabe dd57168144 Merge pull request #27754 from poettering/cloexec-fdset-madness
pid1: when taking possession of passed fds check O_CLOEXEC state first
2023-05-24 06:08:17 +09:00
Yu Watanabe 26a9dd6f55 sd-bus: refuse to send messages with an invalid string
Prompted by aaf7b0e411 and
4804da5853.
2023-05-23 19:14:21 +08:00
Yu Watanabe 4539bb3b4b Merge pull request #27733 from mrc0mmand/more-test-followups
test: a couple of follow-ups
2023-05-23 05:02:36 +09:00
Yu Watanabe 6554f56361 wait-online: downgrade log level of failure that interface is removed or unmanaged during processing it
Closing #27145.
2023-05-22 19:06:06 +09:00
Yu Watanabe e7432ed7ca Merge pull request #27726 from yuwata/network-wireguard-doc
network: update doc
2023-05-22 16:46:38 +09:00
Yu Watanabe f8c5301e44 man: AllowedIPs= can be specified multiple times
Closes #27507.
2023-05-22 14:18:46 +09:00
Yu Watanabe 54189b2ec3 network/wireguard: make AllowedIPs= cleared by specifying an empty string 2023-05-22 14:15:49 +09:00
Yu Watanabe 23ff8a776c test: install test specific modules in test_append_files() 2023-05-22 12:40:05 +09:00
Yu Watanabe a94149601a sd-journal: save correct location specifier 2023-05-22 02:54:40 +09:00