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: #29298Fixes: #28583
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-'.
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.
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).
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.
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.
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.
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.
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.
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.
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().
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.