Commit Graph
100 Commits
Author SHA1 Message Date
Yu Watanabe cf708d803e Merge pull request #22867 from poettering/lockdev-util
add small "udevadm lock" tool for locking a block device
2022-04-05 03:04:23 +09:00
Yu Watanabe f3e5c781f3 Merge pull request #22943 from yuwata/dhcp6-client-requet-options
sd-dhcp6-client: requet options
2022-04-04 22:55:02 +09:00
Yu Watanabe d315b47e2d Merge pull request #22952 from poettering/rework-kvm-hyperv
virt: tweak kvm with hyperv enlightenments
2022-04-04 22:53:56 +09:00
Yu Watanabe 822883b3e7 sd-dhcp6-client: request several options
Even though these options are not currently used by sd-dhcp6-client,
RFC 8415 states these options MUST be requested.
2022-04-04 01:22:02 +09:00
Yu Watanabe 612caa2626 network: dhcp6: request DNS servers or friends only when they will be used 2022-04-03 19:55:25 +09:00
Yu Watanabe f697ab358a dhcp: make option names singular 2022-04-03 19:50:02 +09:00
Yu Watanabe 0e0c4daea6 sd-dhcp6-client: sort requesting options 2022-04-03 19:23:03 +09:00
Yu Watanabe 2f53b311c3 sd-dhcp6-client: rename req_opts_len -> n_req_opts
As 'len' is confusing and we may misunderstand it as the size of
the buffer instead of the number of options.
2022-04-03 19:23:03 +09:00
Yu Watanabe 95cd21928f Merge pull request #22939 from yuwata/tree-wide-space
tree-wide: add space after if, switch, for, and while
2022-04-02 01:32:26 +09:00
Yu Watanabe b17a681be5 tree-wide: fix typo 2022-04-02 00:34:39 +09:00
Yu Watanabe 37ebfe49de Merge pull request #22926 from bluca/analyze_offline_filter
analyze: fix offline checks for syscall filter and 'native' architecture
2022-04-01 23:43:18 +09:00
Yu Watanabe 798931160e tree-wide: add a space after if, switch, for, and while 2022-04-01 22:48:42 +09:00
Yu Watanabe 72dce85a60 test: add space between arguments 2022-04-01 22:28:13 +09:00
Yu Watanabe b8529cf376 Merge pull request #22872 from yuwata/udevadm-wait
udevadm: introduce 'wait' command
2022-04-01 18:41:03 +09:00
Yu Watanabe 78e278ad48 udev: use sd_device_open() where appropriate 2022-04-01 15:21:05 +09:00
Yu Watanabe 9534d6c9ea test: add test for sd_device_open() 2022-04-01 15:20:48 +09:00
Yu Watanabe f9a726abef sd-device: introduce sd_device_open()
We usually open() device node obtained by sd_device_get_devname().
However, the device node corresponds to the sd-device object may be
already removed, and another device node with the same path may be
created, hence an unexpected device may be opened.

The sd_device_open() opens device node, and checks the devnum and
diskseq of opened devnum, to avoid the above possibility.

Prompted by https://github.com/systemd/systemd/issues/22906#issuecomment-1082736443.
2022-04-01 15:13:18 +09:00
Yu Watanabe 7e93a65868 fd-util: rename loop_get_diskseq() -> fd_get_diskseq()
And move it from loop-util.[ch] -> fd-util.[ch]
2022-04-01 15:13:18 +09:00
Yu Watanabe 2076612f84 basic/missing: move BLKGETDISKSEQ to missing_fs.h
As it is defined at linux/fs.h.
2022-04-01 15:13:18 +09:00
Yu Watanabe e529abe24d test: replace helper_wait_for_dev() with 'udevadm wait' 2022-04-01 15:13:18 +09:00
Yu Watanabe aa2b0d8d29 udevadm: introduce new 'wait' command
Prompted by https://github.com/systemd/systemd/pull/22717#issuecomment-1067348496.

The new command 'udevadm wait' waits for device or device symlink being
created. This may be useful to wait for a device is processed by udevd
after e.g. formatting or partitioning the device.
2022-04-01 15:13:18 +09:00
Yu Watanabe 209294ad24 test: add more tests for sd_device_new_from_xxx() 2022-04-01 15:13:14 +09:00
Yu Watanabe e418f9658b sd-device: introduce sd_device_new_from_devname()
and sd_device_new_from_path() which takes devname or syspath.
2022-04-01 15:03:33 +09:00
Yu Watanabe b2e7ded16b Merge pull request #22899 from yuwata/network-ignore-carrier-loss
network: automatically determine timeout of waiting for carrier regain
2022-03-31 11:40:30 +09:00
Yu Watanabe da94a69b8d network: shorten code a bit
Currently, there exist only two MTU sources, static and DHCPv4, and they
are exclusive. Hence, it is not necessary to check the existence of the
MTU option in the acquired DHCP lease. Let's unconditionally reset the
MTU. Note that, if the current and original MTU are equivalent, then
link_request_to_set_mtu() handles that gracefully.
2022-03-31 09:29:42 +09:00
Yu Watanabe b732606950 network: automatically determine timeout of waiting for carrier regain
The commit 6706ce2fd2 made
IgnoreCarrierLoss= setting also take timespan, to make users handle
issues like #18738 or #20887. But still users needed to explicitly set
a timespan.

This makes networkd automatically determine the timeout when the
situations #18738 or #19832 is detected. Unfortunately, still users have
issue #20887 need to specify a value.

Closes #19832.
2022-03-31 09:29:42 +09:00
Yu Watanabe a14b9ca2c3 Merge pull request #22913 from yuwata/sd-device-cleanups
sd-device,udev: several cleanups
2022-03-31 09:24:38 +09:00
Yu Watanabe 03a24ce76b udev: rename functions to emphasize whole disk is locked 2022-03-31 07:25:24 +09:00
Yu Watanabe 20ba5a3fe7 udev: ignore one more error in device_get_block_device() 2022-03-31 07:25:24 +09:00
Yu Watanabe df88f02bb1 sd-device: do not ignore critical errors in device_new_from_child() 2022-03-31 07:25:24 +09:00
Yu Watanabe 07c90f02d2 sd-device: use path_extract_directory() at one more place 2022-03-31 07:25:24 +09:00
Yu Watanabe becbcca5b8 sd-device: try to get DISKSEQ from uevent file
Otherwise, if the sd-device object is created from e.g. syspath, then
sd_device_get_diskseq() returns -ENOENT.
2022-03-31 07:25:24 +09:00
Yu Watanabe a43129b0a0 sd-device: drop /sys/subsystem support
Follow-ups for 37cf83d9bf.
2022-03-31 07:25:24 +09:00
Yu Watanabe 72151060e8 udev: do not use sd_event_source_disable_unref() at more places
Fixes a bug introduced by 9612da361a.

Follow-up for f777e745a7.
2022-03-31 05:08:23 +09:00
Yu Watanabe fb54461717 udev: do not append unknown errno or signal name
Follow-up for 6467bda59d.

Addresses https://github.com/systemd/systemd/pull/22871#discussion_r837705779.
2022-03-30 17:22:11 +02:00
Yu Watanabe 8b7378e145 fix typo 2022-03-30 21:10:06 +09:00
Yu Watanabe 10176f0011 test: add tests for worker error code 2022-03-30 01:27:29 +09:00
Yu Watanabe 6467bda59d udev: append error code in broadcasted message
So, libudev listners can easily detect errors.

Addresses https://github.com/systemd/systemd/pull/22717#discussion_r834420878.
2022-03-30 01:27:29 +09:00
Yu Watanabe 71978a79fd sd-device: introduce device_add_propertyf() 2022-03-30 01:27:29 +09:00
Yu Watanabe f777e745a7 udev: do not call sd_event_source_disable_unref() in workers for event sources created by the main process
Fixes a bug introduced by 9612da361a.
2022-03-29 10:29:44 +02:00
Yu Watanabe 8166950763 inotify-util: fix wrong warnings in FOREACH_INOTIFY_EVENT()
Follow-up for 00adc340bb.

This fixes the wrong "Received invalid inotify event, ignoring." warnings
caused by the missing curly brackets and the priorities of `&&` and `?:`.

This also replaces the ternary operators with `||`.
2022-03-29 13:20:16 +09:00
Yu Watanabe 2afb2f4a9d Merge pull request #22885 from poettering/kill-clock-boottime-or-monotonic
time-util: assume CLOCK_BOOTTIME always exists
2022-03-29 03:06:54 +09:00
Yu Watanabe 288bd40620 fix typo 2022-03-29 01:21:51 +09:00
Yu Watanabe 0c6e746b86 Update NEWS
- categorize entries
- add several news for networkd and udevd
2022-03-29 01:19:18 +09:00
Yu Watanabe ec4954d934 network: rename netdev kind virtual-wlan -> wlan
The Kind= setting in [Match] section of .network files takes "wlan".
This makes the same setting in .netdev files matches the one in .network
files.
2022-03-28 23:53:12 +09:00
Yu Watanabe dd2396f20d Merge pull request #22861 from poettering/journald-sigterm
journald: don't let SIGTERM starve indefinitely
2022-03-26 00:27:47 +09:00
Yu Watanabe 8603a229e9 efi-loader: drop harmful assertion
This fixes a bug introduced by 7be4b23649.

The function `efi_loader_get_device_part_uuid()` handles NULL
gracefully, and it is called with NULL in gpt-auto-generator.

Fixes #22862.
2022-03-25 14:29:44 +09:00
Yu Watanabe 82a5de9fd2 udev: assume block device is not locked when a new event is queued
Then, hopefully, previously requeued events are processed earlier.
2022-03-25 10:28:07 +09:00
Yu Watanabe 7b7959fba5 udev: split worker_lock_block_device() into two
This also makes return value initialized when these function return 0 to
follow our coding style.

Just a preparation for later commits.
2022-03-25 10:28:07 +09:00
Yu Watanabe 5d354e525a udev: requeue event when the corresponding block device is locked by another process
Previously, if a block device is locked by another process, then the
corresponding worker skip to process the corresponding event, and does
not broadcast the uevent to libudev listners. This causes several issues:

- During a period of a device being locked by a process, if a user trigger
  an event with `udevadm trigger --settle`, then it never returned.

- When there is a delay between close and unlock in a process, then the
  synthesized events triggered by inotify may not be processed. This can
  happens easily by wrapping mkfs with flock. This causes severe issues
  e.g. new devlinks are not created, or old devlinks are not removed.

This commit makes events are requeued with a tiny delay when the corresponding
block devices are locked by other processes. With this way, the triggered
uevent may be delayed but is always processed by udevd. Hence, the above
issues can be solved. Also, it is not necessary to watch a block device
unconditionally when it is already locked. Hence, the logic is dropped.
2022-03-25 10:28:03 +09:00
Yu Watanabe 0c3d8182c9 udev: store action in struct Event 2022-03-25 10:25:27 +09:00
Yu Watanabe c17ab900cb udev: introduce device_broadcast() helper function 2022-03-25 10:25:26 +09:00
Yu Watanabe c9473aaa5b udev: drop unnecessary clone of received sd-device object
As the sd-device object received through sd-device-monitor is sealed,
so the corresponding udev database or uevent file will not be read.
2022-03-25 10:25:26 +09: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
Yu Watanabe c02fb80479 udev: try to reload selinux label database less frequently
Previously, `event_run()` was called repeatedly in one `event_queue_start()`
invocation. Hence, the SELinux label database is reloaded many times needlessly.
Other settings, e.g. udev rules or hwdata, are tried to be reloaded in the
beginning of `event_queue_start()`. Let's also do so for the SELinux database.
2022-03-24 16:20:42 +01:00
Yu Watanabe 2d40f02ee4 udev: assume there is no blocker when failed to check event dependencies
Previously, if udevd failed to resolve event dependency, the event is
ignored and libudev listeners did not receive the event. This is
inconsistent with the case when a worker failed to process a event,
in that case, the original uevent sent by the kernel is broadcasted to
listeners.
2022-03-24 16:20:32 +01:00
Yu Watanabe ef400c3878 udev: only ignore ENOENT or friends which suggest the block device is not exist
The ENOENT, ENXIO, and ENODEV error can happen easily when a block
device appears and soon removed. So, it is reasonable to ignore the
error. But other errors should not occur here, and hence let's handle
them as critical.
2022-03-24 16:20:08 +01:00
Yu Watanabe 4029328014 udev: remove /run/udev/queue in on_post()
When the last queued event is processed, information about subsequent
events may be already queued in the netlink socket of sd-device-monitor.
In that case, previously we once removed /run/udev/queue and touch the
file soon later, and `udevadm settle` mistakenly considered all events
are processed.

To mitigate such situation, this makes /run/udev/queue removed in on_post().
2022-03-24 16:19:36 +01:00
Yu Watanabe 9612da361a udev: use sd_event_source_disable_unref()
This should not change any behavior, as the event sources are not
shared. Just for safety.
2022-03-24 16:19:20 +01:00
Yu Watanabe 87afc766d1 udev: update comment and log message 2022-03-24 16:19:05 +01:00
Yu Watanabe f7adeaeb89 journal-remote: refuse to specify --trust option when gnutls is disabled
and check_permission() should not be called in that case.

Replaces #22847.
2022-03-24 13:53:04 +01:00
Yu Watanabe bc7a6ee4af Merge pull request #22800 from poettering/safe-ptr-sub1
Add helper macro PTR_SUB1() to deal with backwards iteration through arrays without UB
2022-03-24 06:34:09 +09:00
Yu Watanabe 2859932bd6 network: do not enable IPv4 ACD for IPv4 link-local address if ACD is disabled explicitly
The commit 1cf4ed142d makes the IPv4 ACD
enabled unconditionally for IPv4 link-local addresses even if users
explicitly disable ACD.

This makes the IPv4 ACD is enabled by default, but honor user setting.

Fixes #22763.
2022-03-23 17:59:38 +01:00
Yu Watanabe 007950dcd1 dns-domain: use PTR_SUB1() macro 2022-03-23 21:57:59 +09:00
Yu Watanabe 93e04eb43b test: add tests for device id 2022-03-23 21:57:39 +09:00
Yu Watanabe 13659527ef sd-device: use path_find_last_component() to set driver subsystem 2022-03-23 21:57:39 +09:00
Yu Watanabe 3066293dd3 path-util: use PTR_SUB1() macro in path_find_last_component() 2022-03-23 21:57:39 +09:00
Yu Watanabe e7bf2fcab0 core/namespace: inline one more iterator variable 2022-03-23 21:57:39 +09:00
Yu Watanabe 904447ce5a Merge pull request #22835 from keszybz/foreach_string-inline-iterator
Inline the iterator declaration in FOREACH_STRING
2022-03-23 21:43:02 +09:00
Yu Watanabe 7a692931ab sysupdate: fix error handling 2022-03-23 16:52:55 +09:00
Yu Watanabe cb8453cc51 network: sriov: use request queue to configure SR-IOV virtual functions 2022-03-23 16:48:36 +09:00
Yu Watanabe bee8fc36f4 sriov: introduce sr_iov_hash_func() and sr_iov_compare_func() 2022-03-23 16:32:51 +09:00
Yu Watanabe 60f53dd5cc NEWS: fix typo 2022-03-23 12:22:53 +09:00
Yu Watanabe ff8619791a boot: fix typo 2022-03-23 12:21:54 +09:00
Yu Watanabe 14acae357b Merge pull request #22825 from keszybz/assorted-cleanups
Assorted cleanups
2022-03-23 11:34:46 +09:00
Yu Watanabe d8b50e5df7 sd-device-enumerator: support to list only initialized or uninitialized devices 2022-03-22 15:27:06 +09:00
Yu Watanabe 2336bde964 unit: make systemd-udev-trigger.service use --prioritized-subsystem
Replaces #19637 and #22643.
2022-03-22 15:27:06 +09:00
Yu Watanabe 1baeee5784 udevadm trigger: introduce --type=all option 2022-03-22 15:27:06 +09:00
Yu Watanabe 873cf95c2f udevadm trigger: introduce --prioritized-subsystem option 2022-03-22 15:27:06 +09:00
Yu Watanabe 3c5cc23a93 sd-device-enumerator: introduce device_enumerator_scan_devices_and_subsystems() 2022-03-22 15:27:06 +09:00
Yu Watanabe 37cf83d9bf sd-device-enumerator: drop /sys/subsystem support
This addresses the comment by Lennart
https://github.com/systemd/systemd/pull/22662#discussion_r829799863:
> /sys/subsystem is preparation for a future that never came.
> And given that the main proponent of this left Linux kernel
> development (Kay), I doubt this will ever come. So maybe we
> should start dropping references to /sys/subsystem/ given it's
> unlikely to materialize anytime soon.
2022-03-22 15:27:06 +09:00
Yu Watanabe 95a6f969fc sd-device-enumerator: introduce device_enumerator_add_prioritized_subsystem()
If a subsystem is specified, then matching devices and their parents are
listed at first.
2022-03-22 12:29:08 +09:00
Yu Watanabe 87c3a0f9f8 sd-device-enumerator: introduce device_enumerator_sort_devices()
and devices are sorted when the iteration started.

Previously, devices added by udev_enumerate_add_syspath() ->
device_enumerator_add_device() are not sorted. This fixes the issue.
2022-03-22 11:56:18 +09:00
Yu Watanabe deac0c9c04 sd-device-enumerator: introduce device_enumerator_unref_devices() helper function 2022-03-22 11:56:18 +09:00
Yu Watanabe 9e871965a0 sd-device-enumerator: introduce sound_device_compare() and devpath_is_late_block() helper functions 2022-03-22 11:56:13 +09:00
Yu Watanabe 59b8e67582 Merge pull request #22789 from poettering/timesync-struct-log
timesyncd: various refactorings and cleanup + structured log msg on first sync
2022-03-21 02:26:59 +09: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
Yu Watanabe d0b4f13ef8 strv: use STRV_FOREACH() at two more places 2022-03-18 18:38:08 +01:00
Yu Watanabe 9eb814818d strv: rewrite strv_copy() with cleanup attribute and STRV_FOREACH() 2022-03-18 18:36:48 +01:00
Yu Watanabe 827f865063 sd-device: shorten code a bit 2022-03-18 09:57:24 +01:00
Yu Watanabe 29e6f70b8d sd-device-enumerator: fix typo: contolC -> controlC
Also shorten code a bit.
2022-03-18 09:43:09 +01:00
Yu Watanabe f79856d9e8 sort-util: add missing parens
With this, we can call e.g.
```
typesafe_qsort(buf + m, n - m, comp);
```
2022-03-18 09:42:38 +01:00
Yu Watanabe 3c45ad24c2 Merge pull request #22752 from yuwata/udev-ctrl-manage-sender-pids
udev: enable Delegate=
2022-03-18 07:38:35 +09:00
Yu Watanabe b7ee9b3551 test: wait for loopback device being ready to manipulate
Follow-up for 6626ea08f6.
2022-03-17 16:11:12 +00:00
Yu Watanabe a1f4fd3876 udev: run the main process, workers, and spawned commands in /udev subcgroup
And enable cgroup delegation for udevd.
Then, processes invoked through ExecReload= are assigned .control
subcgroup, and they are not killed by cg_kill().

Fixes #16867 and #22686.
2022-03-17 20:24:38 +09:00
Yu Watanabe ac33e14754 repart: use assert() when no state is changed 2022-03-17 20:10:17 +09:00
Yu Watanabe 8fe84dc8de core: ExecContext::restrict_filesystems is set of string 2022-03-17 20:09:59 +09:00
Yu Watanabe 3cef19b369 Merge pull request #22770 from yuwata/sd-radv-fixes
sd-radv: several fixes
2022-03-17 20:09:41 +09:00