Commit Graph
100 Commits
Author SHA1 Message Date
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
Yu Watanabe 8b9afa5524 timedate: use cleanup attribute at one more place 2022-03-17 20:09:18 +09:00
Yu Watanabe 4267084642 Revert "udev: do not kill "udevadm control" process in the same cgroup"
This reverts commit ccadf9ac0d.

The fix is not insufficient. See #22686.
2022-03-17 14:42:56 +09:00
Yu Watanabe faaf3d66ce sd-radv: fix indentation 2022-03-17 14:34:58 +09:00
Yu Watanabe 56aa51432e sd-radv: do not use iterater outside of the loop 2022-03-17 14:34:58 +09:00
Yu Watanabe 95931532aa sd-radv: voidify sd_radv_remove_prefix()
If the prefix is only referenced by sd_radv, then the returned pointer
is already freed.

networkd does not uses the returned value. Let's voidify the function.
2022-03-17 14:34:58 +09:00
Yu Watanabe 06fb09cf40 Merge pull request #22765 from medhefgo/test
test: Use TEST macros in more places
2022-03-17 03:07:36 +09:00
Yu Watanabe 172e3817b0 home: use open_image_file() helper at one more place 2022-03-15 22:07:11 +09:00
Yu Watanabe 3b591ebbd1 Merge pull request #22739 from mrc0mmand/list-boot-followup
A couple of follow-ups for #22721
2022-03-15 15:59:45 +09:00
Yu Watanabe e60c3c72f7 home: shorten code a bit and add missing assertions
This drops redundant call of fstat(), and reduces indentation.
2022-03-15 12:38:08 +09:00
Yu Watanabe 6626ea08f6 test: wait for loopback device being actually created
It seems there exists a short time period that we cannot see the
loopback device after `losetup` is finished:
```
testsuite-58.sh[367]: ++ losetup -b 1024 -P --show -f /tmp/testsuite-58-sector-1024.img
kernel: loop1: detected capacity change from 0 to 204800
testsuite-58.sh[285]: + LOOP=/dev/loop1
testsuite-58.sh[285]: + systemd-repart --pretty=yes --definitions=/tmp/testsuite-58-sector/ --seed=750b6cd5c4ae4012a15e7be3c29e6a47 --empty=require --dry-run=no /dev/loop1
testsuite-58.sh[368]: Device '/dev/loop1' has no dm-crypt/dm-verity device, no need to look for underlying block device.
testsuite-58.sh[368]: Failed to determine canonical path for '/dev/loop1': No such file or directory
testsuite-58.sh[368]: Failed to open file or determine backing device of /dev/loop1: No such file or directory
```
2022-03-15 12:35:50 +09:00
Yu Watanabe 8c166c962d test: format disk image through loopback device
It seems that the change on the image file sometimes not propagated on
the loopback device immediately.
2022-03-15 12:35:50 +09:00
Yu Watanabe cc75e1f7c9 test: use /var/tmp for storing disk images
The Ubuntu CI on ppc64el seems to have a issue on tmpfs, and files
may not be fsynced. See c10caebb98.
For safety, let's use /var/tmp to store disk images.
2022-03-15 12:35:50 +09:00
Yu Watanabe d4782b51ec Merge pull request #22721 from mrc0mmand/journalctl-tweaks
journal: convert --list-boots to a table
2022-03-14 10:59:13 +09:00
Yu Watanabe c86efe34df man: replace full stop with colon
Fixes #22724.
2022-03-13 18:30:57 +00:00
Yu Watanabe 21547367cd doc: fix error code 2022-03-13 10:24:45 +00:00
Yu Watanabe 27a5281f4b Merge pull request #22711 from yuwata/c11
move to C11 (gnu11) and use u8 specifier for special characters
2022-03-12 14:27:48 +09:00
Yu Watanabe 6f4bffb586 lgtm: disable cpp/missing-return
As it does not handle assert_not_reahed() gracefully.
2022-03-11 17:19:32 +09:00
Yu Watanabe 5535484e17 qrcode-util: use u8 literal specifier 2022-03-11 15:59:58 +09:00
Yu Watanabe e5ba040fb8 hostnamectl: use u8 literal specifier 2022-03-11 15:53:18 +09:00
Yu Watanabe 7fbbec71b1 glyph-util: use u8 literal specifier for special characters 2022-03-11 15:35:47 +09:00
Yu Watanabe 2b2dbcbbeb meson: move to c_std=gnu11
Recently, the kernel communitiy started to discuss to move C11 (gnu11) [1],
and it seems to come near future.
Let's also move to c_std=gnu11. Unlike the kernel, we already uses
gnu99, hence hopefully we can move to C11 without changing anything.

[1] https://lore.kernel.org/lkml/CAHk-=wiyCH7xeHcmiFJ-YgXUy2Jaj7pnkdKpcovt8fYbVFW3TA@mail.gmail.com/
2022-03-11 15:13:29 +09:00
Yu Watanabe 09d09207de network: re-design request queue
This makes Request object takes hash, compare, free, and process functions.

With this change, the logic in networkd-queue.c can be mostly
independent of the type of the request or the object (e.g. Address) assigned
to the request, and it becomes simpler.
2022-03-11 14:20:31 +09:00
Yu Watanabe 4c8b81caa5 network: increment reference counters of Link and Request before processing requests
To prevent the request or link is freed while processing requests.
2022-03-11 14:20:31 +09:00