1
0
mirror of https://github.com/systemd/systemd synced 2026-03-18 11:04:46 +01:00

Compare commits

..

No commits in common. "f7047b8c1cabca03fd8754abb3b13a6c26117b36" and "b6eabd21ea78483c35618be879864171d52d40c6" have entirely different histories.

19 changed files with 84 additions and 49 deletions

View File

@ -36,9 +36,6 @@ Daniel Stekloff <dsteklof@us.ibm.com>
Daniel Șerbănescu <dasj19@users.noreply.github.com> Daniel Șerbănescu <dasj19@users.noreply.github.com>
Dann Frazier <dann.frazier@canonical.com> Dann Frazier <dann.frazier@canonical.com>
Dave Reisner <dreisner@archlinux.org> <d@falconindy.com> Dave Reisner <dreisner@archlinux.org> <d@falconindy.com>
David Rheinsberg <david@readahead.eu>
David Rheinsberg <dh.herrmann@gmail.com>
David Rheinsberg <dh.herrmann@googlemail.com>
David Santamaría Rogado <howl.nsp@gmail.com> David Santamaría Rogado <howl.nsp@gmail.com>
David Zeuthen <david@fubar.dk> David Zeuthen <david@fubar.dk>
David Zeuthen <david@fubar.dk> <davidz@redhat.com> David Zeuthen <david@fubar.dk> <davidz@redhat.com>
@ -94,9 +91,7 @@ José Bollo <jose.bollo@iot.bzh> <jobol@nonadev.net>
Jun Bo Bi <jambonmcyeah@gmail.com> Jun Bo Bi <jambonmcyeah@gmail.com>
Justin Capella <justincapella@gmail.com> <b1tninja@users.noreply.github.com> Justin Capella <justincapella@gmail.com> <b1tninja@users.noreply.github.com>
Jérémy Rosen <jeremy.rosen@enst-bretagne.fr> Jérémy Rosen <jeremy.rosen@enst-bretagne.fr>
Jörg Behrmann <behrmann@physik.fu-berlin.de>
Jürg Billeter <j@bitron.ch> Jürg Billeter <j@bitron.ch>
Kai Lüke <kailuke@microsoft.com>
Karl Kraus <karl.kraus@tum.de> <laqueray@gmail.com> Karl Kraus <karl.kraus@tum.de> <laqueray@gmail.com>
Kay Sievers <kay@vrfy.org> Kay Sievers <kay@vrfy.org>
Kay Sievers <kay@vrfy.org> <kay.sievers@suse.de> Kay Sievers <kay@vrfy.org> <kay.sievers@suse.de>

View File

@ -247,24 +247,6 @@ SPDX-License-Identifier: LGPL-2.1-or-later
const char *input); const char *input);
``` ```
- When passing `NULL` or another value meaning "unset" to a function, use a comment
to indicate the argument name to make it more clear where we're passing an "unset"
value.
Bad:
```c
myfunction(NULL, NULL, NULL);
```
Good:
```c
myfunction(/* a= */ NULL, /* b= */ NULL, /* c= */ NULL);
```
This guidance should be applied tree-wide, including in test files.
- Please do not introduce new circular dependencies between header files. - Please do not introduce new circular dependencies between header files.
Effectively this means that if a.h includes b.h, then b.h cannot include a.h, Effectively this means that if a.h includes b.h, then b.h cannot include a.h,
directly or transitively via another header. Circular header dependencies can directly or transitively via another header. Circular header dependencies can

View File

@ -2329,6 +2329,38 @@ static int link_update_driver(Link *link, sd_netlink_message *message) {
return 1; /* needs reconfigure */ return 1; /* needs reconfigure */
} }
static int link_update_permanent_hardware_address_from_ethtool(Link *link, sd_netlink_message *message) {
int r;
assert(link);
assert(link->manager);
assert(message);
if (link->ethtool_permanent_hw_addr_read)
return 0;
/* When udevd is running, read the permanent hardware address after the interface is
* initialized by udevd. Otherwise, ethtool may not work correctly. See issue #22538.
* When udevd is not running, read the value when the interface is detected. */
if (udev_available() && !link->dev)
return 0;
/* If the interface does not have a hardware address, then it will not have a permanent address either. */
r = netlink_message_read_hw_addr(message, IFLA_ADDRESS, NULL);
if (r == -ENODATA)
return 0;
if (r < 0)
return log_link_debug_errno(link, r, "Failed to read IFLA_ADDRESS attribute: %m");
link->ethtool_permanent_hw_addr_read = true;
r = ethtool_get_permanent_hw_addr(&link->manager->ethtool_fd, link->ifname, &link->permanent_hw_addr);
if (r < 0)
log_link_debug_errno(link, r, "Permanent hardware address not found, continuing without: %m");
return 0;
}
static int link_update_permanent_hardware_address(Link *link, sd_netlink_message *message) { static int link_update_permanent_hardware_address(Link *link, sd_netlink_message *message) {
int r; int r;
@ -2340,11 +2372,16 @@ static int link_update_permanent_hardware_address(Link *link, sd_netlink_message
return 0; return 0;
r = netlink_message_read_hw_addr(message, IFLA_PERM_ADDRESS, &link->permanent_hw_addr); r = netlink_message_read_hw_addr(message, IFLA_PERM_ADDRESS, &link->permanent_hw_addr);
if (r == -ENODATA) if (r < 0) {
return 0; if (r != -ENODATA)
if (r < 0)
return log_link_debug_errno(link, r, "Failed to read IFLA_PERM_ADDRESS attribute: %m"); return log_link_debug_errno(link, r, "Failed to read IFLA_PERM_ADDRESS attribute: %m");
/* Fallback to ethtool for kernels older than v5.6 (f74877a5457d34d604dba6dbbb13c4c05bac8b93). */
r = link_update_permanent_hardware_address_from_ethtool(link, message);
if (r < 0)
return r;
}
if (link->permanent_hw_addr.length > 0) if (link->permanent_hw_addr.length > 0)
log_link_debug(link, "Saved permanent hardware address: %s", HW_ADDR_TO_STR(&link->permanent_hw_addr)); log_link_debug(link, "Saved permanent hardware address: %s", HW_ADDR_TO_STR(&link->permanent_hw_addr));

View File

@ -9,7 +9,7 @@
#include "string-util.h" #include "string-util.h"
#include "time-util.h" #include "time-util.h"
static int notify_remove_fd_full(int log_level, const char *name) { int notify_remove_fd_warn(const char *name) {
int r; int r;
assert(name); assert(name);
@ -18,22 +18,13 @@ static int notify_remove_fd_full(int log_level, const char *name) {
"FDSTOREREMOVE=1\n" "FDSTOREREMOVE=1\n"
"FDNAME=%s", name); "FDNAME=%s", name);
if (r < 0) if (r < 0)
return log_full_errno( return log_warning_errno(r,
log_level, r,
"Failed to remove file descriptor \"%s\" from the store, ignoring: %m", "Failed to remove file descriptor \"%s\" from the store, ignoring: %m",
name); name);
return 0; return 0;
} }
int notify_remove_fd(const char *name) {
return notify_remove_fd_full(LOG_DEBUG, name);
}
int notify_remove_fd_warn(const char *name) {
return notify_remove_fd_full(LOG_WARNING, name);
}
int notify_remove_fd_warnf(const char *format, ...) { int notify_remove_fd_warnf(const char *format, ...) {
_cleanup_free_ char *p = NULL; _cleanup_free_ char *p = NULL;
va_list ap; va_list ap;

View File

@ -21,7 +21,6 @@ static inline void notify_on_cleanup(const char **p) {
(void) sd_notify(false, *p); (void) sd_notify(false, *p);
} }
int notify_remove_fd(const char *name);
int notify_remove_fd_warn(const char *name); int notify_remove_fd_warn(const char *name);
int notify_remove_fd_warnf(const char *format, ...) _printf_(1, 2); int notify_remove_fd_warnf(const char *format, ...) _printf_(1, 2);
int close_and_notify_warn(int fd, const char *name); int close_and_notify_warn(int fd, const char *name);

View File

@ -557,10 +557,9 @@ int manager_serialize_config(Manager *manager) {
if (r < 0) if (r < 0)
return log_warning_errno(r, "Failed to finalize serialization file: %m"); return log_warning_errno(r, "Failed to finalize serialization file: %m");
/* This may fail on shutdown/reboot. Let's not warn louder. */
r = notify_push_fd(fileno(f), "config-serialization"); r = notify_push_fd(fileno(f), "config-serialization");
if (r < 0) if (r < 0)
return log_debug_errno(r, "Failed to push serialization fd to service manager: %m"); return log_warning_errno(r, "Failed to push serialization fd to service manager: %m");
log_debug("Serialized configurations."); log_debug("Serialized configurations.");
return 0; return 0;

View File

@ -1503,7 +1503,7 @@ int manager_main(Manager *manager) {
/* We will start processing events in the loop below. Before starting processing, let's remove the /* We will start processing events in the loop below. Before starting processing, let's remove the
* event serialization fd from the fdstore, to avoid retrieving the serialized events again in future * event serialization fd from the fdstore, to avoid retrieving the serialized events again in future
* invocations. Otherwise, the serialized events may be processed multiple times. */ * invocations. Otherwise, the serialized events may be processed multiple times. */
(void) notify_remove_fd("event-serialization"); (void) notify_remove_fd_warn("event-serialization");
r = sd_event_loop(manager->event); r = sd_event_loop(manager->event);
if (r < 0) if (r < 0)

View File

@ -3,6 +3,8 @@
set -ex set -ex
set -o pipefail set -o pipefail
udevadm control --log-level=debug
IFNAME=test-udev-aaa IFNAME=test-udev-aaa
ip link add "$IFNAME" type dummy ip link add "$IFNAME" type dummy
IFINDEX=$(ip -json link show "$IFNAME" | jq '.[].ifindex') IFINDEX=$(ip -json link show "$IFNAME" | jq '.[].ifindex')
@ -15,4 +17,6 @@ udevadm wait --timeout=10 --removed --settle "/sys/class/net/$IFNAME"
# CHeck if the database file is removed. # CHeck if the database file is removed.
[[ ! -e "/run/udev/data/n$IFINDEX" ]] [[ ! -e "/run/udev/data/n$IFINDEX" ]]
udevadm control --log-level=info
exit 0 exit 0

View File

@ -19,10 +19,14 @@ at_exit() (
systemctl daemon-reload systemctl daemon-reload
[[ -d "$TMPDIR" ]] && rm -rf "$TMPDIR" [[ -d "$TMPDIR" ]] && rm -rf "$TMPDIR"
udevadm control --log-level=info
) )
trap at_exit EXIT trap at_exit EXIT
udevadm control --log-level=debug
TMPDIR="$(mktemp -d)" TMPDIR="$(mktemp -d)"
truncate -s 16M "$TMPDIR"/foo.raw truncate -s 16M "$TMPDIR"/foo.raw
mkfs.ext4 -L foo "$TMPDIR"/foo.raw mkfs.ext4 -L foo "$TMPDIR"/foo.raw

View File

@ -6,6 +6,8 @@ set -o pipefail
# shellcheck source=test/units/util.sh # shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh . "$(dirname "$0")"/util.sh
udevadm control --log-level=debug
mkdir -p /run/systemd/network/ mkdir -p /run/systemd/network/
cat >/run/systemd/network/10-test.link <<EOF cat >/run/systemd/network/10-test.link <<EOF
[Match] [Match]
@ -196,6 +198,6 @@ ip link del dev test1
rm -f /run/systemd/network/10-test.link rm -f /run/systemd/network/10-test.link
rm -rf /run/systemd/network/10-test.link.d rm -rf /run/systemd/network/10-test.link.d
udevadm control --reload udevadm control --reload --log-level=info
exit 0 exit 0

View File

@ -11,10 +11,14 @@ at_exit() (
set +e set +e
[[ -d "$TMPDIR" ]] && rm -rf "$TMPDIR" [[ -d "$TMPDIR" ]] && rm -rf "$TMPDIR"
udevadm control --log-level=info
) )
trap at_exit EXIT trap at_exit EXIT
udevadm control --log-level=debug
TMPDIR="$(mktemp -d)" TMPDIR="$(mktemp -d)"
truncate -s 16M "$TMPDIR"/foo.raw truncate -s 16M "$TMPDIR"/foo.raw
mkfs.ext4 "$TMPDIR"/foo.raw mkfs.ext4 "$TMPDIR"/foo.raw

View File

@ -15,7 +15,7 @@ OriginalName=testif
Name=te!st!if Name=te!st!if
EOF EOF
udevadm control --reload udevadm control --log-level=debug --reload
# Check if any interfaces originally named with '!' in their name have been renamed unexpectedly. # Check if any interfaces originally named with '!' in their name have been renamed unexpectedly.
ip link add 'hoge!foo' type dummy ip link add 'hoge!foo' type dummy
@ -41,6 +41,6 @@ ip link del dev 'te!st!if'
# cleanup # cleanup
rm -f /run/systemd/network/10-rename-test.link rm -f /run/systemd/network/10-rename-test.link
udevadm control --reload udevadm control --log-level=info --reload
exit 0 exit 0

View File

@ -22,6 +22,8 @@ EOF
udevadm control --reload udevadm control --reload
} }
udevadm control --log-level=debug
create_link_file test1 create_link_file test1
ip link add address 00:50:56:c0:00:18 type dummy ip link add address 00:50:56:c0:00:18 type dummy
udevadm wait --settle --timeout=30 /sys/class/net/test1 udevadm wait --settle --timeout=30 /sys/class/net/test1
@ -79,6 +81,6 @@ assert_not_in "altname hoge" "$output"
ip link del dev test3 ip link del dev test3
rm -f /run/systemd/network/10-test.link rm -f /run/systemd/network/10-test.link
udevadm control --reload udevadm control --reload --log-level=info
exit 0 exit 0

View File

@ -24,7 +24,7 @@ ACTION=="add", RUN+="/usr/bin/bash -c ':> /tmp/marker'", RUN+="/usr/bin/sleep 10
LABEL="end" LABEL="end"
EOF EOF
udevadm control --reload udevadm control --reload --log-level=debug
udevadm settle --timeout 30 udevadm settle --timeout 30
rm -f /tmp/marker rm -f /tmp/marker

View File

@ -80,6 +80,10 @@ cat >/run/udev/rules.d/50-testsuite.rules <<EOF
ACTION=="add", SUBSYSTEM=="block", KERNEL=="sda", OPTIONS:="watch" ACTION=="add", SUBSYSTEM=="block", KERNEL=="sda", OPTIONS:="watch"
EOF EOF
# To make the previous invocation of systemd-udevd generates debugging logs on stop,
# that will be checked by check().
udevadm control --log-level debug
# Unfortunately, journalctl --invocation= is unstable when debug logging is enabled on service manager. # Unfortunately, journalctl --invocation= is unstable when debug logging is enabled on service manager.
SAVED_LOG_LEVEL=$(systemctl log-level) SAVED_LOG_LEVEL=$(systemctl log-level)
systemctl log-level info systemctl log-level info

View File

@ -29,6 +29,9 @@ EOF
systemctl daemon-reexec systemctl daemon-reexec
udevadm control --log-level debug
ARGS=() ARGS=()
STATE_DIRECTORY=/var/lib/private/ STATE_DIRECTORY=/var/lib/private/
if [[ -v ASAN_OPTIONS || -v UBSAN_OPTIONS ]]; then if [[ -v ASAN_OPTIONS || -v UBSAN_OPTIONS ]]; then

View File

@ -118,6 +118,8 @@ else
exit 1 exit 1
fi fi
udevadm control --log-level=debug
IMAGE_DIR="$(mktemp -d --tmpdir="" TEST-50-IMAGES.XXX)" IMAGE_DIR="$(mktemp -d --tmpdir="" TEST-50-IMAGES.XXX)"
chmod go+rx "$IMAGE_DIR" chmod go+rx "$IMAGE_DIR"
cp -v /usr/share/minimal* "$IMAGE_DIR/" cp -v /usr/share/minimal* "$IMAGE_DIR/"

View File

@ -22,6 +22,10 @@ export SYSTEMD_UTF8=0
seed=750b6cd5c4ae4012a15e7be3c29e6a47 seed=750b6cd5c4ae4012a15e7be3c29e6a47
if ! systemd-detect-virt --quiet --container; then
udevadm control --log-level debug
fi
esp_guid=C12A7328-F81F-11D2-BA4B-00A0C93EC93B esp_guid=C12A7328-F81F-11D2-BA4B-00A0C93EC93B
xbootldr_guid=BC13C2FF-59E6-4262-A352-B275FD6F7172 xbootldr_guid=BC13C2FF-59E6-4262-A352-B275FD6F7172

View File

@ -1348,6 +1348,7 @@ testcase_mdadm_lvm() {
} }
udevadm settle udevadm settle
udevadm control --log-level debug
lsblk -a lsblk -a
echo "Check if all symlinks under /dev/disk/ are valid (pre-test)" echo "Check if all symlinks under /dev/disk/ are valid (pre-test)"
@ -1367,6 +1368,8 @@ udevadm settle --timeout=60
echo "Check if all symlinks under /dev/disk/ are valid (post-test)" echo "Check if all symlinks under /dev/disk/ are valid (post-test)"
helper_check_device_symlinks helper_check_device_symlinks
udevadm control --log-level info
systemctl status systemd-udevd systemctl status systemd-udevd
touch /testok touch /testok