1
0
mirror of https://github.com/systemd/systemd synced 2026-04-25 16:34:50 +02:00

Compare commits

..

No commits in common. "b0c3d2b76b85e5fc9eca4391830de00ddf86e767" and "bf93f24ad8743e1dae7d8629946df7325af2bef7" have entirely different histories.

20 changed files with 239 additions and 359 deletions

View File

@ -32,19 +32,15 @@
<citerefentry><refentrytitle>systemd.syntax</refentrytitle><manvolnum>7</manvolnum></citerefentry> for a
general description of the syntax.</para>
<para>The <filename>.link</filename> files are read from the files located in the system network
directory <filename>/usr/lib/systemd/network</filename> and
<filename>/usr/local/lib/systemd/network</filename>, the volatile runtime network directory
<para>The link files are read from the files located in the system network directory
<filename>/usr/lib/systemd/network</filename>, the volatile runtime network directory
<filename>/run/systemd/network</filename>, and the local administration network directory
<filename>/etc/systemd/network</filename>. All configuration files are collectively sorted and
processed in alphanumeric order, regardless of the directories in which they live. However, files
with identical filenames replace each other. It is recommended that each filename is prefixed with
a number (e.g. <filename>10-eth0.link</filename>). Otherwise, the default
<filename>.link</filename> files or those generated by
<citerefentry><refentrytitle>systemd-network-generator.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
may take precedence over user configured files. Files in <filename>/etc/</filename> have the
highest priority, files in <filename>/run/</filename> take precedence over files with the same name
in <filename>/usr/lib/</filename>. This can be used to override a system-supplied link file with a
<filename>/etc/systemd/network</filename>. Link files must have the extension
<filename>.link</filename>; other extensions are ignored. All link files are collectively sorted
and processed in lexical order, regardless of the directories in which they live. However, files
with identical filenames replace each other. Files in <filename>/etc/</filename> have the highest
priority, files in <filename>/run/</filename> take precedence over files with the same name in
<filename>/usr/lib/</filename>. This can be used to override a system-supplied link file with a
local file if needed. As a special case, an empty file (file size 0) or symlink with the same name
pointing to <filename>/dev/null</filename> disables the configuration file entirely (it is
"masked").</para>
@ -75,13 +71,13 @@
<refsect1>
<title>[Match] Section Options</title>
<para>A link file is said to match an interface if all matches specified by the [Match] section are
satisfied. When a link file does not contain valid settings in [Match] section, then the file will
match all interfaces and <command>systemd-udevd</command> warns about that. Hint: to avoid the
warning and to make it clear that all interfaces shall be matched, add the following:
<para>A link file is said to match a device if all matches specified by the
[Match] section are satisfied. When a link file does not contain valid settings
in [Match] section, then the file will match all devices and
<command>systemd-udevd</command> warns about that. Hint: to avoid the warning and to make it clear
that all interfaces shall be matched, add the following:
<programlisting>OriginalName=*</programlisting>
The first (in alphanumeric order) of the link files that matches a given interface is applied, all
later files are ignored, even if they match as well. The following keys are accepted:</para>
The following keys are accepted:</para>
<variablelist class='network-directives'>
<!-- This list is reused in systemd.network(3), hence maintain a specific order:
@ -1215,9 +1211,6 @@ MACAddress=cb:a9:87:65:43:21</programlisting>
</citerefentry>,
<citerefentry>
<refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>systemd-network-generator.service</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>
</para>
</refsect1>

View File

@ -39,22 +39,17 @@
than create its own. Note that the settings of the pre-existing netdev will not be changed by
networkd.</para>
<para>The <filename>.netdev</filename> files are read from the files located in the system network
directory <filename>/usr/lib/systemd/network</filename> and
<filename>/usr/local/lib/systemd/network</filename>, the volatile runtime network directory
<filename>/run/systemd/network</filename> and the local administration network directory
<filename>/etc/systemd/network</filename>. All configuration files are collectively sorted and
processed in alphanumeric order, regardless of the directories in which they live. However, files
with identical filenames replace each other. It is recommended that each filename is prefixed with
a number (e.g. <filename>10-vlan.netdev</filename>). Otherwise, <filename>.netdev</filename> files
generated by
<citerefentry><refentrytitle>systemd-network-generator.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
may take precedence over user configured files. Files in <filename>/etc/</filename> have the
highest priority, files in <filename>/run/</filename> take precedence over files with the same name
in <filename>/usr/lib/</filename>. This can be used to override a system-supplied configuration
file with a local file if needed. As a special case, an empty file (file size 0) or symlink with
the same name pointing to <filename>/dev/null</filename> disables the configuration file entirely
(it is "masked").</para>
<para>The <filename>.netdev</filename> files are read from the files located in the system
network directory <filename>/usr/lib/systemd/network</filename>, the volatile runtime network
directory <filename>/run/systemd/network</filename> and the local administration network
directory <filename>/etc/systemd/network</filename>. All configuration files are collectively
sorted and processed in lexical order, regardless of the directories in which they live.
However, files with identical filenames replace each other. Files in <filename>/etc/</filename>
have the highest priority, files in <filename>/run/</filename> take precedence over files with
the same name in <filename>/usr/lib/</filename>. This can be used to override a system-supplied
configuration file with a local file if needed. As a special case, an empty file (file size 0)
or symlink with the same name pointing to <filename>/dev/null</filename> disables the
configuration file entirely (it is "masked").</para>
<para>Along with the netdev file <filename>foo.netdev</filename>, a "drop-in" directory
<filename>foo.netdev.d/</filename> may exist. All files with the suffix <literal>.conf</literal>
@ -2438,8 +2433,7 @@ Independent=yes</programlisting>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-networkd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-network-generator.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
<citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>
</para>
</refsect1>

View File

@ -42,12 +42,8 @@
<filename>/usr/local/lib/systemd/network</filename>, the volatile runtime network directory
<filename>/run/systemd/network</filename> and the local administration network directory
<filename>/etc/systemd/network</filename>. All configuration files are collectively sorted and
processed in alphanumeric order, regardless of the directories in which they live. However, files
with identical filenames replace each other. It is recommended that each filename is prefixed with
a number (e.g. <filename>10-eth0.network</filename>). Otherwise, the default
<filename>.network</filename> files or those generated by
<citerefentry><refentrytitle>systemd-network-generator.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
may take precedence over user configured files. Files in <filename>/etc/</filename> have the highest
processed in lexical order, regardless of the directories in which they live. However, files with
identical filenames replace each other. Files in <filename>/etc/</filename> have the highest
priority, files in <filename>/run/</filename> take precedence over files with the same name under
<filename>/usr/</filename>. This can be used to override a system-supplied configuration file with
a local file if needed. As a special case, an empty file (file size 0) or symlink with the same
@ -73,9 +69,9 @@
<title>[Match] Section Options</title>
<para>The network file contains a [Match] section, which determines if a given network file may
be applied to a given interface; and a [Network] section specifying how the interface should be
configured. The first (in alphanumeric order) of the network files that matches a given interface
is applied, all later files are ignored, even if they match as well.</para>
be applied to a given device; and a [Network] section specifying how the device should be
configured. The first (in lexical order) of the network files that matches a given device is
applied, all later files are ignored, even if they match as well.</para>
<para>A network file is said to match a network interface if all matches specified by the [Match]
section are satisfied. When a network file does not contain valid settings in [Match] section, then
@ -2149,7 +2145,7 @@ Table=1234</programlisting></para>
<listitem>
<para>When true (the default), the client will request the DHCPv6 server to delegate
prefixes. If the server provides prefixes to be delegated, then subnets of the prefixes are
assigned to the interfaces that have <varname>DHCPPrefixDelegation=yes</varname>.
assigned to the interfaces which enables <varname>DHCPPrefixDelegation=</varname>.
See also the <varname>DHCPPrefixDelegation=</varname> setting in the [Network] section,
settings in the [DHCPPrefixDelegation] section, and
<ulink url="https://www.rfc-editor.org/rfc/rfc8415.html#section-6.3">RFC 8415</ulink>.
@ -4778,7 +4774,6 @@ Xfrm=xfrm0</programlisting>
<citerefentry><refentrytitle>systemd-networkd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.link</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.netdev</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-network-generator.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-resolved.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
</para>
</refsect1>

View File

@ -165,7 +165,7 @@
<term><option>--tree</option></term>
<listitem>
<para>Display a sysfs tree. This recursively iterates through the sysfs hierarchy and displays it
in a tree structure. If a path is specified only the subtree below and its parent directories are
in a tree structure. If a path is specified only the subtree below that directory is
shown. This will show both device and subsystem items.</para>
</listitem>
</varlistentry>

View File

@ -1452,30 +1452,6 @@ conf.set10('HAVE_ZSTD', have_zstd)
conf.set10('HAVE_COMPRESSION', have_xz or have_lz4 or have_zstd)
compression = get_option('default-compression')
if compression == 'auto'
if have_zstd
compression = 'zstd'
elif have_lz4
compression = 'lz4'
elif have_xz
compression = 'xz'
else
compression = 'none'
endif
elif compression == 'zstd' and not have_zstd
error('default-compression=zstd requires zstd')
elif compression == 'lz4' and not have_lz4
error('default-compression=lz4 requires lz4')
elif compression == 'xz' and not have_xz
error('default-compression=xz requires xz')
endif
conf.set('OBJECT_COMPRESSED_NONE', 0)
conf.set('OBJECT_COMPRESSED_XZ', 1)
conf.set('OBJECT_COMPRESSED_LZ4', 2)
conf.set('OBJECT_COMPRESSED_ZSTD', 4)
conf.set('DEFAULT_COMPRESSION', 'OBJECT_COMPRESSED_@0@'.format(compression.to_upper()))
want_xkbcommon = get_option('xkbcommon')
if want_xkbcommon != 'false' and not skip_deps
libxkbcommon = dependency('xkbcommon',

View File

@ -411,8 +411,6 @@ option('lz4', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'lz4 compression support')
option('zstd', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'zstd compression support')
option('default-compression', type : 'combo', choices : ['auto', 'zstd', 'lz4', 'xz'], value: 'auto',
description : 'default compression algorithm')
option('xkbcommon', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'xkbcommon keymap support')
option('pcre2', type : 'combo', choices : ['auto', 'true', 'false'],

View File

@ -16,7 +16,6 @@ int device_enumerator_scan_devices(sd_device_enumerator *enumerator);
int device_enumerator_scan_subsystems(sd_device_enumerator *enumerator);
int device_enumerator_scan_devices_and_subsystems(sd_device_enumerator *enumerator);
int device_enumerator_add_device(sd_device_enumerator *enumerator, sd_device *device);
int device_enumerator_add_parent_devices(sd_device_enumerator *enumerator, sd_device *device);
int device_enumerator_add_match_is_initialized(sd_device_enumerator *enumerator, MatchInitializedType type);
int device_enumerator_add_match_parent_incremental(sd_device_enumerator *enumerator, sd_device *parent);
int device_enumerator_add_prioritized_subsystem(sd_device_enumerator *enumerator, const char *subsystem);

View File

@ -549,8 +549,7 @@ static int match_initialized(sd_device_enumerator *enumerator, sd_device *device
static int test_matches(
sd_device_enumerator *enumerator,
sd_device *device,
bool ignore_parent_match) {
sd_device *device) {
int r;
@ -563,8 +562,7 @@ static int test_matches(
if (r <= 0)
return r;
if (!ignore_parent_match &&
!device_match_parent(device, enumerator->match_parent, NULL))
if (!device_match_parent(device, enumerator->match_parent, NULL))
return false;
if (!match_tag(enumerator, device))
@ -601,71 +599,6 @@ static bool match_subsystem(sd_device_enumerator *enumerator, const char *subsys
return false;
}
static int enumerator_add_parent_devices(
sd_device_enumerator *enumerator,
sd_device *device,
bool ignore_parent_match) {
int k, r = 0;
assert(enumerator);
assert(device);
for (;;) {
const char *ss, *usn;
k = sd_device_get_parent(device, &device);
if (k == -ENOENT) /* Reached the top? */
break;
if (k < 0) {
r = k;
break;
}
k = sd_device_get_subsystem(device, &ss);
if (k == -ENOENT) /* Has no subsystem? */
continue;
if (k < 0) {
r = k;
break;
}
if (!match_subsystem(enumerator, ss))
continue;
k = sd_device_get_sysname(device, &usn);
if (k < 0) {
r = k;
break;
}
if (!match_sysname(enumerator, usn))
continue;
k = test_matches(enumerator, device, ignore_parent_match);
if (k < 0) {
r = k;
break;
}
if (k == 0)
continue;
k = device_enumerator_add_device(enumerator, device);
if (k < 0) {
r = k;
break;
}
if (k == 0) /* Exists already? Then no need to go further up. */
break;
}
return r;
}
int device_enumerator_add_parent_devices(sd_device_enumerator *enumerator, sd_device *device) {
return enumerator_add_parent_devices(enumerator, device, /* ignore_parent_match = */ true);
}
static bool relevant_sysfs_subdir(const struct dirent *de) {
assert(de);
@ -706,6 +639,7 @@ static int enumerator_scan_dir_and_add_devices(
FOREACH_DIRENT_ALL(de, dir, return -errno) {
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
char syspath[strlen(path) + 1 + strlen(de->d_name) + 1];
sd_device *upwards;
if (!relevant_sysfs_subdir(de))
continue;
@ -724,7 +658,7 @@ static int enumerator_scan_dir_and_add_devices(
continue;
}
k = test_matches(enumerator, device, /* ignore_parent_match = */ false);
k = test_matches(enumerator, device);
if (k <= 0) {
if (k < 0)
r = k;
@ -738,9 +672,50 @@ static int enumerator_scan_dir_and_add_devices(
/* Also include all potentially matching parent devices in the enumeration. These are things
* like root busses e.g. /sys/devices/pci0000:00/ or /sys/devices/pnp0/, which ar not
* linked from /sys/class/ or /sys/bus/, hence pick them up explicitly here. */
k = enumerator_add_parent_devices(enumerator, device, /* ignore_parent_match = */ false);
upwards = device;
for (;;) {
const char *ss, *usn;
k = sd_device_get_parent(upwards, &upwards);
if (k == -ENOENT) /* Reached the top? */
break;
if (k < 0) {
r = k;
break;
}
k = sd_device_get_subsystem(upwards, &ss);
if (k == -ENOENT) /* Has no subsystem? */
continue;
if (k < 0) {
r = k;
break;
}
if (!match_subsystem(enumerator, ss))
continue;
k = sd_device_get_sysname(upwards, &usn);
if (k < 0) {
r = k;
break;
}
if (!match_sysname(enumerator, usn))
continue;
k = test_matches(enumerator, upwards);
if (k < 0)
break;
if (k == 0)
continue;
k = device_enumerator_add_device(enumerator, upwards);
if (k < 0)
r = k;
else if (k == 0) /* Exists already? Then no need to go further up. */
break;
}
}
return r;

View File

@ -111,7 +111,7 @@ uint64_t device_get_devlinks_generation(sd_device *device) {
return device->devlinks_generation;
}
int device_get_devnode_mode(sd_device *device, mode_t *ret) {
int device_get_devnode_mode(sd_device *device, mode_t *mode) {
int r;
assert(device);
@ -123,13 +123,13 @@ int device_get_devnode_mode(sd_device *device, mode_t *ret) {
if (device->devmode == MODE_INVALID)
return -ENOENT;
if (ret)
*ret = device->devmode;
if (mode)
*mode = device->devmode;
return 0;
}
int device_get_devnode_uid(sd_device *device, uid_t *ret) {
int device_get_devnode_uid(sd_device *device, uid_t *uid) {
int r;
assert(device);
@ -141,20 +141,20 @@ int device_get_devnode_uid(sd_device *device, uid_t *ret) {
if (device->devuid == UID_INVALID)
return -ENOENT;
if (ret)
*ret = device->devuid;
if (uid)
*uid = device->devuid;
return 0;
}
static int device_set_devuid(sd_device *device, const char *uid) {
uid_t u;
unsigned u;
int r;
assert(device);
assert(uid);
r = parse_uid(uid, &u);
r = safe_atou(uid, &u);
if (r < 0)
return r;
@ -167,7 +167,7 @@ static int device_set_devuid(sd_device *device, const char *uid) {
return 0;
}
int device_get_devnode_gid(sd_device *device, gid_t *ret) {
int device_get_devnode_gid(sd_device *device, gid_t *gid) {
int r;
assert(device);
@ -179,20 +179,20 @@ int device_get_devnode_gid(sd_device *device, gid_t *ret) {
if (device->devgid == GID_INVALID)
return -ENOENT;
if (ret)
*ret = device->devgid;
if (gid)
*gid = device->devgid;
return 0;
}
static int device_set_devgid(sd_device *device, const char *gid) {
gid_t g;
unsigned g;
int r;
assert(device);
assert(gid);
r = parse_gid(gid, &g);
r = safe_atou(gid, &g);
if (r < 0)
return r;
@ -593,17 +593,17 @@ int device_get_properties_strv(sd_device *device, char ***strv) {
return 0;
}
int device_get_devlink_priority(sd_device *device, int *ret) {
int device_get_devlink_priority(sd_device *device, int *priority) {
int r;
assert(device);
assert(priority);
r = device_read_db(device);
if (r < 0)
return r;
if (ret)
*ret = device->devlink_priority;
*priority = device->devlink_priority;
return 0;
}
@ -747,72 +747,62 @@ int device_new_from_watch_handle_at(sd_device **ret, int dirfd, int wd) {
}
int device_rename(sd_device *device, const char *name) {
_cleanup_free_ char *new_syspath = NULL;
const char *interface;
_cleanup_free_ char *dirname = NULL;
const char *new_syspath, *interface;
int r;
assert(device);
assert(name);
if (!filename_is_valid(name))
return -EINVAL;
r = path_extract_directory(device->syspath, &new_syspath);
if (r < 0)
return r;
if (!path_extend(&new_syspath, name))
dirname = dirname_malloc(device->syspath);
if (!dirname)
return -ENOMEM;
if (!path_is_safe(new_syspath))
return -EINVAL;
new_syspath = prefix_roota(dirname, name);
/* At the time this is called, the renamed device may not exist yet. Hence, we cannot validate
* the new syspath. */
/* the user must trust that the new name is correct */
r = device_set_syspath(device, new_syspath, false);
if (r < 0)
return r;
/* Here, only clear the sysname and sysnum. They will be set when requested. */
device->sysnum = NULL;
device->sysname = mfree(device->sysname);
r = sd_device_get_property_value(device, "INTERFACE", &interface);
if (r == -ENOENT)
return 0;
if (r < 0)
return r;
if (r >= 0) {
/* like DEVPATH_OLD, INTERFACE_OLD is not saved to the db, but only stays around for the current event */
r = device_add_property_internal(device, "INTERFACE_OLD", interface);
if (r < 0)
return r;
return device_add_property_internal(device, "INTERFACE", name);
r = device_add_property_internal(device, "INTERFACE", name);
if (r < 0)
return r;
} else if (r != -ENOENT)
return r;
return 0;
}
int device_shallow_clone(sd_device *device, sd_device **ret) {
_cleanup_(sd_device_unrefp) sd_device *dest = NULL;
const char *val = NULL;
int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
_cleanup_(sd_device_unrefp) sd_device *ret = NULL;
const char *val;
int r;
assert(device);
assert(ret);
assert(old_device);
assert(new_device);
r = device_new_aux(&dest);
r = device_new_aux(&ret);
if (r < 0)
return r;
r = device_set_syspath(dest, device->syspath, false);
r = device_set_syspath(ret, old_device->syspath, false);
if (r < 0)
return r;
(void) sd_device_get_subsystem(device, &val);
r = device_set_subsystem(dest, val);
(void) sd_device_get_subsystem(old_device, &val);
r = device_set_subsystem(ret, val);
if (r < 0)
return r;
if (streq_ptr(val, "drivers")) {
r = free_and_strdup(&dest->driver_subsystem, device->driver_subsystem);
r = free_and_strdup(&ret->driver_subsystem, old_device->driver_subsystem);
if (r < 0)
return r;
}
@ -820,47 +810,49 @@ int device_shallow_clone(sd_device *device, sd_device **ret) {
/* The device may be already removed. Let's copy minimal set of information to make
* device_get_device_id() work without uevent file. */
if (sd_device_get_property_value(device, "IFINDEX", &val) >= 0) {
r = device_set_ifindex(dest, val);
if (sd_device_get_property_value(old_device, "IFINDEX", &val) >= 0) {
r = device_set_ifindex(ret, val);
if (r < 0)
return r;
}
if (sd_device_get_property_value(device, "MAJOR", &val) >= 0) {
if (sd_device_get_property_value(old_device, "MAJOR", &val) >= 0) {
const char *minor = NULL;
(void) sd_device_get_property_value(device, "MINOR", &minor);
r = device_set_devnum(dest, val, minor);
(void) sd_device_get_property_value(old_device, "MINOR", &minor);
r = device_set_devnum(ret, val, minor);
if (r < 0)
return r;
}
r = device_read_uevent_file(dest);
if (r < 0)
return r;
/* And then read uevent file, but ignore errors, as some devices seem to return a spurious
* error on read, e.g. -ENODEV, and even if ifindex or devnum is set in the above,
* sd_device_get_ifindex() or sd_device_get_devnum() fails. See. #19788. */
(void) device_read_uevent_file(ret);
*ret = TAKE_PTR(dest);
*new_device = TAKE_PTR(ret);
return 0;
}
int device_clone_with_db(sd_device *device, sd_device **ret) {
_cleanup_(sd_device_unrefp) sd_device *dest = NULL;
int device_clone_with_db(sd_device *old_device, sd_device **new_device) {
_cleanup_(sd_device_unrefp) sd_device *ret = NULL;
int r;
assert(device);
assert(ret);
assert(old_device);
assert(new_device);
r = device_shallow_clone(device, &dest);
r = device_shallow_clone(old_device, &ret);
if (r < 0)
return r;
r = device_read_db(dest);
r = device_read_db(ret);
if (r < 0)
return r;
dest->sealed = true;
ret->sealed = true;
*new_device = TAKE_PTR(ret);
*ret = TAKE_PTR(dest);
return 0;
}
@ -931,11 +923,15 @@ static int device_tag(sd_device *device, const char *tag, bool add) {
path = strjoina("/run/udev/tags/", tag, "/", id);
if (add)
return touch_file(path, true, USEC_INFINITY, UID_INVALID, GID_INVALID, 0444);
if (unlink(path) < 0 && errno != ENOENT)
if (add) {
r = touch_file(path, true, USEC_INFINITY, UID_INVALID, GID_INVALID, 0444);
if (r < 0)
return r;
} else {
r = unlink(path);
if (r < 0 && errno != ENOENT)
return -errno;
}
return 0;
}
@ -944,14 +940,16 @@ int device_tag_index(sd_device *device, sd_device *device_old, bool add) {
const char *tag;
int r = 0, k;
if (add && device_old)
if (add && device_old) {
/* delete possible left-over tags */
FOREACH_DEVICE_TAG(device_old, tag)
FOREACH_DEVICE_TAG(device_old, tag) {
if (!sd_device_has_tag(device, tag)) {
k = device_tag(device_old, tag, false);
if (r >= 0 && k < 0)
r = k;
}
}
}
FOREACH_DEVICE_TAG(device, tag) {
k = device_tag(device, tag, add);
@ -1009,7 +1007,8 @@ int device_update_db(sd_device *device) {
/* do not store anything for otherwise empty devices */
if (!has_info && major(device->devnum) == 0 && device->ifindex == 0) {
if (unlink(path) < 0 && errno != ENOENT)
r = unlink(path);
if (r < 0 && errno != ENOENT)
return -errno;
return 0;
@ -1097,7 +1096,8 @@ int device_delete_db(sd_device *device) {
path = strjoina("/run/udev/data/", id);
if (unlink(path) < 0 && errno != ENOENT)
r = unlink(path);
if (r < 0 && errno != ENOENT)
return -errno;
return 0;

View File

@ -18,11 +18,11 @@ static inline int device_new_from_watch_handle(sd_device **ret, int wd) {
}
int device_get_device_id(sd_device *device, const char **ret);
int device_get_devlink_priority(sd_device *device, int *ret);
int device_get_devlink_priority(sd_device *device, int *priority);
int device_get_watch_handle(sd_device *device);
int device_get_devnode_mode(sd_device *device, mode_t *ret);
int device_get_devnode_uid(sd_device *device, uid_t *ret);
int device_get_devnode_gid(sd_device *device, gid_t *ret);
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_cache_sysattr_value(sd_device *device, const char *key, char *value);
int device_get_cached_sysattr_value(sd_device *device, const char *key, const char **ret_value);
@ -51,8 +51,8 @@ int device_get_properties_nulstr(sd_device *device, const uint8_t **nulstr, size
int device_get_properties_strv(sd_device *device, char ***strv);
int device_rename(sd_device *device, const char *name);
int device_shallow_clone(sd_device *device, sd_device **ret);
int device_clone_with_db(sd_device *device, sd_device **ret);
int device_shallow_clone(sd_device *old_device, sd_device **new_device);
int device_clone_with_db(sd_device *old_device, sd_device **new_device);
int device_copy_properties(sd_device *device_dst, sd_device *device_src);
int device_tag_index(sd_device *dev, sd_device *dev_old, bool add);

View File

@ -724,14 +724,11 @@ int device_read_uevent_file(sd_device *device) {
path = strjoina(syspath, "/uevent");
r = read_full_virtual_file(path, &uevent, &uevent_len);
if (r < 0) {
/* The uevent files may be write-only, the device may be already removed, or the device
* may not have the uevent file. */
if (r == -EACCES || ERRNO_IS_DEVICE_ABSENT(r))
if (IN_SET(r, -EACCES, -ENOENT))
/* The uevent files may be write-only, or the device may not have uevent file. */
return 0;
if (r < 0)
return log_device_debug_errno(device, r, "sd-device: Failed to read uevent file '%s': %m", path);
}
for (size_t i = 0; i < uevent_len; i++)
switch (state) {
@ -1440,30 +1437,37 @@ int device_get_device_id(sd_device *device, const char **ret) {
return r;
if (sd_device_get_devnum(device, &devnum) >= 0) {
assert(subsystem);
/* use dev_t — b259:131072, c254:0 */
if (asprintf(&id, "%c%u:%u",
r = asprintf(&id, "%c%u:%u",
streq(subsystem, "block") ? 'b' : 'c',
major(devnum), minor(devnum)) < 0)
major(devnum), minor(devnum));
if (r < 0)
return -ENOMEM;
} else if (sd_device_get_ifindex(device, &ifindex) >= 0) {
/* use netdev ifindex — n3 */
if (asprintf(&id, "n%u", (unsigned) ifindex) < 0)
r = asprintf(&id, "n%u", (unsigned) ifindex);
if (r < 0)
return -ENOMEM;
} else {
_cleanup_free_ char *sysname = NULL;
/* use $subsys:$sysname — pci:0000:00:1f.2
* sd_device_get_sysname() has '!' translated, get it from devpath */
r = path_extract_filename(device->devpath, &sysname);
if (r < 0)
return r;
* sysname() has '!' translated, get it from devpath
*/
const char *sysname;
if (streq(subsystem, "drivers")) {
/* the 'drivers' pseudo-subsystem is special, and needs the real
* subsystem encoded as well */
assert(device->driver_subsystem);
sysname = basename(device->devpath);
if (!sysname)
return -EINVAL;
if (!subsystem)
return -EINVAL;
if (streq(subsystem, "drivers"))
/* the 'drivers' pseudo-subsystem is special, and needs the real subsystem
* encoded as well */
id = strjoin("+drivers:", device->driver_subsystem, ":", sysname);
} else
else
id = strjoin("+", subsystem, ":", sysname);
if (!id)
return -ENOMEM;

View File

@ -18,15 +18,15 @@ int compress_blob_zstd(const void *src, uint64_t src_size,
static inline int compress_blob(const void *src, uint64_t src_size,
void *dst, size_t dst_alloc_size, size_t *dst_size) {
int r;
#if DEFAULT_COMPRESSION == OBJECT_COMPRESSED_ZSTD
#if HAVE_ZSTD
r = compress_blob_zstd(src, src_size, dst, dst_alloc_size, dst_size);
if (r == 0)
return OBJECT_COMPRESSED_ZSTD;
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_LZ4
#elif HAVE_LZ4
r = compress_blob_lz4(src, src_size, dst, dst_alloc_size, dst_size);
if (r == 0)
return OBJECT_COMPRESSED_LZ4;
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_XZ
#elif HAVE_XZ
r = compress_blob_xz(src, src_size, dst, dst_alloc_size, dst_size);
if (r == 0)
return OBJECT_COMPRESSED_XZ;
@ -72,13 +72,13 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_size);
int decompress_stream_lz4(int fdf, int fdt, uint64_t max_size);
int decompress_stream_zstd(int fdf, int fdt, uint64_t max_size);
#if DEFAULT_COMPRESSION == OBJECT_COMPRESSED_ZSTD
#if HAVE_ZSTD
# define compress_stream compress_stream_zstd
# define COMPRESSED_EXT ".zst"
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_LZ4
#elif HAVE_LZ4
# define compress_stream compress_stream_lz4
# define COMPRESSED_EXT ".lz4"
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_XZ
#elif HAVE_XZ
# define compress_stream compress_stream_xz
# define COMPRESSED_EXT ".xz"
#else

View File

@ -42,9 +42,11 @@ typedef enum ObjectType {
_OBJECT_TYPE_MAX
} ObjectType;
/* Object flags
* The per-compression enums are defined in meson.build so that config.h is self-contained */
/* Object flags */
enum {
OBJECT_COMPRESSED_XZ = 1 << 0,
OBJECT_COMPRESSED_LZ4 = 1 << 1,
OBJECT_COMPRESSED_ZSTD = 1 << 2,
OBJECT_COMPRESSION_MASK = (OBJECT_COMPRESSED_XZ | OBJECT_COMPRESSED_LZ4 | OBJECT_COMPRESSED_ZSTD),
_OBJECT_COMPRESSED_MAX = OBJECT_COMPRESSION_MASK,
};

View File

@ -3359,11 +3359,11 @@ int journal_file_open(
.open_flags = open_flags,
.writable = (open_flags & O_ACCMODE) != O_RDONLY,
#if DEFAULT_COMPRESSION == OBJECT_COMPRESSED_ZSTD
#if HAVE_ZSTD
.compress_zstd = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_LZ4
#elif HAVE_LZ4
.compress_lz4 = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
#elif DEFAULT_COMPRESSION == OBJECT_COMPRESSED_XZ
#elif HAVE_XZ
.compress_xz = FLAGS_SET(file_flags, JOURNAL_COMPRESS),
#endif
.compress_threshold_bytes = compress_threshold_bytes == UINT64_MAX ?

View File

@ -486,8 +486,7 @@ int config_parse_l2tp_tunnel_local_address(
L2tpLocalAddressType type;
L2tpTunnel *t = userdata;
const char *p = rvalue;
union in_addr_union a;
int r, f;
int r;
assert(filename);
assert(lvalue);
@ -540,27 +539,16 @@ int config_parse_l2tp_tunnel_local_address(
return 0;
}
r = in_addr_from_string_auto(rvalue, &f, &a);
if (t->family == AF_UNSPEC)
r = in_addr_from_string_auto(rvalue, &t->family, &t->local);
else
r = in_addr_from_string(t->family, rvalue, &t->local);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid L2TP Tunnel local address specified, ignoring assignment: %s", rvalue);
"Invalid L2TP Tunnel address specified in %s=, ignoring assignment: %s", lvalue, rvalue);
return 0;
}
if (in_addr_is_null(f, &a)) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"L2TP Tunnel local address cannot be null, ignoring assignment: %s", rvalue);
return 0;
}
if (t->family != AF_UNSPEC && t->family != f) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Address family does not match the previous assignment, ignoring assignment: %s", rvalue);
return 0;
}
t->family = f;
t->local = a;
free_and_replace(t->local_ifname, ifname);
t->local_address_type = _NETDEV_L2TP_LOCAL_ADDRESS_INVALID;
return 0;
@ -579,8 +567,7 @@ int config_parse_l2tp_tunnel_remote_address(
void *userdata) {
L2tpTunnel *t = userdata;
union in_addr_union a;
int r, f;
int r;
assert(filename);
assert(lvalue);
@ -597,27 +584,16 @@ int config_parse_l2tp_tunnel_remote_address(
return 0;
}
r = in_addr_from_string_auto(rvalue, &f, &a);
if (t->family == AF_UNSPEC)
r = in_addr_from_string_auto(rvalue, &t->family, &t->remote);
else
r = in_addr_from_string(t->family, rvalue, &t->remote);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid L2TP Tunnel remote address specified, ignoring assignment: %s", rvalue);
"Invalid L2TP Tunnel address specified in %s=, ignoring assignment: %s", lvalue, rvalue);
return 0;
}
if (in_addr_is_null(f, &a)) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"L2TP Tunnel remote address cannot be null, ignoring assignment: %s", rvalue);
return 0;
}
if (t->family != AF_UNSPEC && t->family != f) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Address family does not match the previous assignment, ignoring assignment: %s", rvalue);
return 0;
}
t->family = f;
t->remote = a;
return 0;
}

View File

@ -7,7 +7,6 @@
#include <linux/ip.h>
#include <linux/ip6_tunnel.h>
#include "af-list.h"
#include "conf-parser.h"
#include "hexdecoct.h"
#include "missing_network.h"
@ -738,20 +737,6 @@ static int netdev_tunnel_verify(NetDev *netdev, const char *filename) {
return 0;
}
static int unset_local(Tunnel *t) {
assert(t);
/* Unset the previous assignment. */
t->local = IN_ADDR_NULL;
t->local_type = _NETDEV_LOCAL_ADDRESS_TYPE_INVALID;
/* If the remote address is not specified, also clear the address family. */
if (!in_addr_is_set(t->family, &t->remote))
t->family = AF_UNSPEC;
return 0;
}
int config_parse_tunnel_local_address(
const char *unit,
const char *filename,
@ -774,8 +759,16 @@ int config_parse_tunnel_local_address(
assert(rvalue);
assert(userdata);
if (isempty(rvalue) || streq(rvalue, "any"))
return unset_local(t);
if (isempty(rvalue) || streq(rvalue, "any")) {
/* Unset the previous assignment. */
t->local = IN_ADDR_NULL;
t->local_type = _NETDEV_LOCAL_ADDRESS_TYPE_INVALID;
/* If the remote address is not specified, also clear the address family. */
if (!in_addr_is_set(t->family, &t->remote))
t->family = AF_UNSPEC;
return 0;
}
type = netdev_local_address_type_from_string(rvalue);
if (IN_SET(type, NETDEV_LOCAL_ADDRESS_IPV4LL, NETDEV_LOCAL_ADDRESS_DHCP4))
@ -790,9 +783,6 @@ int config_parse_tunnel_local_address(
"Tunnel address \"%s\" invalid, ignoring assignment: %m", rvalue);
return 0;
}
if (in_addr_is_null(f, &buffer))
return unset_local(t);
}
if (t->family != AF_UNSPEC && t->family != f) {
@ -807,20 +797,6 @@ int config_parse_tunnel_local_address(
return 0;
}
static int unset_remote(Tunnel *t) {
assert(t);
/* Unset the previous assignment. */
t->remote = IN_ADDR_NULL;
/* If the local address is not specified, also clear the address family. */
if (t->local_type == _NETDEV_LOCAL_ADDRESS_TYPE_INVALID &&
!in_addr_is_set(t->family, &t->local))
t->family = AF_UNSPEC;
return 0;
}
int config_parse_tunnel_remote_address(
const char *unit,
const char *filename,
@ -842,8 +818,16 @@ int config_parse_tunnel_remote_address(
assert(rvalue);
assert(userdata);
if (isempty(rvalue) || streq(rvalue, "any"))
return unset_remote(t);
if (isempty(rvalue) || streq(rvalue, "any")) {
/* Unset the previous assignment. */
t->remote = IN_ADDR_NULL;
/* If the local address is not specified, also clear the address family. */
if (t->local_type == _NETDEV_LOCAL_ADDRESS_TYPE_INVALID &&
!in_addr_is_set(t->family, &t->local))
t->family = AF_UNSPEC;
return 0;
}
r = in_addr_from_string_auto(rvalue, &f, &buffer);
if (r < 0) {
@ -852,9 +836,6 @@ int config_parse_tunnel_remote_address(
return 0;
}
if (in_addr_is_null(f, &buffer))
return unset_remote(t);
if (t->family != AF_UNSPEC && t->family != f) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Address family does not match the previous assignment, ignoring assignment: %s", rvalue);

View File

@ -60,7 +60,7 @@ bool dns_type_is_pseudo(uint16_t type) {
}
bool dns_class_is_pseudo(uint16_t class) {
return class == DNS_CLASS_ANY;
return class == DNS_TYPE_ANY;
}
bool dns_type_is_valid_query(uint16_t type) {

View File

@ -869,21 +869,15 @@ int udev_event_spawn(
}
static int rename_netif(UdevEvent *event) {
sd_device *dev = event->dev;
const char *oldname;
sd_device *dev;
unsigned flags;
int ifindex, r;
assert(event);
if (!event->name)
return 0; /* No new name is requested. */
dev = ASSERT_PTR(event->dev);
/* Read sysname from cloned sd-device object, otherwise use-after-free is triggered, as the
* main object will be renamed and dev->sysname will be freed in device_rename(). */
r = sd_device_get_sysname(event->dev_db_clone, &oldname);
r = sd_device_get_sysname(dev, &oldname);
if (r < 0)
return log_device_error_errno(dev, r, "Failed to get sysname: %m");

View File

@ -637,13 +637,6 @@ static int print_tree(sd_device* below) {
if (r < 0)
return log_error_errno(r, "Failed to scan for devices and subsystems: %m");
if (below) {
/* This must be called after device_enumerator_scan_devices_and_subsystems(). */
r = device_enumerator_add_parent_devices(e, below);
if (r < 0)
return log_error_errno(r, "Failed to add parent devices: %m");
}
assert_se(array = device_enumerator_get_devices(e, &n));
if (n == 0) {