1
0
mirror of https://github.com/systemd/systemd synced 2025-10-01 09:44:46 +02:00

Compare commits

..

16 Commits

Author SHA1 Message Date
Lennart Poettering
1f3315b8bd update NEWS 2021-02-19 08:45:34 +09:00
Lennart Poettering
66e52d2221 update TODO 2021-02-18 22:31:11 +01:00
Yu Watanabe
38ba3da0a1 network: rename UseFQDN= -> UseHostname=
Prompted by
https://github.com/systemd/systemd/pull/18543#issuecomment-780798451.
2021-02-18 21:47:37 +01:00
Lennart Poettering
988338eb19
Merge pull request #18685 from poettering/network-type-tweaks
sd-network.h type tweaks
2021-02-18 21:19:51 +01:00
Lennart Poettering
1a8900e7ed random-util: fix type of random_u64_range()
As the name of the function suggests this is supposed to return
uint64_t, of course. Fix it. Not sure how this mistake happened in the
first place...
2021-02-18 21:19:23 +01:00
Lennart Poettering
e55daa2599
Merge pull request #18546 from poettering/sd-device-action
export sd_device_get_action() API + more
2021-02-18 20:54:25 +01:00
chri2
ba2b8f9239 https://github.com/systemd/systemd/issues/15360
The additional rules fix a firmware bug in the en keyboard of Librem notebooks by Purism.

By doing so the break the keyboard with other layouts which do not have the same bug in their firmware.
2021-02-18 20:49:12 +01:00
Lennart Poettering
f715584018 resolved: improve debug logging on incoming messages a bit 2021-02-18 20:34:18 +01:00
Zbigniew Jędrzejewski-Szmek
e133c454b1
Merge pull request #18679 from keszybz/rfkill-size-leniency
struct rfkill_event read/write size leniency
2021-02-18 19:53:25 +01:00
Lennart Poettering
ff03bfa508 udevadm: after validating action, use our internal string instead of optarg
This doesn't really change anything, but feels nicer, since it abstracts
away what device_action_from_string()/device_action_to_string() do
internally, and always uses a normalized action string (yes, there's no
ambiguity, but it's nice to stay abstract, maybe one day there is
ambiguity around this)
2021-02-18 18:21:25 +01:00
Lennart Poettering
a113002214 sd-device: add sd_device_get_action() + sd_device_get_seqnum() + sd_device_new_from_stat_rdev()
To make sd-device properly usable for all programs we need to provide an
API for the "action" field of an event, it's one of the most relevant
ones, and it was so far missing.

This also adds sd_device_get_seqnum(), which isn't that interesting,
except for generating pretty debug output, which we use it ourselves
for.

This also makes device_new_from_stat_rdev() public, as it is truly
useful, as we can see in our own uses of it, and I think is fairly
generic to show up in the public APIs.
2021-02-18 18:20:56 +01:00
Lennart Poettering
96fb82aa06 sd-device: don't compare pointers with numeric zero
Our coding style says no to this.
2021-02-18 18:20:09 +01:00
Lennart Poettering
135c4aad4c network: tighten table alignment a bit 2021-02-18 18:17:16 +01:00
Lennart Poettering
2324fd3a39 network: suffix types with _t in public headers
Apparently, in our current public headers (i.e. those called sd-*.h) we
suffixed typedefs that we use as values with _t, but we didn't do this
for enum typedefs. Fix that while this stuff is not actually public yet.

With this scheme "value typedefs" now end systematically in _t, and
"object typedefs" (i.e. structures that are typically passed around via
pointers and not values) do not.

No code changes, just some renaming.
2021-02-18 18:17:16 +01:00
Zbigniew Jędrzejewski-Szmek
a71c096850 rfkill: use short writes and accept long reads
I'm seeing the following with kernel-core-5.10.16-200.fc33.x86_64:

$ sudo SYSTEMD_LOG_LEVEL=debug build/systemd-rfkill
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 0 and type bluetooth.
Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Found container virtualization none.
rfkill0: Operating on rfkill device 'tpacpi_bluetooth_sw'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/platform-thinkpad_acpi:bluetooth.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 1 and type wwan.
rfkill1: Operating on rfkill device 'tpacpi_wwan_sw'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/platform-thinkpad_acpi:wwan.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 2 and type bluetooth.
rfkill2: Operating on rfkill device 'hci0'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/pci-0000:00:14.0-usb-0:7:1.0:bluetooth.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 3 and type wlan.
rfkill3: Operating on rfkill device 'phy0'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/pci-0000:04:00.0:wlan.
All events read and idle, exiting.

We were expecting a read of exactly RFKILL_EVENT_SIZE_V1==8 bytes. But the
structure has 9 after [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=14486c82612a177cb910980c70ba900827ca0894

For some reason the kernel does not accept the full structure size, but cuts
the write short after 8 bytes:

static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
				size_t count, loff_t *pos)
{
	struct rfkill_event ev;

	/* we don't need the 'hard' variable but accept it */
	if (count < RFKILL_EVENT_SIZE_V1 - 1)
		return -EINVAL;

	/*
	 * Copy as much data as we can accept into our 'ev' buffer,
	 * but tell userspace how much we've copied so it can determine
	 * our API version even in a write() call, if it cares.
	 */
	count = min(count, sizeof(ev));
	if (copy_from_user(&ev, buf, count))
		return -EFAULT;

... so it should accept the full size. I'm not sure what is going on here.

But we don't care about the extra fields, so let's accept a write as long as
it's at least RFKILL_EVENT_SIZE_V1.

Fixes #18677.
2021-02-18 11:25:04 +01:00
Zbigniew Jędrzejewski-Szmek
6c7afdeab0 rfkill: improve error logging
If we get something of unexpected size, log the sizes. Also, don't log twice.
2021-02-18 10:40:16 +01:00
65 changed files with 411 additions and 315 deletions

126
NEWS
View File

@ -28,26 +28,38 @@ CHANGES WITH 248:
used to configure dm-verity behaviour for the root device.
* The key file specified in /etc/crypttab (the third field) may now
refer to a UNIX socket path. The key is acquired by connecting to
that socket and reading from it. This allows the implementation of a
service to provide key information dynamically, at the moment when it
is needed.
refer to an AF_UNIX/SOCK_STREAM socket in the file system. The key is
acquired by connecting to that socket and reading from it. This
allows the implementation of a service to provide key information
dynamically, at the moment when it is needed.
* Support has been added for extracting the PKCS#11 token URI and
encrypted key from the LUKS2 JSON embedded metadata header. This
allows the information how to open the encrypted device to be
embedded directly in the device and obviates the need for
configuration in an external file.
* Support has been added to systemd-cryptsetup for extracting the
PKCS#11 token URI and encrypted key from the LUKS2 JSON embedded
metadata header. This allows the information how to open the
encrypted device to be embedded directly in the device and obviates
the need for configuration in an external file.
* LUKS devices may now be unlocked using TPM2 hardware.
* systemd-cryptsetup gained support for unlocking LUKS2 volumes using
TPM2 hardware, as well as FIDO2 security tokens.
* systemd-repart may lock partitions using TPM2 hardware. This may be
useful for example to create an encrypted /var partition bound to the
machine on first boot.
* A new systemd-cryptenroll tool has been added to enroll FIDO2+PKCS#11
security tokens to LUKS volumes, list and destroy them. See
https://www.freedesktop.org/software/systemd/man/systemd-cryptenroll.html.
* A new systemd-cryptenroll tool has been added to enroll TPM2, FIDO2
and PKCS#11 security tokens to LUKS volumes, list and destroy
them. See:
http://0pointer.net/blog/unlocking-luks2-volumes-with-tpm2-fido2-pkcs11-security-hardware-on-systemd-248.html
It also supports enrolling "recovery keys" and regular passphrases.
* The libfido2 dependency is now based on dlopen(), so that the library
is used at runtime when installed, but not if not.
* systemd-cryptsetup gained support for two new options in
/etc/crypttab: no-write-workqueue and no-read-workqueue which request
synchronous processing of encryption/decryption IO.
* The manager may be configured at compile time to use fexecve instead
of execve when spawning children. Using fexecve closes a window
@ -58,8 +70,8 @@ CHANGES WITH 248:
* The configuration option -Dcompat-gateway-hostname has been dropped.
"_gateway" is now the only supported name.
* The ConditionSecurity=tpm2 unit file setting may be used to check
if the system has at least one TPM2 (tpmrm class) device.
* The ConditionSecurity=tpm2 unit file setting may be used to check if
the system has at least one TPM2 (tpmrm class) device.
* The tables of system calls in seccomps filters are now automatically
generated from kernel lists exported on
@ -89,13 +101,25 @@ CHANGES WITH 248:
* The ExecPaths= and NoExecPaths= settings may be used to specify
noexec for parts of the file system.
* sd-bus has a new function sd_bus_open_use_machine() to open a
* sd-bus has a new function sd_bus_open_user_machine() to open a
connection to the session bus of a specific user in a local container
or on the local host. It also gained a convenience function
sd_bus_reply() to call sd_bus_send() with an existing reply message.
or on the local host. This is exposed in the -M switch to systemctl
and similar tools:
* sd-event allows rate limits to be set on event sources. See the new
man page sd_event_source_set_ratelimit(3) for details.
systemctl --user -M lennart@foobar start foo
This will connect to the user bus of a user "lennart" in container
"foobar". If no container name is specified, the specified user on
the host itself is connected to
systemctl --user -M lennart@ start quux
* sd-bus also gained a convenience function sd_bus_reply() to call
sd_bus_send() with an existing reply message.
* sd-event allows rate limits to be set on event sources, for dealing
with high-priority event sources that might starve out others. See
the new man page sd_event_source_set_ratelimit(3) for details.
* systemd.link files gained a [Link] Promiscuous= switch, which allows
the device to be raised in promiscuous mode.
@ -128,6 +152,11 @@ CHANGES WITH 248:
systemd.network files gained a [DHCPv6PrefixDelegation]
ManageTemporaryAddress= switch.
.network files gained a new ActivationPolicy= setting which allows
configuraiton how the UP state of an interface shall be managed,
i.e. whether the iterface is always upped, always downed, or may be
upped/downed by the user using "ip dev".
* systemd.netdev files gained a [VLAN] Protocol=, IngressQOSMaps=,
EgressQOSMaps=, and [MACVLAN] BroadcastMulticastQueueLength=
configuration options for VLAN packet handling.
@ -139,10 +168,10 @@ CHANGES WITH 248:
* udev now exports the VOLUME_ID, LOGICAL_VOLUME_ID, VOLUME_SET_ID, and
DATA_PREPARED_ID attributes for block devices (when available).
* udev now exports decoded DMI information about memory under the
/sys/class/dmi/id/ pseudo device.
* udev now exports decoded DMI information about used memory slots as
device properties under the /sys/class/dmi/id/ pseudo device.
* /dev is not mounted noexec any more. This didn't provide any
* /dev/ is not mounted noexec any more. This didn't provide any
significant security benefits and would conflicts with the executable
mappings used with /dev/sgx device nodes.
@ -158,12 +187,27 @@ CHANGES WITH 248:
DNS query and respond with a mostly unmodified packet received from
the upstream server.
* systemd-resolved learnt a new boolean option CacheFromLocalhost= in
resolved.conf. If true the service will provide caching even for DNS
lookups made to an upstream DNS server on the 127.0.0.1/::1
addresses. By default (and when the option is false) systemd-resolved
will not cache such lookups, in order to avoid duplicate local
caching, under the assumption the local upstream server caches
anyway.
* systemd-nspawn gained a new --ambient-capability= setting
(AmbientCapability= in .nspawn files) to configure ambient
capabilities passed to the container payload.
* systemd-nspawn gained the ability to configure the firewall using the
nft subsystem (in addition to the existing iptables support).
nftables subsystem (in addition to the existing iptables
support). Similar, systemd-networkd's IPMasquerade= option now
supports nftables as backend, too. In both cases NAT on IPv6 is now
supported too, in addition to IPv4 (the iptables backend still is
IPv4-only).
* systemd-importd will now download .verity and .roothash.p7s files
along with the machine image (as exposed via machinectl pull-raw).
* systemd-oomd now gained a new DefaultMemoryPressureDurationSec=
setting to configure the time a unit's cgroup needs to exceed memory
@ -188,15 +232,20 @@ CHANGES WITH 248:
the configured hostname ("static", "transient", or "fallback") as
D-Bus properties.
* systemd-hostnamed now exports the HardwareVendor and HardwareModel
D-Bus properties. hostnamectl shows this in the status output.
* systemd-hostnamed now exports the "HardwareVendor" and
"HardwareModel" D-Bus properties, which are supposed to contain a
pair of cleaned up, human readable strings describing the system
vendor and model. It's typically source from the firmware's DMI
tables, but may be augmented from a new hwdb database. hostnamectl
shows this in the status output.
* systemd-localed may now call locale-gen to generate missing locales
on-demand (UTF-8-only). This improves integration with Debian-based
distributions (Debian/Ubuntu/PureOS/Tanglu/...) and Arch Linux.
* systemctl --check-inhibitors may now be used to obey inhibitors even
when invoked non-interactively.
* systemctl --check-inhibitors=true may now be used to obey inhibitors
even when invoked non-interactively. The old --ignore-inhibitors
switch is now deprecated and replaced by --check-inhibitors=false.
* systemctl import-environment will now emit a warning when called
without any arguments (i.e. to import the full environment block of
@ -211,6 +260,11 @@ CHANGES WITH 248:
directly calling the D-Bus API of the manager, should also push
specific variables, and not the full inherited environment.
* systemctl's status output now shows unit state with a more careful
selection of Unicode characters: units in maintainance show a "○"
symbol instead of the usual "●", failed units show "×", and services
being reloaded "↻".
* coredumpctl gained a --debugger-arguments= switch to pass arguments
to the debugger.
@ -219,12 +273,13 @@ CHANGES WITH 248:
* Various tools gained --pager/--no-pager/--json switches to
enable/disable the pager and provide JSON output.
* Various tools now accept SYSTEMD_COLORS=16|256 to configure what
colours are used in output.
* Various tools now accept SYSTEMD_COLORS=16|256 to configure how
many terminal colours are used in output.
* less 568 or newer is now required. Link markup is now always used,
and older versions will not display it properly. SYSTEMD_URLIFY=0 may
be used to disable it.
* less 568 or newer is now required. Hyperlink ANSI sequences in
termina output are now used even if a pager is used, and older
versions of less are not able to display these sequences
correctly. SYSTEMD_URLIFY=0 may be used to disable it.
* Builds with support for separate / and /usr hierarchies (split-usr
builds, non-merged-usr builds) are now officially deprecated. A
@ -237,6 +292,11 @@ CHANGES WITH 248:
for partitions, as in the vast majority of cases they contain none
and are used internally by the bootloader (eg: uboot).
* systemd will now set the $SYSTEMD_EXEC_PID environment variable for
spawned processes to the PID of the process itself. This may be used
by programs for detecting whether they were forked off by the service
manager itself or are a process forked off further down the tree.
CHANGES WITH 247:
* KERNEL API INCOMPATIBILITY: Linux 4.14 introduced two new uevents

12
TODO
View File

@ -20,6 +20,18 @@ Janitorial Clean-ups:
Features:
* add an Open= setting to service unit files that can open arbitrary file
system paths at service startup time and pass them to the service process via
our usual socket activation protocol. If passed path refers to AF_UNIX
socket: connect() to it.
* add a ConnectSocket= setting to service unit files, that may reference a
socket unit, and which will connect to the socket defined therein, and pass
the resulting fd to the service program via socket activation proto.
* Add a concept of ListenStream=anonymous to socket units: listen on a socket
that is deleted in the fs. Usecase would be with ConnectSocket= above.
* Hook up journald's FSS logic with TPM2: seal the verification disk by
time-based policy, so that the verification key can remain on host and ve
validated via TPM.

View File

@ -1463,17 +1463,29 @@ evdev:input:b0003v047FpC006*
# Purism
###########################################################
# Purism Librem 13 V2
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v2*:*
KEYBOARD_KEY_56=backslash
# Purism Librem 13 V3
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v3*:*
KEYBOARD_KEY_56=backslash
# Purism Librem 13 V4
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v4*:*
KEYBOARD_KEY_56=backslash
# If you're using an us layout keyboard in one of the below models of
# Purism Librem 13 consider copying this file to /etc/systemd/hwdb.d/
# to enable the following rule acording to your model.
#
# There's a bug in the keyboards firmware and the additional rule
# will make your keyboard behave as expected.
#
# More info:
# - https://github.com/systemd/systemd/issues/15360
# - https://github.com/systemd/systemd/pull/11516
# - https://tracker.pureos.net/T888
#
# # Purism Librem 13 V2
# evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v2*:*
# KEYBOARD_KEY_56=backslash
#
# # Purism Librem 13 V3
# evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v3*:*
# KEYBOARD_KEY_56=backslash
#
# # Purism Librem 13 V4
# evdev:atkbd:dmi:bvn*:bvr*:bd*:svnPurism*:pn*Librem13v4*:*
# KEYBOARD_KEY_56=backslash
###########################################################
# Quanta

View File

@ -1935,18 +1935,12 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
<varlistentry>
<term><varname>UseDNS=</varname></term>
<term><varname>UseNTP=</varname></term>
<term><varname>UseHostname=</varname></term>
<listitem>
<para>As in the [DHCPv4] section.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>UseFQDN=</varname></term>
<listitem>
<para>Equivalent of <varname>UseHostname=</varname> in the [DHCPv4] section.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>RouteMetric=</varname></term>
<listitem>

View File

@ -495,7 +495,7 @@ int random_write_entropy(int fd, const void *seed, size_t size, bool credit) {
return 1;
}
int random_u64_range(uint64_t m) {
uint64_t random_u64_range(uint64_t m) {
uint64_t x, remainder;
/* Generates a random number in the range 0…m-1, unbiased. (Java's algorithm) */

View File

@ -41,4 +41,4 @@ size_t random_pool_size(void);
int random_write_entropy(int fd, const void *seed, size_t size, bool credit);
int random_u64_range(uint64_t max);
uint64_t random_u64_range(uint64_t max);

View File

@ -7,7 +7,6 @@
#include "bus-error.h"
#include "dbus-device.h"
#include "dbus-unit.h"
#include "device-private.h"
#include "device-util.h"
#include "device.h"
#include "log.h"
@ -916,8 +915,8 @@ static int device_remove_old(Manager *m, sd_device *dev) {
}
static int device_dispatch_io(sd_device_monitor *monitor, sd_device *dev, void *userdata) {
sd_device_action_t action;
Manager *m = userdata;
DeviceAction action;
const char *sysfs;
int r;
@ -930,22 +929,22 @@ static int device_dispatch_io(sd_device_monitor *monitor, sd_device *dev, void *
return 0;
}
r = device_get_action(dev, &action);
r = sd_device_get_action(dev, &action);
if (r < 0) {
log_device_error_errno(dev, r, "Failed to get udev action: %m");
return 0;
}
if (!IN_SET(action, DEVICE_ACTION_ADD, DEVICE_ACTION_REMOVE, DEVICE_ACTION_MOVE))
if (!IN_SET(action, SD_DEVICE_ADD, SD_DEVICE_REMOVE, SD_DEVICE_MOVE))
device_propagate_reload_by_sysfs(m, sysfs);
if (action == DEVICE_ACTION_MOVE)
if (action == SD_DEVICE_MOVE)
(void) device_remove_old(m, dev);
/* A change event can signal that a device is becoming ready, in particular if the device is using
* the SYSTEMD_READY logic in udev so we need to reach the else block of the following if, even for
* change events */
if (action == DEVICE_ACTION_REMOVE) {
if (action == SD_DEVICE_REMOVE) {
r = swap_process_device_remove(m, dev);
if (r < 0)
log_device_warning_errno(dev, r, "Failed to process swap device remove event, ignoring: %m");
@ -1013,7 +1012,7 @@ static int validate_node(Manager *m, const char *node, sd_device **ret) {
} else {
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
r = device_new_from_stat_rdev(&dev, &st);
r = sd_device_new_from_stat_rdev(&dev, &st);
if (r == -ENOENT) {
*ret = NULL;
return 1; /* good! (though missing) */

View File

@ -10,7 +10,6 @@
#include "alloc-util.h"
#include "dbus-swap.h"
#include "dbus-unit.h"
#include "device-private.h"
#include "device-util.h"
#include "device.h"
#include "escape.h"
@ -307,7 +306,7 @@ static int swap_load_devnode(Swap *s) {
if (stat(s->what, &st) < 0 || !S_ISBLK(st.st_mode))
return 0;
r = device_new_from_stat_rdev(&d, &st);
r = sd_device_new_from_stat_rdev(&d, &st);
if (r < 0) {
log_unit_full_errno(UNIT(s), r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
"Failed to allocate device for swap %s: %m", s->what);
@ -510,7 +509,7 @@ static int swap_process_new(Manager *m, const char *device, int prio, bool set_f
if (stat(device, &st) < 0 || !S_ISBLK(st.st_mode))
return 0;
r = device_new_from_stat_rdev(&d, &st);
r = sd_device_new_from_stat_rdev(&d, &st);
if (r < 0) {
log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
"Failed to allocate device for swap %s: %m", device);

View File

@ -1234,7 +1234,7 @@ static int manager_on_device(sd_device_monitor *monitor, sd_device *d, void *use
assert(m);
assert(d);
if (device_for_action(d, DEVICE_ACTION_REMOVE)) {
if (device_for_action(d, SD_DEVICE_REMOVE)) {
const char *sysfs;
Home *h;

View File

@ -30,7 +30,6 @@
#include "catalog.h"
#include "chattr-util.h"
#include "def.h"
#include "device-private.h"
#include "dissect-image.h"
#include "fd-util.h"
#include "fileio.h"
@ -207,7 +206,7 @@ static int add_matches_for_device(sd_journal *j, const char *devpath) {
if (stat(devpath, &st) < 0)
return log_error_errno(errno, "Couldn't stat file: %m");
r = device_new_from_stat_rdev(&device, &st);
r = sd_device_new_from_stat_rdev(&device, &st);
if (r < 0)
return log_error_errno(r, "Failed to get device from devnum %u:%u: %m", major(st.st_rdev), minor(st.st_rdev));

View File

@ -35,5 +35,5 @@ struct sd_lldp {
#define log_lldp_errno(error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "LLDP: " fmt, ##__VA_ARGS__)
#define log_lldp(fmt, ...) log_lldp_errno(0, fmt, ##__VA_ARGS__)
const char* lldp_event_to_string(sd_lldp_event e) _const_;
sd_lldp_event lldp_event_from_string(const char *s) _pure_;
const char* lldp_event_to_string(sd_lldp_event_t e) _const_;
sd_lldp_event_t lldp_event_from_string(const char *s) _pure_;

View File

@ -40,5 +40,5 @@ struct sd_ndisc {
#define log_ndisc_errno(error, fmt, ...) log_internal(LOG_DEBUG, error, PROJECT_FILE, __LINE__, __func__, "NDISC: " fmt, ##__VA_ARGS__)
#define log_ndisc(fmt, ...) log_ndisc_errno(0, fmt, ##__VA_ARGS__)
const char* ndisc_event_to_string(sd_ndisc_event e) _const_;
sd_ndisc_event ndisc_event_from_string(const char *s) _pure_;
const char* ndisc_event_to_string(sd_ndisc_event_t e) _const_;
sd_ndisc_event_t ndisc_event_from_string(const char *s) _pure_;

View File

@ -99,7 +99,7 @@ int sd_dhcp_lease_get_mtu(sd_dhcp_lease *lease, uint16_t *mtu) {
int sd_dhcp_lease_get_servers(
sd_dhcp_lease *lease,
sd_dhcp_lease_server_type what,
sd_dhcp_lease_server_type_t what,
const struct in_addr **addr) {
assert_return(lease, -EINVAL);
@ -281,7 +281,7 @@ static sd_dhcp_lease *dhcp_lease_free(sd_dhcp_lease *lease) {
free(lease->hostname);
free(lease->domainname);
for (sd_dhcp_lease_server_type i = 0; i < _SD_DHCP_LEASE_SERVER_TYPE_MAX; i++)
for (sd_dhcp_lease_server_type_t i = 0; i < _SD_DHCP_LEASE_SERVER_TYPE_MAX; i++)
free(lease->servers[i].addr);
free(lease->static_route);

View File

@ -149,7 +149,7 @@ static sd_dhcp_server *dhcp_server_free(sd_dhcp_server *server) {
free(server->timezone);
for (sd_dhcp_lease_server_type i = 0; i < _SD_DHCP_LEASE_SERVER_TYPE_MAX; i++)
for (sd_dhcp_lease_server_type_t i = 0; i < _SD_DHCP_LEASE_SERVER_TYPE_MAX; i++)
free(server->servers[i].addr);
hashmap_free(server->leases_by_client_id);
@ -509,7 +509,7 @@ static int server_send_ack(
return r;
}
for (sd_dhcp_lease_server_type k = 0; k < _SD_DHCP_LEASE_SERVER_TYPE_MAX; k++) {
for (sd_dhcp_lease_server_type_t k = 0; k < _SD_DHCP_LEASE_SERVER_TYPE_MAX; k++) {
if (server->servers[k].size <= 0)
continue;
@ -1118,7 +1118,7 @@ int sd_dhcp_server_set_default_lease_time(sd_dhcp_server *server, uint32_t t) {
int sd_dhcp_server_set_servers(
sd_dhcp_server *server,
sd_dhcp_lease_server_type what,
sd_dhcp_lease_server_type_t what,
const struct in_addr addresses[],
size_t n_addresses) {

View File

@ -21,13 +21,13 @@
#define LLDP_DEFAULT_NEIGHBORS_MAX 128U
static const char * const lldp_event_table[_SD_LLDP_EVENT_MAX] = {
[SD_LLDP_EVENT_ADDED] = "added",
[SD_LLDP_EVENT_REMOVED] = "removed",
[SD_LLDP_EVENT_ADDED] = "added",
[SD_LLDP_EVENT_REMOVED] = "removed",
[SD_LLDP_EVENT_UPDATED] = "updated",
[SD_LLDP_EVENT_REFRESHED] = "refreshed",
};
DEFINE_STRING_TABLE_LOOKUP(lldp_event, sd_lldp_event);
DEFINE_STRING_TABLE_LOOKUP(lldp_event, sd_lldp_event_t);
static void lldp_flush_neighbors(sd_lldp *lldp) {
assert(lldp);
@ -35,7 +35,7 @@ static void lldp_flush_neighbors(sd_lldp *lldp) {
hashmap_clear(lldp->neighbor_by_id);
}
static void lldp_callback(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n) {
static void lldp_callback(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor *n) {
assert(lldp);
assert(event >= 0 && event < _SD_LLDP_EVENT_MAX);

View File

@ -28,9 +28,9 @@ static const char * const ndisc_event_table[_SD_NDISC_EVENT_MAX] = {
[SD_NDISC_EVENT_ROUTER] = "router",
};
DEFINE_STRING_TABLE_LOOKUP(ndisc_event, sd_ndisc_event);
DEFINE_STRING_TABLE_LOOKUP(ndisc_event, sd_ndisc_event_t);
static void ndisc_callback(sd_ndisc *ndisc, sd_ndisc_event event, sd_ndisc_router *rt) {
static void ndisc_callback(sd_ndisc *ndisc, sd_ndisc_event_t event, sd_ndisc_router *rt) {
assert(ndisc);
assert(event >= 0 && event < _SD_NDISC_EVENT_MAX);

View File

@ -30,7 +30,7 @@ int lldp_network_bind_raw_socket(int ifindex) {
return test_fd[0];
}
static void lldp_handler(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n, void *userdata) {
static void lldp_handler(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor *n, void *userdata) {
lldp_handler_calls++;
}

View File

@ -232,7 +232,7 @@ int icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr) {
return send_ra_function(0);
}
static void test_callback(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *rt, void *userdata) {
static void test_callback(sd_ndisc *nd, sd_ndisc_event_t event, sd_ndisc_router *rt, void *userdata) {
sd_event *e = userdata;
static unsigned idx = 0;
uint64_t flags_array[] = {

View File

@ -745,4 +745,8 @@ global:
sd_event_source_set_ratelimit;
sd_event_source_get_ratelimit;
sd_event_source_is_ratelimited;
sd_device_get_action;
sd_device_get_seqnum;
sd_device_new_from_stat_rdev;
} LIBSYSTEMD_247;

View File

@ -76,7 +76,7 @@ struct sd_device {
gid_t devgid;
/* only set when device is passed through netlink */
DeviceAction action;
sd_device_action_t action;
uint64_t seqnum;
bool parent_set:1; /* no need to try to reload parent */

View File

@ -183,20 +183,8 @@ static int device_set_devgid(sd_device *device, const char *gid) {
return 0;
}
int device_get_action(sd_device *device, DeviceAction *action) {
assert(device);
if (device->action < 0)
return -ENOENT;
if (action)
*action = device->action;
return 0;
}
static int device_set_action(sd_device *device, const char *action) {
DeviceAction a;
sd_device_action_t a;
int r;
assert(device);
@ -206,7 +194,7 @@ static int device_set_action(sd_device *device, const char *action) {
if (a < 0)
return a;
r = device_add_property_internal(device, "ACTION", action);
r = device_add_property_internal(device, "ACTION", device_action_to_string(a));
if (r < 0)
return r;
@ -215,18 +203,6 @@ static int device_set_action(sd_device *device, const char *action) {
return 0;
}
int device_get_seqnum(sd_device *device, uint64_t *seqnum) {
assert(device);
if (device->seqnum == 0)
return -ENOENT;
if (seqnum)
*seqnum = device->seqnum;
return 0;
}
static int device_set_seqnum(sd_device *device, const char *str) {
uint64_t seqnum;
int r;
@ -355,7 +331,12 @@ static int device_amend(sd_device *device, const char *key, const char *value) {
return 0;
}
static int device_append(sd_device *device, char *key, const char **_major, const char **_minor) {
static int device_append(
sd_device *device,
char *key,
const char **_major,
const char **_minor) {
const char *major = NULL, *minor = NULL;
char *value;
int r;
@ -384,10 +365,10 @@ static int device_append(sd_device *device, char *key, const char **_major, cons
return r;
}
if (major != 0)
if (major)
*_major = major;
if (minor != 0)
if (minor)
*_minor = minor;
return 0;
@ -719,22 +700,6 @@ int device_new_from_synthetic_event(sd_device **new_device, const char *syspath,
return 0;
}
int device_new_from_stat_rdev(sd_device **ret, const struct stat *st) {
char type;
assert(ret);
assert(st);
if (S_ISBLK(st->st_mode))
type = 'b';
else if (S_ISCHR(st->st_mode))
type = 'c';
else
return -ENOTTY;
return sd_device_new_from_devnum(ret, type, st->st_rdev);
}
int device_copy_properties(sd_device *device_dst, sd_device *device_src) {
const char *property, *value;
int r;
@ -998,19 +963,19 @@ int device_delete_db(sd_device *device) {
return 0;
}
static const char* const device_action_table[_DEVICE_ACTION_MAX] = {
[DEVICE_ACTION_ADD] = "add",
[DEVICE_ACTION_REMOVE] = "remove",
[DEVICE_ACTION_CHANGE] = "change",
[DEVICE_ACTION_MOVE] = "move",
[DEVICE_ACTION_ONLINE] = "online",
[DEVICE_ACTION_OFFLINE] = "offline",
[DEVICE_ACTION_BIND] = "bind",
[DEVICE_ACTION_UNBIND] = "unbind",
static const char* const device_action_table[_SD_DEVICE_ACTION_MAX] = {
[SD_DEVICE_ADD] = "add",
[SD_DEVICE_REMOVE] = "remove",
[SD_DEVICE_CHANGE] = "change",
[SD_DEVICE_MOVE] = "move",
[SD_DEVICE_ONLINE] = "online",
[SD_DEVICE_OFFLINE] = "offline",
[SD_DEVICE_BIND] = "bind",
[SD_DEVICE_UNBIND] = "unbind",
};
DEFINE_STRING_TABLE_LOOKUP(device_action, DeviceAction);
DEFINE_STRING_TABLE_LOOKUP(device_action, sd_device_action_t);
void dump_device_action_table(void) {
DUMP_STRING_TABLE(device_action, DeviceAction, _DEVICE_ACTION_MAX);
DUMP_STRING_TABLE(device_action, sd_device_action_t, _SD_DEVICE_ACTION_MAX);
}

View File

@ -10,22 +10,8 @@
#include "macro.h"
typedef enum DeviceAction {
DEVICE_ACTION_ADD,
DEVICE_ACTION_REMOVE,
DEVICE_ACTION_CHANGE,
DEVICE_ACTION_MOVE,
DEVICE_ACTION_ONLINE,
DEVICE_ACTION_OFFLINE,
DEVICE_ACTION_BIND,
DEVICE_ACTION_UNBIND,
_DEVICE_ACTION_MAX,
_DEVICE_ACTION_INVALID = -EINVAL,
} DeviceAction;
int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len);
int device_new_from_strv(sd_device **ret, char **strv);
int device_new_from_stat_rdev(sd_device **ret, const struct stat *st);
int device_get_id_filename(sd_device *device, const char **ret);
@ -34,8 +20,6 @@ int device_get_watch_handle(sd_device *device, int *handle);
int device_get_devnode_mode(sd_device *device, mode_t *mode);
int device_get_devnode_uid(sd_device *device, uid_t *uid);
int device_get_devnode_gid(sd_device *device, gid_t *gid);
int device_get_action(sd_device *device, DeviceAction *action);
int device_get_seqnum(sd_device *device, uint64_t *seqnum);
void device_seal(sd_device *device);
void device_set_is_initialized(sd_device *device);
@ -73,6 +57,6 @@ static inline int device_read_db(sd_device *device) {
return device_read_db_internal(device, false);
}
DeviceAction device_action_from_string(const char *s) _pure_;
const char *device_action_to_string(DeviceAction a) _const_;
sd_device_action_t device_action_from_string(const char *s) _pure_;
const char *device_action_to_string(sd_device_action_t a) _const_;
void dump_device_action_table(void);

View File

@ -43,7 +43,7 @@ int device_new_aux(sd_device **ret) {
.devmode = (mode_t) -1,
.devuid = (uid_t) -1,
.devgid = (gid_t) -1,
.action = _DEVICE_ACTION_INVALID,
.action = _SD_DEVICE_ACTION_INVALID,
};
*ret = device;
@ -316,6 +316,22 @@ _public_ int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *s
return -ENODEV;
}
_public_ int sd_device_new_from_stat_rdev(sd_device **ret, const struct stat *st) {
char type;
assert_return(ret, -EINVAL);
assert_return(st, -EINVAL);
if (S_ISBLK(st->st_mode))
type = 'b';
else if (S_ISCHR(st->st_mode))
type = 'c';
else
return -ENOTTY;
return sd_device_new_from_devnum(ret, type, st->st_rdev);
}
int device_set_devtype(sd_device *device, const char *devtype) {
_cleanup_free_ char *t = NULL;
int r;
@ -1052,6 +1068,30 @@ _public_ int sd_device_get_sysnum(sd_device *device, const char **ret) {
return 0;
}
_public_ int sd_device_get_action(sd_device *device, sd_device_action_t *ret) {
assert_return(device, -EINVAL);
if (device->action < 0)
return -ENOENT;
if (ret)
*ret = device->action;
return 0;
}
_public_ int sd_device_get_seqnum(sd_device *device, uint64_t *ret) {
assert_return(device, -EINVAL);
if (device->seqnum == 0)
return -ENOENT;
if (ret)
*ret = device->seqnum;
return 0;
}
static bool is_valid_tag(const char *tag) {
assert(tag);

View File

@ -25,9 +25,9 @@ static const genl_family genl_families[] = {
int sd_genl_socket_open(sd_netlink **ret) {
return netlink_open_family(ret, NETLINK_GENERIC);
}
static int lookup_id(sd_netlink *nl, sd_genl_family family, uint16_t *id);
static int lookup_id(sd_netlink *nl, sd_genl_family_t family, uint16_t *id);
static int genl_message_new(sd_netlink *nl, sd_genl_family family, uint16_t nlmsg_type, uint8_t cmd, sd_netlink_message **ret) {
static int genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint16_t nlmsg_type, uint8_t cmd, sd_netlink_message **ret) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
const NLType *genl_cmd_type, *nl_type;
const NLTypeSystem *type_system;
@ -71,7 +71,7 @@ static int genl_message_new(sd_netlink *nl, sd_genl_family family, uint16_t nlms
return 0;
}
int sd_genl_message_new(sd_netlink *nl, sd_genl_family family, uint8_t cmd, sd_netlink_message **ret) {
int sd_genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint8_t cmd, sd_netlink_message **ret) {
uint16_t id;
int r;
@ -82,7 +82,7 @@ int sd_genl_message_new(sd_netlink *nl, sd_genl_family family, uint8_t cmd, sd_n
return genl_message_new(nl, family, id, cmd, ret);
}
static int lookup_id(sd_netlink *nl, sd_genl_family family, uint16_t *id) {
static int lookup_id(sd_netlink *nl, sd_genl_family_t family, uint16_t *id) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL, *reply = NULL;
uint16_t u;
void *v;
@ -127,7 +127,7 @@ static int lookup_id(sd_netlink *nl, sd_genl_family family, uint16_t *id) {
return 0;
}
int nlmsg_type_to_genl_family(const sd_netlink *nl, uint16_t type, sd_genl_family *ret) {
int nlmsg_type_to_genl_family(const sd_netlink *nl, uint16_t type, sd_genl_family_t *ret) {
void *p;
assert_return(nl, -EINVAL);
@ -151,7 +151,7 @@ int nlmsg_type_to_genl_family(const sd_netlink *nl, uint16_t type, sd_genl_famil
return 0;
}
int sd_genl_message_get_family(const sd_netlink *nl, const sd_netlink_message *m, sd_genl_family *family) {
int sd_genl_message_get_family(const sd_netlink *nl, const sd_netlink_message *m, sd_genl_family_t *family) {
uint16_t type;
int r;

View File

@ -3,4 +3,4 @@
#include "sd-netlink.h"
int nlmsg_type_to_genl_family(const sd_netlink *nl, uint16_t type, sd_genl_family *ret);
int nlmsg_type_to_genl_family(const sd_netlink *nl, uint16_t type, sd_genl_family_t *ret);

View File

@ -1636,7 +1636,7 @@ const NLTypeSystem *type_system_get_root(int protocol) {
}
int type_system_root_get_type(sd_netlink *nl, const NLType **ret, uint16_t type) {
sd_genl_family family;
sd_genl_family_t family;
const NLType *nl_type;
int r;

View File

@ -82,7 +82,7 @@ _public_ unsigned long long udev_device_get_seqnum(struct udev_device *udev_devi
assert_return_errno(udev_device, 0, EINVAL);
if (device_get_seqnum(udev_device->device, &seqnum) < 0)
if (sd_device_get_seqnum(udev_device->device, &seqnum) < 0)
return 0;
return seqnum;
@ -693,11 +693,11 @@ _public_ struct udev_list_entry *udev_device_get_properties_list_entry(struct ud
* Returns: the kernel action value, or #NULL if there is no action value available.
**/
_public_ const char *udev_device_get_action(struct udev_device *udev_device) {
DeviceAction action;
sd_device_action_t action;
assert_return_errno(udev_device, NULL, EINVAL);
if (device_get_action(udev_device->device, &action) < 0)
if (sd_device_get_action(udev_device->device, &action) < 0)
return NULL;
return device_action_to_string(action);

View File

@ -246,7 +246,7 @@ int manager_process_seat_device(Manager *m, sd_device *d) {
assert(m);
if (device_for_action(d, DEVICE_ACTION_REMOVE) ||
if (device_for_action(d, SD_DEVICE_REMOVE) ||
sd_device_has_current_tag(d, "seat") <= 0) {
const char *syspath;
@ -317,7 +317,7 @@ int manager_process_button_device(Manager *m, sd_device *d) {
if (r < 0)
return r;
if (device_for_action(d, DEVICE_ACTION_REMOVE) ||
if (device_for_action(d, SD_DEVICE_REMOVE) ||
sd_device_has_current_tag(d, "power-switch") <= 0) {
b = hashmap_get(m->buttons, sysname);

View File

@ -578,7 +578,7 @@ static int manager_dispatch_vcsa_udev(sd_device_monitor *monitor, sd_device *dev
if (sd_device_get_sysname(device, &name) >= 0 &&
startswith(name, "vcsa") &&
device_for_action(device, DEVICE_ACTION_REMOVE))
device_for_action(device, SD_DEVICE_REMOVE))
seat_preallocate_vts(m->seat0);
return 0;

View File

@ -60,7 +60,7 @@ static Address* link_find_dhcp_server_address(Link *link) {
static int link_push_uplink_to_dhcp_server(
Link *link,
sd_dhcp_lease_server_type what,
sd_dhcp_lease_server_type_t what,
sd_dhcp_server *s) {
_cleanup_free_ struct in_addr *addresses = NULL;
@ -307,7 +307,7 @@ int dhcp4_server_configure(Link *link) {
return log_link_error_errno(link, r, "Failed to set default lease time for DHCPv4 server instance: %m");
}
for (sd_dhcp_lease_server_type type = 0; type < _SD_DHCP_LEASE_SERVER_TYPE_MAX; type ++) {
for (sd_dhcp_lease_server_type_t type = 0; type < _SD_DHCP_LEASE_SERVER_TYPE_MAX; type ++) {
if (!link->network->dhcp_server_emit[type].emit)
continue;

View File

@ -1076,9 +1076,10 @@ static int dhcp6_address_acquired(Link *link) {
return r;
}
if (link->network->dhcp6_use_fqdn) {
if (link->network->dhcp6_use_hostname) {
const char *dhcpname = NULL;
_cleanup_free_ char *hostname = NULL;
(void) sd_dhcp6_lease_get_fqdn(link->dhcp6_lease, &dhcpname);
if (dhcpname) {

View File

@ -2823,7 +2823,7 @@ static void serialize_addresses(
char **addresses,
sd_dhcp_lease *lease,
bool conditional,
sd_dhcp_lease_server_type what,
sd_dhcp_lease_server_type_t what,
sd_dhcp6_lease *lease6,
bool conditional6,
int (*lease6_get_addr)(sd_dhcp6_lease*, const struct in6_addr**),

View File

@ -47,7 +47,7 @@ static bool link_lldp_rx_enabled(Link *link) {
return link->network->lldp_mode != LLDP_MODE_NO;
}
static void lldp_handler(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n, void *userdata) {
static void lldp_handler(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor *n, void *userdata) {
Link *link = userdata;
int r;

View File

@ -182,15 +182,15 @@ int manager_connect_bus(Manager *m) {
}
static int manager_udev_process_link(sd_device_monitor *monitor, sd_device *device, void *userdata) {
sd_device_action_t action;
Manager *m = userdata;
DeviceAction action;
Link *link = NULL;
int r, ifindex;
assert(m);
assert(device);
r = device_get_action(device, &action);
r = sd_device_get_action(device, &action);
if (r < 0) {
log_device_debug_errno(device, r, "Failed to get udev action, ignoring device: %m");
return 0;
@ -199,7 +199,7 @@ static int manager_udev_process_link(sd_device_monitor *monitor, sd_device *devi
/* Ignore the "remove" uevent — let's remove a device only if rtnetlink says so. All other uevents
* are "positive" events in some form, i.e. inform us about a changed or new network interface, that
* still exists and we are interested in that. */
if (action == DEVICE_ACTION_REMOVE)
if (action == SD_DEVICE_REMOVE)
return 0;
r = sd_device_get_ifindex(device, &ifindex);

View File

@ -1274,7 +1274,7 @@ static int ndisc_router_handler(Link *link, sd_ndisc_router *rt) {
return 0;
}
static void ndisc_handler(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *rt, void *userdata) {
static void ndisc_handler(sd_ndisc *nd, sd_ndisc_event_t event, sd_ndisc_router *rt, void *userdata) {
Link *link = userdata;
int r;

View File

@ -225,7 +225,7 @@ DHCPv4.RouteMTUBytes, config_parse_mtu,
DHCPv4.FallbackLeaseLifetimeSec, config_parse_dhcp_fallback_lease_lifetime, 0, 0
DHCPv6.UseAddress, config_parse_bool, 0, offsetof(Network, dhcp6_use_address)
DHCPv6.UseDNS, config_parse_dhcp_use_dns, 0, 0
DHCPv6.UseFQDN, config_parse_bool, 0, offsetof(Network, dhcp6_use_fqdn)
DHCPv6.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp6_use_hostname)
DHCPv6.UseNTP, config_parse_dhcp_use_ntp, 0, 0
DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_rapid_commit)
DHCPv6.MUDURL, config_parse_dhcp6_mud_url, 0, 0

View File

@ -373,7 +373,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.dhcp6_use_address = true,
.dhcp6_use_dns = true,
.dhcp6_use_fqdn = true,
.dhcp6_use_hostname = true,
.dhcp6_use_ntp = true,
.dhcp6_rapid_commit = true,
.dhcp6_route_metric = DHCP_ROUTE_METRIC,
@ -664,7 +664,7 @@ static Network *network_free(Network *network) {
free(network->dhcp_server_timezone);
for (sd_dhcp_lease_server_type t = 0; t < _SD_DHCP_LEASE_SERVER_TYPE_MAX; t++)
for (sd_dhcp_lease_server_type_t t = 0; t < _SD_DHCP_LEASE_SERVER_TYPE_MAX; t++)
free(network->dhcp_server_emit[t].addresses);
set_free_free(network->dnssec_negative_trust_anchors);

View File

@ -159,7 +159,7 @@ struct Network {
bool dhcp6_use_address;
bool dhcp6_use_dns;
bool dhcp6_use_dns_set;
bool dhcp6_use_fqdn;
bool dhcp6_use_hostname;
bool dhcp6_use_ntp;
bool dhcp6_use_ntp_set;
bool dhcp6_rapid_commit;

View File

@ -9,35 +9,35 @@
#include "util.h"
static const char* const address_family_table[_ADDRESS_FAMILY_MAX] = {
[ADDRESS_FAMILY_NO] = "no",
[ADDRESS_FAMILY_YES] = "yes",
[ADDRESS_FAMILY_IPV4] = "ipv4",
[ADDRESS_FAMILY_IPV6] = "ipv6",
[ADDRESS_FAMILY_NO] = "no",
[ADDRESS_FAMILY_YES] = "yes",
[ADDRESS_FAMILY_IPV4] = "ipv4",
[ADDRESS_FAMILY_IPV6] = "ipv6",
};
static const char* const routing_policy_rule_address_family_table[_ADDRESS_FAMILY_MAX] = {
[ADDRESS_FAMILY_YES] = "both",
[ADDRESS_FAMILY_IPV4] = "ipv4",
[ADDRESS_FAMILY_IPV6] = "ipv6",
[ADDRESS_FAMILY_YES] = "both",
[ADDRESS_FAMILY_IPV4] = "ipv4",
[ADDRESS_FAMILY_IPV6] = "ipv6",
};
static const char* const nexthop_address_family_table[_ADDRESS_FAMILY_MAX] = {
[ADDRESS_FAMILY_IPV4] = "ipv4",
[ADDRESS_FAMILY_IPV6] = "ipv6",
[ADDRESS_FAMILY_IPV4] = "ipv4",
[ADDRESS_FAMILY_IPV6] = "ipv6",
};
static const char* const duplicate_address_detection_address_family_table[_ADDRESS_FAMILY_MAX] = {
[ADDRESS_FAMILY_NO] = "none",
[ADDRESS_FAMILY_YES] = "both",
[ADDRESS_FAMILY_IPV4] = "ipv4",
[ADDRESS_FAMILY_IPV6] = "ipv6",
[ADDRESS_FAMILY_NO] = "none",
[ADDRESS_FAMILY_YES] = "both",
[ADDRESS_FAMILY_IPV4] = "ipv4",
[ADDRESS_FAMILY_IPV6] = "ipv6",
};
static const char* const dhcp_deprecated_address_family_table[_ADDRESS_FAMILY_MAX] = {
[ADDRESS_FAMILY_NO] = "none",
[ADDRESS_FAMILY_YES] = "both",
[ADDRESS_FAMILY_IPV4] = "v4",
[ADDRESS_FAMILY_IPV6] = "v6",
[ADDRESS_FAMILY_NO] = "none",
[ADDRESS_FAMILY_YES] = "both",
[ADDRESS_FAMILY_IPV4] = "v4",
[ADDRESS_FAMILY_IPV6] = "v6",
};
static const char* const dhcp_lease_server_type_table[_SD_DHCP_LEASE_SERVER_TYPE_MAX] = {
@ -65,7 +65,7 @@ DEFINE_STRING_TABLE_LOOKUP(duplicate_address_detection_address_family, AddressFa
DEFINE_CONFIG_PARSE_ENUM(config_parse_link_local_address_family, link_local_address_family,
AddressFamily, "Failed to parse option");
DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_deprecated_address_family, AddressFamily);
DEFINE_STRING_TABLE_LOOKUP(dhcp_lease_server_type, sd_dhcp_lease_server_type);
DEFINE_STRING_TABLE_LOOKUP(dhcp_lease_server_type, sd_dhcp_lease_server_type_t);
static AddressFamily address_family_compat_from_string(const char *s) {
if (streq_ptr(s, "yes")) /* compat name */

View File

@ -46,8 +46,8 @@ AddressFamily duplicate_address_detection_address_family_from_string(const char
AddressFamily dhcp_deprecated_address_family_from_string(const char *s) _pure_;
const char *dhcp_lease_server_type_to_string(sd_dhcp_lease_server_type t) _const_;
sd_dhcp_lease_server_type dhcp_lease_server_type_from_string(const char *s) _pure_;
const char *dhcp_lease_server_type_to_string(sd_dhcp_lease_server_type_t t) _const_;
sd_dhcp_lease_server_type_t dhcp_lease_server_type_from_string(const char *s) _pure_;
int kernel_route_expiration_supported(void);

View File

@ -46,10 +46,10 @@ int main(int argc, char **argv) {
test_table_sparse(macvlan_mode, NETDEV_MACVLAN_MODE);
test_table_sparse(address_family, ADDRESS_FAMILY);
assert_cc(sizeof(sd_lldp_event) == sizeof(int64_t));
assert_cc(sizeof(sd_ndisc_event) == sizeof(int64_t));
assert_cc(sizeof(sd_dhcp_lease_server_type) == sizeof(int64_t));
assert_cc(sizeof(sd_genl_family) == sizeof(int64_t));
assert_cc(sizeof(sd_lldp_event_t) == sizeof(int64_t));
assert_cc(sizeof(sd_ndisc_event_t) == sizeof(int64_t));
assert_cc(sizeof(sd_dhcp_lease_server_type_t) == sizeof(int64_t));
assert_cc(sizeof(sd_genl_family_t) == sizeof(int64_t));
return EXIT_SUCCESS;
}

View File

@ -1046,7 +1046,8 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
* should hence not attempt to access the query or transaction
* after calling this function. */
log_debug("Processing incoming packet on transaction %" PRIu16" (rcode=%s).",
log_debug("Processing incoming packet of size %zu on transaction %" PRIu16" (rcode=%s).",
p->size,
t->id, dns_rcode_to_string(DNS_PACKET_RCODE(p)));
switch (t->scope->protocol) {
@ -1211,7 +1212,8 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
* servers often do not implement TCP, hence falling back to TCP on fragmentation is
* counter-productive there.) */
log_debug("Reply fragmented, retrying via TCP.");
log_debug("Reply fragmented, retrying via TCP. (Largest fragment size: %zu; Datagram size: %zu)",
p->fragsize, p->size);
retry_with_tcp = true;
}
}

View File

@ -926,8 +926,10 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
p->ifindex = manager_find_ifindex(m, p->family, &p->destination);
}
*ret = TAKE_PTR(p);
log_debug("Received %s UDP packet of size %zu, ifindex=%i, ttl=%i, fragsize=%zu",
dns_protocol_to_string(protocol), p->size, p->ifindex, p->ttl, p->fragsize);
*ret = TAKE_PTR(p);
return 1;
}

View File

@ -135,8 +135,6 @@ static int determine_state_file(
static int load_state(Context *c, const struct rfkill_event *event) {
_cleanup_free_ char *state_file = NULL, *value = NULL;
struct rfkill_event we;
ssize_t l;
int b, r;
assert(c);
@ -168,18 +166,22 @@ static int load_state(Context *c, const struct rfkill_event *event) {
if (b < 0)
return log_error_errno(b, "Failed to parse state file %s: %m", state_file);
we = (struct rfkill_event) {
.op = RFKILL_OP_CHANGE,
struct rfkill_event we = {
.idx = event->idx,
.op = RFKILL_OP_CHANGE,
.soft = b,
};
assert_cc(offsetof(struct rfkill_event, op) < RFKILL_EVENT_SIZE_V1);
assert_cc(offsetof(struct rfkill_event, soft) < RFKILL_EVENT_SIZE_V1);
l = write(c->rfkill_fd, &we, sizeof(we));
ssize_t l = write(c->rfkill_fd, &we, sizeof we);
if (l < 0)
return log_error_errno(errno, "Failed to restore rfkill state for %i: %m", event->idx);
if (l != sizeof(we))
if (l < RFKILL_EVENT_SIZE_V1)
return log_error_errno(SYNTHETIC_ERRNO(EIO),
"Couldn't write rfkill event structure, too short.");
"Couldn't write rfkill event structure, too short (wrote %zd of %zu bytes).",
l, sizeof we);
log_debug("Writing struct rfkill_event successful (%zd of %zu bytes).", l, sizeof we);
log_debug("Loaded state '%s' from %s.", one_zero(b), state_file);
return 0;
@ -305,44 +307,45 @@ static int run(int argc, char *argv[]) {
}
for (;;) {
struct rfkill_event event;
const char *type;
ssize_t l;
struct rfkill_event event = {};
l = read(c.rfkill_fd, &event, sizeof(event));
ssize_t l = read(c.rfkill_fd, &event, sizeof event);
if (l < 0) {
if (errno == EAGAIN) {
if (errno != EAGAIN)
return log_error_errno(errno, "Failed to read from /dev/rfkill: %m");
if (!ready) {
/* Notify manager that we are
* now finished with
* processing whatever was
* queued */
(void) sd_notify(false, "READY=1");
ready = true;
}
/* Hang around for a bit, maybe there's more coming */
r = fd_wait_for_event(c.rfkill_fd, POLLIN, EXIT_USEC);
if (r == -EINTR)
continue;
if (r < 0)
return log_error_errno(r, "Failed to poll() on device: %m");
if (r > 0)
continue;
log_debug("All events read and idle, exiting.");
break;
if (!ready) {
/* Notify manager that we are now finished with processing whatever was
* queued */
(void) sd_notify(false, "READY=1");
ready = true;
}
log_error_errno(errno, "Failed to read from /dev/rfkill: %m");
/* Hang around for a bit, maybe there's more coming */
r = fd_wait_for_event(c.rfkill_fd, POLLIN, EXIT_USEC);
if (r == -EINTR)
continue;
if (r < 0)
return log_error_errno(r, "Failed to poll() on device: %m");
if (r > 0)
continue;
log_debug("All events read and idle, exiting.");
break;
}
if (l != RFKILL_EVENT_SIZE_V1)
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Read event structure of invalid size.");
if (l < RFKILL_EVENT_SIZE_V1)
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read of struct rfkill_event: (%zd < %d)",
l, RFKILL_EVENT_SIZE_V1);
log_debug("Reading struct rfkill_event: got %zd bytes.", l);
type = rfkill_type_to_string(event.type);
/* The event structure has more fields. We only care about the first few, so it's OK if we
* don't read the full structure. */
assert_cc(offsetof(struct rfkill_event, op) < RFKILL_EVENT_SIZE_V1);
assert_cc(offsetof(struct rfkill_event, type) < RFKILL_EVENT_SIZE_V1);
const char *type = rfkill_type_to_string(event.type);
if (!type) {
log_debug("An rfkill device of unknown type %i discovered, ignoring.", event.type);
continue;

View File

@ -247,7 +247,7 @@ static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device,
assert(w);
if (device_for_action(device, DEVICE_ACTION_REMOVE))
if (device_for_action(device, SD_DEVICE_REMOVE))
return 0;
r = sd_device_get_parent(device, &pp);

View File

@ -7,6 +7,7 @@
#include "alloc-util.h"
#include "device-nodes.h"
#include "device-private.h"
#include "device-util.h"
#include "env-file.h"
#include "escape.h"
@ -175,7 +176,7 @@ static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device,
* (And yes, we only need to special case REMOVE. It's the only "negative" event type, where a device
* ceases to exist. All other event types are "positive": the device exists and is registered in the
* udev database, thus whenever we see the event, we can consider it initialized.) */
if (device_for_action(device, DEVICE_ACTION_REMOVE))
if (device_for_action(device, SD_DEVICE_REMOVE))
return 0;
if (data->sysname && sd_device_get_sysname(device, &sysname) >= 0 && streq(sysname, data->sysname))
@ -318,26 +319,29 @@ int device_is_renaming(sd_device *dev) {
return true;
}
bool device_for_action(sd_device *dev, DeviceAction action) {
DeviceAction a;
bool device_for_action(sd_device *dev, sd_device_action_t a) {
sd_device_action_t b;
assert(dev);
if (device_get_action(dev, &a) < 0)
if (a < 0)
return false;
return a == action;
if (sd_device_get_action(dev, &b) < 0)
return false;
return a == b;
}
void log_device_uevent(sd_device *device, const char *str) {
DeviceAction action = _DEVICE_ACTION_INVALID;
sd_device_action_t action = _SD_DEVICE_ACTION_INVALID;
uint64_t seqnum = 0;
if (!DEBUG_LOGGING)
return;
(void) device_get_seqnum(device, &seqnum);
(void) device_get_action(device, &action);
(void) sd_device_get_seqnum(device, &seqnum);
(void) sd_device_get_action(device, &action);
log_device_debug(device, "%s%s(SEQNUM=%"PRIu64", ACTION=%s)",
strempty(str), isempty(str) ? "" : " ",
seqnum, strna(device_action_to_string(action)));

View File

@ -3,7 +3,6 @@
#include "sd-device.h"
#include "device-private.h"
#include "time-util.h"
#define UDEV_NAME_SIZE 512
@ -35,7 +34,8 @@ static inline int udev_parse_config(void) {
int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t deadline, sd_device **ret);
int device_wait_for_devlink(const char *path, const char *subsystem, usec_t deadline, sd_device **ret);
int device_is_renaming(sd_device *dev);
bool device_for_action(sd_device *dev, DeviceAction action);
bool device_for_action(sd_device *dev, sd_device_action_t action);
void log_device_uevent(sd_device *device, const char *str);

View File

@ -5,7 +5,7 @@
int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftype, char **ssid) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL, *reply = NULL;
sd_genl_family family;
sd_genl_family_t family;
int r;
assert(genl);
@ -75,7 +75,7 @@ nodata:
int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL, *reply = NULL;
sd_genl_family family;
sd_genl_family_t family;
int r;
assert(genl);

View File

@ -17,7 +17,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <inttypes.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <sys/types.h>
@ -31,6 +33,20 @@ typedef struct sd_device sd_device;
typedef struct sd_device_enumerator sd_device_enumerator;
typedef struct sd_device_monitor sd_device_monitor;
typedef enum sd_device_action_t {
SD_DEVICE_ADD,
SD_DEVICE_REMOVE,
SD_DEVICE_CHANGE,
SD_DEVICE_MOVE,
SD_DEVICE_ONLINE,
SD_DEVICE_OFFLINE,
SD_DEVICE_BIND,
SD_DEVICE_UNBIND,
_SD_DEVICE_ACTION_MAX,
_SD_DEVICE_ACTION_INVALID = -EINVAL,
_SD_ENUM_FORCE_S64(DEVICE_ACTION),
} sd_device_action_t;
/* callback */
typedef int (*sd_device_monitor_handler_t)(sd_device_monitor *m, sd_device *device, void *userdata);
@ -44,6 +60,7 @@ int sd_device_new_from_syspath(sd_device **ret, const char *syspath);
int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum);
int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname);
int sd_device_new_from_device_id(sd_device **ret, const char *id);
int sd_device_new_from_stat_rdev(sd_device **ret, const struct stat *st);
int sd_device_get_parent(sd_device *child, sd_device **ret);
int sd_device_get_parent_with_subsystem_devtype(sd_device *child, const char *subsystem, const char *devtype, sd_device **ret);
@ -58,6 +75,8 @@ int sd_device_get_devpath(sd_device *device, const char **ret);
int sd_device_get_devname(sd_device *device, const char **ret);
int sd_device_get_sysname(sd_device *device, const char **ret);
int sd_device_get_sysnum(sd_device *device, const char **ret);
int sd_device_get_action(sd_device *device, sd_device_action_t *ret);
int sd_device_get_seqnum(sd_device *device, uint64_t *ret);
int sd_device_get_is_initialized(sd_device *device);
int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec);

View File

@ -34,7 +34,7 @@ typedef struct sd_dhcp_route sd_dhcp_route;
sd_dhcp_lease *sd_dhcp_lease_ref(sd_dhcp_lease *lease);
sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease);
typedef enum sd_dhcp_lease_server_type {
typedef enum sd_dhcp_lease_server_type_t {
SD_DHCP_LEASE_DNS,
SD_DHCP_LEASE_NTP,
SD_DHCP_LEASE_SIP,
@ -44,7 +44,7 @@ typedef enum sd_dhcp_lease_server_type {
_SD_DHCP_LEASE_SERVER_TYPE_MAX,
_SD_DHCP_LEASE_SERVER_TYPE_INVALID = -EINVAL,
_SD_ENUM_FORCE_S64(DHCP_LEASE_SERVER_TYPE),
} sd_dhcp_lease_server_type;
} sd_dhcp_lease_server_type_t;
int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr);
int sd_dhcp_lease_get_lifetime(sd_dhcp_lease *lease, uint32_t *lifetime);
@ -55,7 +55,7 @@ int sd_dhcp_lease_get_netmask(sd_dhcp_lease *lease, struct in_addr *addr);
int sd_dhcp_lease_get_router(sd_dhcp_lease *lease, const struct in_addr **addr);
int sd_dhcp_lease_get_next_server(sd_dhcp_lease *lease, struct in_addr *addr);
int sd_dhcp_lease_get_server_identifier(sd_dhcp_lease *lease, struct in_addr *addr);
int sd_dhcp_lease_get_servers(sd_dhcp_lease *lease, sd_dhcp_lease_server_type what, const struct in_addr **addr);
int sd_dhcp_lease_get_servers(sd_dhcp_lease *lease, sd_dhcp_lease_server_type_t what, const struct in_addr **addr);
int sd_dhcp_lease_get_dns(sd_dhcp_lease *lease, const struct in_addr **addr);
int sd_dhcp_lease_get_ntp(sd_dhcp_lease *lease, const struct in_addr **addr);
int sd_dhcp_lease_get_sip(sd_dhcp_lease *lease, const struct in_addr **addr);

View File

@ -60,7 +60,7 @@ int sd_dhcp_server_set_emit_router(sd_dhcp_server *server, int enabled);
int sd_dhcp_server_set_servers(
sd_dhcp_server *server,
sd_dhcp_lease_server_type what,
sd_dhcp_lease_server_type_t what,
const struct in_addr addresses[],
size_t n_addresses);

View File

@ -122,7 +122,7 @@ enum {
typedef struct sd_lldp sd_lldp;
typedef struct sd_lldp_neighbor sd_lldp_neighbor;
typedef enum sd_lldp_event {
typedef enum sd_lldp_event_t {
SD_LLDP_EVENT_ADDED,
SD_LLDP_EVENT_REMOVED,
SD_LLDP_EVENT_UPDATED,
@ -130,9 +130,9 @@ typedef enum sd_lldp_event {
_SD_LLDP_EVENT_MAX,
_SD_LLDP_EVENT_INVALID = -EINVAL,
_SD_ENUM_FORCE_S64(LLDP_EVENT),
} sd_lldp_event;
} sd_lldp_event_t;
typedef void (*sd_lldp_callback_t)(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n, void *userdata);
typedef void (*sd_lldp_callback_t)(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor *n, void *userdata);
int sd_lldp_new(sd_lldp **ret);
sd_lldp* sd_lldp_ref(sd_lldp *lldp);

View File

@ -55,15 +55,15 @@ enum {
typedef struct sd_ndisc sd_ndisc;
typedef struct sd_ndisc_router sd_ndisc_router;
typedef enum sd_ndisc_event {
typedef enum sd_ndisc_event_t {
SD_NDISC_EVENT_TIMEOUT,
SD_NDISC_EVENT_ROUTER,
_SD_NDISC_EVENT_MAX,
_SD_NDISC_EVENT_INVALID = -EINVAL,
_SD_ENUM_FORCE_S64(NDISC_EVENT),
} sd_ndisc_event;
} sd_ndisc_event_t;
typedef void (*sd_ndisc_callback_t)(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *rt, void *userdata);
typedef void (*sd_ndisc_callback_t)(sd_ndisc *nd, sd_ndisc_event_t event, sd_ndisc_router *rt, void *userdata);
int sd_ndisc_new(sd_ndisc **ret);
sd_ndisc *sd_ndisc_ref(sd_ndisc *nd);

View File

@ -35,7 +35,7 @@ typedef struct sd_genl_socket sd_genl_socket;
typedef struct sd_netlink_message sd_netlink_message;
typedef struct sd_netlink_slot sd_netlink_slot;
typedef enum sd_genl_family {
typedef enum sd_genl_family_t {
SD_GENL_ERROR,
SD_GENL_DONE,
SD_GENL_ID_CTRL,
@ -47,7 +47,7 @@ typedef enum sd_genl_family {
_SD_GENL_FAMILY_MAX,
_SD_GENL_FAMILY_INVALID = -EINVAL,
_SD_ENUM_FORCE_S64(GENL_FAMILY)
} sd_genl_family;
} sd_genl_family_t;
/* callback */
@ -249,8 +249,8 @@ int sd_nfnl_nft_message_add_setelem_end(sd_netlink_message *m);
/* genl */
int sd_genl_socket_open(sd_netlink **nl);
int sd_genl_message_new(sd_netlink *nl, sd_genl_family family, uint8_t cmd, sd_netlink_message **m);
int sd_genl_message_get_family(const sd_netlink *nl, const sd_netlink_message *m, sd_genl_family *family);
int sd_genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint8_t cmd, sd_netlink_message **m);
int sd_genl_message_get_family(const sd_netlink *nl, const sd_netlink_message *m, sd_genl_family_t *family);
/* slot */
sd_netlink_slot *sd_netlink_slot_ref(sd_netlink_slot *nl);

View File

@ -50,7 +50,7 @@ int main(int argc, char **argv) {
test_table(collect_mode, COLLECT_MODE);
test_table(condition_result, CONDITION_RESULT);
test_table(condition_type, CONDITION_TYPE);
test_table(device_action, DEVICE_ACTION);
test_table(device_action, SD_DEVICE_ACTION);
test_table(device_state, DEVICE_STATE);
test_table(dns_over_tls_mode, DNS_OVER_TLS_MODE);
test_table(dnssec_mode, DNSSEC_MODE);
@ -125,5 +125,7 @@ int main(int argc, char **argv) {
test_table_sparse(object_compressed, OBJECT_COMPRESSED);
assert_cc(sizeof(sd_device_action_t) == sizeof(int64_t));
return EXIT_SUCCESS;
}

View File

@ -14,7 +14,6 @@
#include <sys/types.h>
#include <unistd.h>
#include "device-internal.h"
#include "device-private.h"
#include "device-util.h"
#include "fd-util.h"

View File

@ -594,7 +594,7 @@ static int link_config_apply_alternative_names(sd_netlink **rtnl, const link_con
int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device *device, const char **ret_name) {
const char *new_name;
DeviceAction a;
sd_device_action_t a;
int r;
assert(ctx);
@ -602,11 +602,11 @@ int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device
assert(device);
assert(ret_name);
r = device_get_action(device, &a);
r = sd_device_get_action(device, &a);
if (r < 0)
return log_device_error_errno(device, r, "Failed to get ACTION= property: %m");
if (!IN_SET(a, DEVICE_ACTION_ADD, DEVICE_ACTION_BIND, DEVICE_ACTION_MOVE)) {
if (!IN_SET(a, SD_DEVICE_ADD, SD_DEVICE_BIND, SD_DEVICE_MOVE)) {
log_device_debug(device, "Skipping to apply .link settings on '%s' uevent.", device_action_to_string(a));
r = sd_device_get_sysname(device, ret_name);
@ -624,7 +624,7 @@ int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device
if (r < 0)
return r;
if (a == DEVICE_ACTION_MOVE) {
if (a == SD_DEVICE_MOVE) {
log_device_debug(device, "Skipping to apply Name= and NamePolicy= on '%s' uevent.", device_action_to_string(a));
r = sd_device_get_sysname(device, &new_name);

View File

@ -831,7 +831,7 @@ static int rename_netif(UdevEvent *event) {
if (streq(event->name, oldname))
return 0; /* The interface name is already requested name. */
if (!device_for_action(dev, DEVICE_ACTION_ADD))
if (!device_for_action(dev, SD_DEVICE_ADD))
return 0; /* Rename the interface only when it is added. */
r = sd_device_get_ifindex(dev, &ifindex);
@ -904,7 +904,7 @@ static int update_devnode(UdevEvent *event) {
/* If group is set, but mode is not set, "upgrade" mode for the group. */
event->mode = 0660;
bool apply_mac = device_for_action(dev, DEVICE_ACTION_ADD);
bool apply_mac = device_for_action(dev, SD_DEVICE_ADD);
return udev_node_add(dev, apply_mac, event->mode, event->uid, event->gid, event->seclabel_list);
}
@ -975,7 +975,7 @@ int udev_event_execute_rules(UdevEvent *event,
Hashmap *properties_list,
UdevRules *rules) {
const char *subsystem;
DeviceAction action;
sd_device_action_t action;
sd_device *dev;
int r;
@ -988,11 +988,11 @@ int udev_event_execute_rules(UdevEvent *event,
if (r < 0)
return log_device_error_errno(dev, r, "Failed to get subsystem: %m");
r = device_get_action(dev, &action);
r = sd_device_get_action(dev, &action);
if (r < 0)
return log_device_error_errno(dev, r, "Failed to get ACTION: %m");
if (action == DEVICE_ACTION_REMOVE) {
if (action == SD_DEVICE_REMOVE) {
event_execute_rules_on_remove(event, timeout_usec, timeout_signal, properties_list, rules);
return 0;
}
@ -1009,7 +1009,7 @@ int udev_event_execute_rules(UdevEvent *event,
/* Disable watch during event processing. */
(void) udev_watch_end(event->dev_db_clone);
if (action == DEVICE_ACTION_MOVE) {
if (action == SD_DEVICE_MOVE) {
r = udev_event_on_move(event->dev);
if (r < 0)
return r;

View File

@ -6,6 +6,7 @@
#include "architecture.h"
#include "conf-files.h"
#include "def.h"
#include "device-private.h"
#include "device-util.h"
#include "dirent-util.h"
#include "escape.h"
@ -1545,9 +1546,9 @@ static int udev_rule_apply_token_to_event(
switch (token->type) {
case TK_M_ACTION: {
DeviceAction a;
sd_device_action_t a;
r = device_get_action(dev, &a);
r = sd_device_get_action(dev, &a);
if (r < 0)
return log_rule_error_errno(dev, rules, r, "Failed to get uevent action type: %m");
@ -2226,14 +2227,14 @@ static int udev_rule_apply_line_to_event(
UdevRuleLineType mask = LINE_HAS_GOTO | LINE_UPDATE_SOMETHING;
UdevRuleToken *token, *next_token;
bool parents_done = false;
DeviceAction action;
sd_device_action_t action;
int r;
r = device_get_action(event->dev, &action);
r = sd_device_get_action(event->dev, &action);
if (r < 0)
return r;
if (action != DEVICE_ACTION_REMOVE) {
if (action != SD_DEVICE_REMOVE) {
if (sd_device_get_devnum(event->dev, NULL) >= 0)
mask |= LINE_HAS_DEVLINK;

View File

@ -27,7 +27,7 @@ static Set *arg_tag_filter = NULL;
static Hashmap *arg_subsystem_filter = NULL;
static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device, void *userdata) {
DeviceAction action = _DEVICE_ACTION_INVALID;
sd_device_action_t action = _SD_DEVICE_ACTION_INVALID;
const char *devpath = NULL, *subsystem = NULL;
MonitorNetlinkGroup group = PTR_TO_INT(userdata);
struct timespec ts;
@ -35,7 +35,7 @@ static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device,
assert(device);
assert(IN_SET(group, MONITOR_GROUP_UDEV, MONITOR_GROUP_KERNEL));
(void) device_get_action(device, &action);
(void) sd_device_get_action(device, &action);
(void) sd_device_get_devpath(device, &devpath);
(void) sd_device_get_subsystem(device, &subsystem);

View File

@ -54,7 +54,7 @@ static int parse_argv(int argc, char *argv[]) {
while ((c = getopt_long(argc, argv, "a:N:Vh", options, NULL)) >= 0)
switch (c) {
case 'a': {
DeviceAction a;
sd_device_action_t a;
if (streq(optarg, "help")) {
dump_device_action_table();
@ -63,10 +63,9 @@ static int parse_argv(int argc, char *argv[]) {
a = device_action_from_string(optarg);
if (a < 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Invalid action '%s'", optarg);
return log_error_errno(a, "Invalid action '%s'", optarg);
arg_action = optarg;
arg_action = device_action_to_string(a);
break;
}
case 'N':

View File

@ -211,7 +211,7 @@ int trigger_main(int argc, char *argv[], void *userdata) {
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg);
break;
case 'c': {
DeviceAction a;
sd_device_action_t a;
if (streq(optarg, "help")) {
dump_device_action_table();
@ -222,7 +222,7 @@ int trigger_main(int argc, char *argv[], void *userdata) {
if (a < 0)
return log_error_errno(a, "Unknown action '%s'", optarg);
action = optarg;
action = device_action_to_string(a);
break;
}
case 's':

View File

@ -20,7 +20,7 @@ static int find_device_from_path(const char *path, sd_device **ret) {
if (stat(path, &st) < 0)
return -errno;
return device_new_from_stat_rdev(ret, &st);
return sd_device_new_from_stat_rdev(ret, &st);
}
return -EINVAL;

View File

@ -325,16 +325,12 @@ static int worker_lock_block_device(sd_device *dev, int *ret_fd) {
assert(dev);
assert(ret_fd);
/*
* Take a shared lock on the device node; this establishes
* a concept of device "ownership" to serialize device
* access. External processes holding an exclusive lock will
* cause udev to skip the event handling; in the case udev
* acquired the lock, the external process can block until
* udev has finished its event handling.
*/
/* Take a shared lock on the device node; this establishes a concept of device "ownership" to
* serialize device access. External processes holding an exclusive lock will cause udev to skip the
* event handling; in the case udev acquired the lock, the external process can block until udev has
* finished its event handling. */
if (device_for_action(dev, DEVICE_ACTION_REMOVE))
if (device_for_action(dev, SD_DEVICE_REMOVE))
return 0;
r = sd_device_get_subsystem(dev, &val);
@ -392,7 +388,7 @@ static int worker_mark_block_device_read_only(sd_device *dev) {
/* Do this only once, when the block device is new. If the device is later retriggered let's not
* toggle the bit again, so that people can boot up with full read-only mode and then unset the bit
* for specific devices only. */
if (!device_for_action(dev, DEVICE_ACTION_ADD))
if (!device_for_action(dev, SD_DEVICE_ADD))
return 0;
r = sd_device_get_subsystem(dev, &val);
@ -694,7 +690,7 @@ static int event_queue_insert(Manager *manager, sd_device *dev) {
assert(manager->pid == getpid_cached());
/* We only accepts devices received by device monitor. */
r = device_get_seqnum(dev, &seqnum);
r = sd_device_get_seqnum(dev, &seqnum);
if (r < 0)
return r;

View File

@ -127,7 +127,7 @@ FallbackLeaseLifetimeSec=
UseAddress=
UseNTP=
UseDNS=
UseFQDN=
UseHostname=
RapidCommit=
ForceDHCPv6PDOtherInformation=
PrefixDelegationHint=