Commit Graph
2550 Commits
Author SHA1 Message Date
Lennart Poettering 1617424ce7 udev: raise RLIMIT_NOFILE as high as we can
We might need a lot of fds on large systems, hence raise RLIMIT_NOFILE
to what the service manager allows us, which is quite a lot these days.

udev already sets FORK_RLIMIT_NOFILE_SAFE when forking of chilren, thus
ensuring that forked off processes get their RLIMIT_NOFILE soft limit
reset to 1K for compat with crappy old select().

Replaces: #29298
Fixes: #28583
2023-09-26 13:01:02 +02:00
Lennart Poettering 8fcacaf046 scsi_serial: convert from nanosleep() to usleep_safe() 2023-09-20 12:07:28 +02:00
Lennart Poettering 7b9da3861a Revert "tree-wide: Mount file descriptors via /proc/<pid>/fd" 2023-09-08 22:13:09 +01:00
Mike Yuan e22c60a9d5 io-util: introduce loop_write_full that takes a timeout
Also drop do_poll as the use case is covered
by timeout.
2023-09-07 20:30:44 +08:00
Daan De Meyer 2af02e6165 tree-wide: Always include <net/if.h> before related linux headers
Otherwise, we get redefinition errors if <net/if.h> is included later
on by another header.
2023-08-14 13:16:46 +02:00
Yu Watanabe 5cdcaf89be meson: drop unnecessary dependency on libidn 2023-08-12 20:04:51 +09:00
Yu Watanabe 8aa0aa40cf udev-builtin-net_id: use strjoin() if possible
Addresses the post-merge comment
https://github.com/systemd/systemd/pull/28623#pullrequestreview-1571307466.
2023-08-10 20:13:43 +09:00
Yu Watanabe f5f1e766ba udev-builtin-net_id: add more debugging logs 2023-08-10 20:09:11 +09:00
Yu Watanabe ce8ff47f74 udev-builtin-net_id: introduce get_first_syspath_component() helper function
Obtaining a component from syspath is a common pattern. Let's split out
the pattern. No functional change, just refactoring.
2023-08-10 20:09:11 +09:00
Yu Watanabe 5dc06b376f udev-builtin-net_id: introduce get_matching_parent() helper function
The pattern is common in many naming scheme. Let's split out the
pattern. No functional change, just refactoring.
2023-08-10 20:09:06 +09:00
Yu Watanabe c27d9c0ac1 udev-builtin-net_id: fix potential invalid memory access
Follow-up for 28141620d9.

Addresses post-merge review in #28269.
2023-08-10 05:13:17 +09:00
Yu Watanabe 3787934b54 proc-cmdline: make proc_cmdline_get_bool() take flags
All other command line parsers takes flags. Let's make
proc_cmdline_get_bool() also take flags. Though, currently,
no flag is set by the caller.
2023-08-09 17:46:41 +09:00
Yu Watanabe 9289e093ae meson: use install_emptydir() and drop meson-make-symlink.sh
The script is mostly equivalent to 'mkdir -p' and 'ln -sfr'.
Let's replace it with install_emptydir() builtin function and
inline meson call.
2023-08-08 22:11:34 +01:00
Yu Watanabe 2cba1d3753 udev: allow to set the maximum number of worker process to 0
In that case, the maximum is calculated based on the system resources.
2023-08-05 15:40:02 +09:00
Yu Watanabe ce5ddbc465 udev: split out manager_set_default_children_max() 2023-08-05 15:39:58 +09:00
Yu Watanabe cbc55c4cce meson: also merge declarations of fuzzers with other executables 2023-08-03 20:37:16 +09:00
Yu Watanabe 130c87b16a meson: merge declarations of normal and test executables 2023-08-03 20:37:16 +09:00
Yu Watanabe 09fa0a0721 test: rename udev-rule-runner -> test-udev-rule-runner
This partially revert 0454cf05d3.
The executable actually does not work with itself, but needs to be
combined with test-udev.py. But, even so, the executable is for testing.

In the next commit, test and normal executables are declared in the same
way, and naming of the executable becomes essential to classify them.
Let's rename the executable and prefix with 'test-'.
2023-08-03 20:37:16 +09:00
Yu Watanabe adedcd39a8 meson: use template to declare udev plugins 2023-08-03 20:37:16 +09:00
Yu Watanabe 12b4cffdae meson: introduce HAVE_DMI flag
The condition is used at several places. Let's introduce a simple flag
for that.
2023-08-03 20:37:16 +09:00
Luca Boccassi 6639ac474e Merge pull request #28623 from yuwata/udev-builtin-net_id-cleanups
udev: several cleanups for net_id builtin (part 4)
2023-08-01 22:09:32 +01:00
Daan De Meyer 54c3326066 Merge pull request #28620 from yuwata/meson-use-template-part5
meson: use template to declare executables (part 5)
2023-08-01 18:10:52 +02:00
Yu Watanabe 82cb5f2ad1 udev-builtin-net_id: first parse USB or BCMA identifier, then parse PCI properties
Previously, we first generate names based on the PCI slot and ACPI
onboard index, and then append an identifier based on USB or BCMA bus
if it exists in between the PCI bus and the interface.

However, if there exists USB or BCMA bus, the name based on the
ACPI onboard index is not used.

So, let's invert the order; first generate USB or BCMA identifier if the
bus exists, then prepend the name with the PCI slot identifier.

With this change, we can drop Names struct, and each naming logic
becomes self-consistent.
2023-08-02 00:00:32 +09:00
Yu Watanabe 415ade00aa udev-builtin-net_id: split out names_pci_onboard_label() from dev_pci_onboard()
Then call it only when it is necessary. The label is used only when the
interface is directly connected to the PCI bus, and it does not have the
SR-IOV feature (or the naming based on SR-IOV is disabled).
2023-08-01 23:35:34 +09:00
Yu Watanabe f831aef509 udev-builtin-net_id: drop redundant copy of BCMA identifier in names_bcma()
Then, this makes names based on the BCMA and PCI identifiers in
names_bcma().

No functional change, just refactoring.
2023-08-01 23:35:34 +09:00
Yu Watanabe d3523818e8 udev-builtin-net_id: split out get_bcma_specifier() from names_bcma()
This contains redundant copy of BCMA identifier, but that will be
dropped in the next commit.

No functional change, just refactoring and preparation for later
commits.
2023-08-01 23:35:34 +09:00
Yu Watanabe f7ae5d1857 udev-builtin-net_id: drop redundant copy of USB identifier in names_usb()
This makes the names based on the USB identifier (and possibly with PCI
specifier) built in names_usb()

No functional change, just refactoring.
2023-08-01 23:35:34 +09:00
Yu Watanabe 045fb967a7 udeb-builtin-net_id: split out get_usb_specifier() from names_usb()
This contains redundant copy of USB identifier, but that will be
dropped in the next commit.

No functional change, just refactoring and preparation for later
commits.
2023-08-01 23:35:34 +09:00
Yu Watanabe 5371c26933 meson: move declarations of socket-proxy, udevadm, quotacheck, and shutdown 2023-08-01 21:37:31 +09:00
Yu Watanabe 5660e68d65 udev-builtin-net_id: fix potential buffer overflow 2023-08-01 21:34:12 +09:00
Yu Watanabe a1008b2dab udev-builtin-net_id: various coding style cleanups 2023-08-01 21:34:12 +09:00
Yu Watanabe 64d2358397 udev-builtin-net_id: introduce device_is_stacked() helper function
Then, we can drop LinkInfo struct.
No functional change, just refactoring.
2023-08-01 21:34:12 +09:00
Yu Watanabe dc999c0346 udev-builtin-net_id: drop unused arguments 2023-08-01 21:34:12 +09:00
Yu Watanabe d6ec0fe229 udev-builtin-net_id: split-out pci_get_onboard_index() from dev_pci_onboard()
This also changes the onboard index type to unsigned, as it is at most
2^16 - 1. Hence, unsigned is enough.

Then, we can use device_get_sysattr_unsigned() helper function.

This also drops mostly redundant debugging logs. The index will be
logged later anyway.
2023-08-01 11:20:48 +09:00
Yu Watanabe 51524b82a2 udev-builtin-net_id: split-out get_pci_slot_specifiers()
Then, we can replace multiple strpcpyf() with single snprintf_ok().

No functional change, just refactoring.
2023-08-01 10:56:46 +09:00
Yu Watanabe 82234e2a21 udev-builtin-net_id: introduce get_port_specifier() helper function
To make the port specifier unified.
No functional change, just refactoring.
2023-08-01 10:56:26 +09:00
Yu Watanabe 4d756471d9 udev-builtin-net_id: split out get_dev_port() and make its failure critical
As dev_port and dev_id sysfs attributes are fundamental properties for
network interfaces. Hence, it should not fail.

Also, the type of dev_port is changed to unsigned. The kernel internally
uses 'unsigned short' for dev_port and dev_id. Hence, unsigned (that is,
32 bits) is still overkill, but should be enough.
2023-08-01 10:56:26 +09:00
Yu Watanabe f1e3eaa730 udev-builtin-net_id: split-out pci_get_hotplug_slot() and pci_get_hotplug_slot_from_address()
No functional changes, just refactoring.
2023-08-01 10:55:51 +09:00
Yu Watanabe 73fb4b20c1 udev-builtin-net_id: return earlier when hotplug slot is not found
Then we can reduce indentation.
No functional change, just refactoring.
2023-08-01 09:26:15 +09:00
Yu Watanabe 4103dca1b5 udev-builtin-net_id: skip non-directory entry earlier
In the below, we will try to read 'address' file in the directory,
hence the entry must be a directory.

No functional change, just a tiny optimization.
2023-08-01 09:26:15 +09:00
Yu Watanabe 114085932c udev: fix typo in comment
Follow-ups for ded2b1d093 and
3327877ca3.
2023-08-01 02:39:16 +09:00
Yu Watanabe c0af9dee0d udev: move declaration of ResolveNameTiming to udev-rules.c
It is only used by udevd and udevadm, not necessary in src/shared.

This also moves UDEV_NAME_SIZE and friends.
2023-07-31 23:23:00 +09:00
Yu Watanabe 04a1ee5867 udev: move udev_parse_config_full() to udevd.c
Then, rename it to manager_parse_udev_config().

No functional change, just refactoring.
2023-07-31 23:23:00 +09:00
Yu Watanabe 5d7e51b10e udev: rename test-udevd.c -> test-udev-manager.c 2023-07-31 23:23:00 +09:00
Yu Watanabe 81c32b1d41 udev: split udevd.c into two 2023-07-31 23:23:00 +09:00
Yu Watanabe 6bd4bad6b9 udev: move arg_xyz into Manager
No functional changes, just preparation for later commits.
2023-07-31 23:23:00 +09:00
Yu Watanabe 79d2ecaf63 udev: drop mostly unused Manager.pid
It is only used by the assertion in event_queue_insert().
We have similar check e.g. in sd-bus or sd-event, but udevd.c is not a
library code, hence such check is not necessary.
2023-07-31 23:23:00 +09:00
Yu Watanabe 8ebc7314e8 udev: merge manager_clear_for_worker() with manager_free()
The function manager_clear_for_worker() is now not called by workers,
and only called from manager_free(). Let's merge them.

This also drops unused Manager.rtnl, and outdated comment in
event_free().
2023-07-31 23:23:00 +09:00
Yu Watanabe 987b90f93f udev: split-out worker code from udevd.c
While doing that, the Manager object allocated by the main process
is now _not_ freed in the spawned worker process, to follow our usual
coding style. See discussion in #24043.
2023-07-31 23:23:00 +09:00
Yu Watanabe 0226729181 udev: move several functions from udev-util.c to relevant udevd source files
The functions are only used by udevd (and relevant tests), hence it is
not necessary to be in src/shared.
2023-07-31 23:23:00 +09:00