Commit Graph
100 Commits
Author SHA1 Message Date
Yu Watanabe e6766c538a udev-builtin-net_id: reading phys_port_name may be refused with EOPNOTSUPP
If reading the sysattr failed with such error, the whole operation in
net_id builtin command will fail, and the interface will not be renamed.

Fixes a bug introduced by 5bbcfbaa11.
2022-10-04 20:29:41 +09:00
Yu Watanabe 0a8720c7f0 network: fix use-after-free
If the lifetime of the route is already expired, do not try to
configure it.

Fixes a use-after-free, as the Request object is already freed, thus, we
cannot use Route or Link stored in Request object.
2022-10-03 09:15:10 +02:00
Yu Watanabe 2ff7862bf2 resolve: drop remaining references for Monitor=
Follow-up for b25d819aee.
2022-10-03 08:26:05 +02:00
Yu Watanabe 64ebc0da03 resolve: fix typo 2022-10-03 09:23:37 +09:00
Yu Watanabe 59fde24c60 Merge pull request #24897 from mrc0mmand/TEST-64-sanitiers-open-scsi
test: pre-load ASan's DSO for iscsi-init.service
2022-10-03 07:51:50 +09:00
Yu Watanabe a78049fc0e resolve: do not cache mDNS goodbye packet
Fixes #24842.
2022-09-30 18:50:56 +09:00
Yu Watanabe 9449268fae Merge pull request #24820 from keszybz/tmpfiles-warning
Downgrade warning about unitialized-/etc in tmpfiles
2022-09-30 18:50:31 +09:00
Yu Watanabe ad8c442a0b test-64-udev-storage: use wait command instead of hackish "udevadm lock true"
Otherwise, "udevadm lock true" may lock a block device earlier than
"udevadm lock sfdisk &".
2022-09-30 03:42:05 +09:00
Yu Watanabe 4273a041f1 udevadm: do not try to find device unit when a path like string is provided
Otherwise, we provide misleading error message.
Before:
---
$ udevadm info /sys/class/foo
Bad argument "/sys/class/foo", expected an absolute path in /dev/ or /sys/ or a unit name: Invalid argument
---
After:
---
$ udevadm info /sys/class/foo
Unknown device "/sys/class/foo": No such device
---
2022-09-30 02:05:09 +09:00
Yu Watanabe 4f0ad43e24 loop-util: re-introduce loop_device_open() which takes sd_device object
Then, this makes loop_device_open_from_fd() or _from_path() be wrappers
of loop_device_open() with block_device_new_from_fd() or _from_path(),
respectively.
2022-09-28 17:42:37 +09:00
Yu Watanabe de3b7f168e loop-util: rename loop_device_open() -> loop_device_open_from_path()
No functional changes, just preparation for later commits.
2022-09-28 17:42:37 +09:00
Yu Watanabe fd690a4b7f blockdev-util: introduce block_device_new_from_fd() and block_device_new_from_path()
These are possible replacements of get_block_device(),
get_block_device_harder(), path_get_whole_disk(), and friends.
2022-09-28 17:42:23 +09:00
Yu Watanabe 612fc70fc0 blockdev-util: re-implement block_get_originating() by using sd_device
And split out the core logic as block_device_get_originating().
Hopefully, this changes no behavior. Just refactoring and preparation
for later commits.
2022-09-28 17:41:09 +09:00
Yu Watanabe 446f8db66b blockdev-util: reopen file descriptor only when O_PATH is set
Prompted by 13879c54d4.
2022-09-28 17:41:09 +09:00
Yu Watanabe 7e4a0387c4 blockdev-util: split-out fd_get_devnum()
No functional changes, just preparation for later commits.
2022-09-28 17:41:09 +09:00
Yu Watanabe c5654483dc fuzz: tighten acceptable data size
Fixes oss-fuzz#51887 (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51887).
Fixes #24833.
2022-09-28 09:12:36 +02:00
Yu Watanabe c561c78063 kernel-install: do not fail if a plugin exits with 77 2022-09-28 13:36:38 +09:00
Yu Watanabe 46f347ada3 kernel-install: do not fail if $layout is not "bls"
Fixes #24836.
2022-09-28 13:36:29 +09:00
Yu Watanabe 8aeccfdedf mkosi: install fdisk for test-loop-block 2022-09-28 03:06:27 +09:00
Yu Watanabe baf0ab691c test: add test for dissect_image_file() 2022-09-28 03:06:27 +09:00
Yu Watanabe 08f14be417 dissect-image: introduce dissect_image_file() which works for regular file 2022-09-28 03:06:27 +09:00
Yu Watanabe 698bb074a3 dissect-image: split-out dissected_image_probe_filesystem()
No functional changes, just preparation for later commits.
2022-09-28 03:06:27 +09:00
Yu Watanabe a13231a904 Merge pull request #24832 from mrc0mmand/more-TEST-64-tweaks
A couple of performance tweaks for TEST-64 under QEMU
2022-09-28 02:26:55 +09:00
Yu Watanabe b577d5569d Merge pull request #24812 from yuwata/udev-drop-netlink
udev: drop workaround for slow read of phys_port_name sysattr
2022-09-27 14:10:02 +09: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
Yu Watanabe 778e3da95e sd-network: drop fallback values
This drops spurious lines in `networkctl status` for unmanaged interfaces.
Before:
```
$ networkctl status --lines 0 lo
● 1: lo
                     Link File: n/a
                  Network File: n/a
                          Type: loopback
                         State: carrier (unmanaged)
                  Online state: unknown
                    HW Address: 00:00:00:00:00:00
                           MTU: 65536
                         QDisc: noqueue
  IPv6 Address Generation Mode: eui64
          Queue Length (Tx/Rx): 1/1
                       Address: 127.0.0.1
                                ::1
             Activation Policy: up
           Required For Online: yes
```
After:
```
$ networkctl status --lines 0 lo
● 1: lo
                     Link File: n/a
                  Network File: n/a
                         State: carrier (unmanaged)
                  Online state: unknown
                          Type: loopback
              Hardware Address: 00:00:00:00:00:00
                           MTU: 65536
                         QDisc: noqueue
  IPv6 Address Generation Mode: eui64
      Number of Queues (Tx/Rx): 1/1
                       Address: 127.0.0.1
                                ::1
```

That is, the lines for Activation Policy and Required For Online are
dropped.
2022-09-27 10:42:31 +09:00
Yu Watanabe c9d22489ca sd-network: introduce network_link_get_boolean() helper function 2022-09-27 10:42:31 +09:00
Yu Watanabe 27b13df45a sd-network: accept all space-like separators 2022-09-27 10:42:31 +09:00
Yu Watanabe ce2e75021c sd-network: propagate -ENOENT
On -ENOENT, it suggests that network-manager is not running, and
interfaces are not unmanaged. Such information may be useful for
callers.
2022-09-27 10:42:31 +09:00
Yu Watanabe e7c1b3f73a sd-network: rename function arguments for storing return value 2022-09-27 10:42:27 +09:00
Yu Watanabe f1d07d83ab networkctl: use table_add_string_line() at one more place 2022-09-27 10:41:21 +09:00
Yu Watanabe 8f60c998ab networkctl: handle all errors in sd_network_link_get_setup_state() as "unmanaged"
We have already ignored all errors in other fields.
2022-09-27 10:41:13 +09:00
Yu Watanabe 5bbcfbaa11 udev: drop workaround for slow read of phys_port_name sysattr
TL;DR
This effectively reverts 8327fd1b11,
eaba9bb3e6, and its follow-ups, as the
original issue was already fixed by the kernel side.

The original issue that the above commits tried to 'fix' is that reading
phys_port_name triggers a lock in the kernel, hence processing multiple
interfaces at the same time causes extreme slow down.
To workaround the issue, the above commits made several necessary
information retrieved through netlink instead of sysfs attributes.

A patch set for the kernel was proposed as a fix for the issue:
https://lore.kernel.org/all/20210928125500.167943-1-atenart@kernel.org/
and some of them were merged to v5.16:
https://github.com/torvalds/linux/commit/146e5e733310379f51924111068f08a3af0db830,
It has been already backported to 5.4.160, 5.10.80, 5.14.19, and 5.15.3.

When these commits were proposed, it is already claimed that such issue
should be fixed by the kernel side, and udevd should not workaround it.
Neverthless the feature was introduced, as these have theoretical
performance improvement, even if phys_port_name sysattr does not have the
above issue, as in that way udevd can obtain multiple information about
the interface with a single netlink socket operation. See the discussion
in #20744.

However, in reality, only `iflink`, `type`, `address`, and `phys_port_name`
attributes from netlink are used in the udev net_id builtin command. Hence,
after the original issue being fixed in the kernel side, there should be
almost no performance improvement for udevd.
Furthermore, combining attributes from netlink and sysfs makes hard to
test net_id builtin. See #21725.

Let's drop mostly meaningless code, and make net_id builtin easily testable.

Closes #21725.
2022-09-27 10:01:46 +09:00
Yu Watanabe bb1bc2fcb0 sd-device: introduce device_get_sysattr_int() 2022-09-25 13:59:49 +09:00
Yu Watanabe 395c1d9a85 tpm2-util: fix build with -Dopenssl=false
Fixes #24800.
2022-09-25 08:03:19 +09:00
Yu Watanabe e0f435f935 meson: libfido2 requires openssl
Fixes compile error with -Dopenssl=false.
```
In file included from ../../home/watanabe/git/systemd/src/shared/pkcs11-util.h:12,
                 from ../../home/watanabe/git/systemd/src/cryptenroll/cryptenroll.c:24:
../../home/watanabe/git/systemd/src/shared/openssl-util.h:56:21: error: conflicting types for ‘X509’; have ‘struct X509’
   56 | typedef struct X509 X509;
      |                     ^~~~
In file included from /usr/include/openssl/crypto.h:25,
                 from /usr/include/openssl/bio.h:20,
                 from /usr/include/openssl/asn1.h:16,
                 from /usr/include/openssl/ec.h:17,
                 from /usr/include/fido.h:10,
                 from ../../home/watanabe/git/systemd/src/shared/libfido2-util.h:18,
                 from ../../home/watanabe/git/systemd/src/cryptenroll/cryptenroll-fido2.h:7,
                 from ../../home/watanabe/git/systemd/src/cryptenroll/cryptenroll.c:6:
/usr/include/openssl/ossl_typ.h:123:24: note: previous declaration of ‘X509’ with type ‘X509’ {aka ‘struct x509_st’}
  123 | typedef struct x509_st X509;
      |                        ^~~~
```
2022-09-25 07:53:06 +09:00
Yu Watanabe e56074a212 tmpfiles: fix wrong return value
Follow-up for 27f6aa0b71.
2022-09-24 13:44:42 +02:00
Yu Watanabe 3b51a183af tree-wide: fix typo 2022-09-24 10:43:58 +09:00
Yu Watanabe 78f14b2ff0 README: drop graphs counting issues or PRs
These cannot be accessible anymore.
2022-09-23 18:29:22 +09:00
Yu Watanabe 0b0cdb1652 doc: drop remaining references to LGTM.com 2022-09-23 18:29:22 +09:00
Yu Watanabe f8d7c0c55e networkctl: re-order entries in status command
Also fixes "Speed:" field, which may show empty value.
2022-09-23 11:20:26 +09:00
Yu Watanabe 767bc538c5 test-network: fix matching string
This partially reverts 5515f2169c.
As the commit changes 'networkctl list', not 'networkctl status'.
2022-09-23 10:43:17 +09:00
Yu Watanabe 3874765735 networkctl: use "-" for empty LLDP entries 2022-09-23 10:39:42 +09:00
Yu Watanabe 67c3e1f63a udev: support by-path devlink for multipath nvme block devices
If multipath feature is enabled, nvme block devices may belong to the
"nvme-subsystem" subsystem, instead of "nvme" subsystem.
(What a confusing name...)

Then, the syspath is something like the following,
    /sys/devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1
Hence, we need to find the 'real parent' device, such as
    /sys/devices/pci0000:00/0000:00:1c.4/0000:3c:00.0/nvme/nvme0

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2031810.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2124964.
Replaces #24748.
2022-09-23 10:21:46 +09:00
Yu Watanabe 68f2134954 Merge pull request #24790 from poettering/run-chdir
run: let's make --working-directory= just work with --scope
2022-09-23 10:20:14 +09:00
Yu Watanabe 96f974e47f network: use FOREACH_DEVICE_CHILD_WITH_SUFFIX() macro 2022-09-23 07:03:19 +09:00
Yu Watanabe 29c1fb3cb3 network: fix assertion triggered by passing wrong ifindex 2022-09-23 07:03:18 +09:00
Yu Watanabe 78463c6c4f udev-builtin-net_id: use FOREACH_DEVICE_CHILD_WITH_SUFFIX() macro 2022-09-23 07:03:18 +09:00
Yu Watanabe fadc8c48ac test-sd-device: add tests for sd_device_get_child_first() and _next() 2022-09-23 07:03:18 +09:00
Yu Watanabe ec9b4f2b92 sd-device: introduce sd_device_get_child_first() and _next()
These functions provide a high-level interface for enumerating
child devices.

Suggested at https://github.com/systemd/systemd/pull/24731#discussion_r973987065.
2022-09-23 07:03:15 +09:00
Yu Watanabe 10a2f90d02 sd-device: refuse to get a parent device by sd_device_new_child() 2022-09-23 06:53:09 +09:00
Yu Watanabe fb227a3de1 test-17-udev: test that device units for nonexistent devlink are removed
For issue #24518.
2022-09-21 05:58:40 +09:00
Yu Watanabe ede0fe0271 test-64-storage: add test for renaming lvm volume 2022-09-21 05:58:40 +09:00
Yu Watanabe 9c126b2c92 test-64-udev-storage: check device units 2022-09-21 05:58:40 +09:00
Yu Watanabe a4cb8afb8f core/device: check that no unit is ready and not simultaneously
This should not happen, just for safety.
2022-09-21 05:58:40 +09:00
Yu Watanabe c352110adc core/device: refuse alias with ".." 2022-09-21 05:58:40 +09:00
Yu Watanabe 4228306b9d core/device: always update existing devlink or alias units on uevent
Previously, existing device units for devlinks or aliases were not
removed unless the main device unit is removed. This makes all existing
device units for devlinks and aliases are checked if they are still
required, and remove if not necessary anymore.

Fixes #24518.
2022-09-21 05:58:37 +09:00
Yu Watanabe 9616f550b8 core/device: introduce device_propagate_reload() 2022-09-21 03:12:12 +09:00
Yu Watanabe c072b84c7e core/device: introduce device_by_path() helper function 2022-09-21 03:12:12 +09:00
Yu Watanabe 1cb89339bc core/device: removed devices are not ready 2022-09-21 03:12:12 +09:00
Yu Watanabe ef9ca572e1 core/device: use DEVICE_NOT_FOUND 2022-09-21 03:12:12 +09:00
Yu Watanabe 0a935bb850 Merge pull request #24711 from poettering/verify_fsroot_dir-rework
find-esp: rework verify_fsroot_dir()  a bit
2022-09-21 00:56:00 +09:00
Yu Watanabe 2f9d231738 udev: use block_device_is_whole_disk()
No functional changes, just refactoring.

Note, this also makes synthesize_change() propagate the error from
synthesize_change_one(). However, the caller of synthesize_change()
ignores the failure anyway, hence the change does not take any effect.
2022-09-20 09:44:19 +02:00
Yu Watanabe 83b94cf10e sd-device: use fd_reopen() at one more place
It provides recognizable error if /proc is not mounted.
2022-09-20 09:41:34 +02:00
Yu Watanabe 57c15ca357 meson: make several tests run sequentially
Follow-up for f93ba37530.
2022-09-20 02:56:57 +09:00
Yu Watanabe 8ef0fc7acc Merge pull request #24744 from yuwata/mkdir-chase-symlinks
mkdir: chase_symlinks_and_stat() does not return 0
2022-09-20 01:43:00 +09:00
Yu Watanabe f8d5048dbf test: add more test cases for mkdir_p_safe() and mkdir_p_root() 2022-09-19 22:55:47 +09:00
Yu Watanabe f1d93b84bc mkdir: chase_symlinks_and_stat() does not return 0
This reverts commits e22916e61d and
1e146d7382.
2022-09-19 22:54:05 +09:00
Yu Watanabe 4b544b5ffd Merge pull request #24742 from keszybz/hwdb-252
hwdb update for v252-rc1
2022-09-19 22:51:13 +09:00
Yu Watanabe 97268bdf6f udev: use device_opendir() 2022-09-19 19:44:33 +09:00
Yu Watanabe 62ccd11d38 sd-device: use device_opendir() 2022-09-19 19:42:36 +09:00
Yu Watanabe db3049b6f0 sd-device: introduce device_opendir() 2022-09-19 19:42:02 +09:00
Yu Watanabe a80ce209b9 udev: use sd_device_get_sysattr_value()
No functional changes, just refactoring.
2022-09-19 18:04:13 +09:00
Yu Watanabe c42033e7be udev: use faccessat()
No functional changes, just refactoring.
2022-09-19 18:04:13 +09:00
Yu Watanabe 4bc9d8165b sd-device: re-implement device_sysattrs_read_all() without recursion 2022-09-19 18:04:13 +09:00
Yu Watanabe 5b304c7052 sd-device: use faccessat()
No functional changes, just refactoring.
2022-09-19 18:04:13 +09:00
Yu Watanabe 65c0f14bc1 sd-device: use fstatat()
No functional changes, just refactoring.
2022-09-19 18:04:13 +09:00
Yu Watanabe bc5e8ebbfb sd-device: use path_hash_ops to store sysattrs
As the stored values are actually path. Just for safety.

This also drops unnecessary duplication of path.
2022-09-19 18:04:12 +09:00
Yu Watanabe d64b44be52 test: add testcase for link priority 2022-09-19 06:08:58 +09:00
Yu Watanabe 5b4671ec47 Merge pull request #24646 from yuwata/udev-node-symlink_atomic
udev: introduce symlink_atomic_full() and use it
2022-09-19 05:25:58 +09:00
Yu Watanabe 3afe230d4a Merge pull request #24725 from yuwata/blockdev-util-introduce-block_device_get_whole_disk
blockdev-util: introduce block_device_get_whole_disk()
2022-09-19 05:25:09 +09:00
Yu Watanabe 626f15a4c1 Merge pull request #24730 from yuwata/dissect-image-drop-reference-to-decrypted-image
dissect-image: introduce dissected_image_relinquish()
2022-09-19 05:24:35 +09:00
Yu Watanabe 28f9bcd65a path-util: add examples for path_make_relative() and path_make_relative_parent()
Addresses https://github.com/systemd/systemd/pull/24646#discussion_r973691797.
2022-09-19 00:30:29 +09:00
Yu Watanabe e330f97a89 tree-wide: drop unused reference to DecryptedImage 2022-09-18 23:47:20 +09:00
Yu Watanabe 3044d343dd tree-wide: use dissected_image_relinquish() 2022-09-18 23:47:20 +09:00
Yu Watanabe f906075a15 dissect-image: introduce dissected_image_relinquish() 2022-09-18 23:47:20 +09:00
Yu Watanabe d50c55bd43 udev: do not ignore -ENOENT from sd_device_get_devname() for block device
We already checked that the sd_device object 'dev' is for a whole block
device. So, -ENOENT should not be triggeered here, and if it is, there
exists something spurious. Hence we should not ignore the failure.
2022-09-18 23:32:24 +09:00
Yu Watanabe 8f71534e06 udev: use block_device_get_whole_disk()
This should not change anything effectively.
2022-09-18 23:30:21 +09:00
Yu Watanabe 6d42138593 udev-node: use symlink_atomic_full_label() to create devlink
If the filename of a device symlink is too long, then the temporary
filename may become invalid, and we fail to create symlink.

The function `tempfn_random()` used in symlink_atomic_full() generates
a safe temporary filename.

Note that, thanks to the PR #23043, now only one worker can handle
the same symlink simultaneously. Hence, the device ID based temporary
filename is not necessary.
2022-09-18 23:23:23 +09:00
Yu Watanabe 5a27af52c7 blockdev-util: change return value when a partition device is passed to partition_enumerator_new()
To make it consistent what returned by block_device_get_whole_disk().
2022-09-18 22:54:20 +09:00
Yu Watanabe 55a437f8b2 blockdev-util: introduce block_device_get_whole_disk() 2022-09-18 22:54:20 +09:00
Yu Watanabe c07186ec03 blockdev-util: split-out block_device_is_whole_disk()
No functional changes, just preparation for later commits.
2022-09-18 22:54:20 +09:00
Yu Watanabe 8b6a70f699 Merge pull request #24719 from yuwata/dissect-image-dissected-image-new
dissect-image: introduce dissected_image_new()
2022-09-18 22:41:49 +09:00
Yu Watanabe 23d3dfc369 sd-device: refuse block device without subsystem
Previously, even if sd_device_get_subsystem() returns -ENOENT for block
device, we accepted that. This makes the check slightly stricter.
2022-09-18 15:35:56 +02:00
Yu Watanabe 0f75b0c589 dissect-image: free crypt_device object before trying to activate with unique name
Otherwise we get error from libcryptsetup like the following:
systemd[1234]: Cannot use device /dev/loop5 which is in use (already mapped or mounted).
2022-09-18 11:19:33 +02:00
Yu Watanabe a1c3628b19 udev: downgrade log level when device node is already removed
Follow-up for 790da548b0.
2022-09-18 10:51:25 +02:00
Yu Watanabe babd5b08b5 dissect-image: introduce DISSECTED_PARTITION_NULL
Currently, it is not necessary to set partno or architecture in
dissect_image_new(), but just for safety.
Preparation for later commits.
2022-09-18 17:26:22 +09:00
Yu Watanabe 00e295055b dissect-image: split out dissected_image_new()
To make dissect_image() shorter.
No functional changes, just refactoring.
2022-09-18 17:26:22 +09:00
Yu Watanabe 1e63dc4f1c dissect-image: take a reference of LoopDevice into DissectedImage
To make LoopDevice object freed after DissectedImage is freed.
At least currently, this should not change anything. Preparation for
later commits.
2022-09-18 07:56:32 +09:00
Yu Watanabe 36d5eb0bff loop-util: introduce reference counter for LoopDevice 2022-09-18 07:56:32 +09:00