1
0
mirror of https://github.com/systemd/systemd synced 2026-04-11 09:34:51 +02:00

Compare commits

..

No commits in common. "c0a2e0cc24491a4f4dbf5ad49aec2507f75ee8e3" and "641e2124de6047e6010cd2925ea22fba29b25309" have entirely different histories.

12 changed files with 73 additions and 144 deletions

View File

@ -136,8 +136,7 @@
<command>kernel-install</command> should use. The value must be a valid machine ID (32 hexadecimal <command>kernel-install</command> should use. The value must be a valid machine ID (32 hexadecimal
characters). This would generally be the original machine-id that was used when the boot loader characters). This would generally be the original machine-id that was used when the boot loader
entries for this installation were first added. When not set, the current value of entries for this installation were first added. When not set, the current value of
<citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> <cite>machine-id(5)</cite> will be used.</para></listitem>
will be used.</para></listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>

View File

@ -80,7 +80,7 @@
<para><function>sd_journal_next_skip()</function> and <para><function>sd_journal_next_skip()</function> and
<function>sd_journal_previous_skip()</function> advance/set back the read pointer by multiple <function>sd_journal_previous_skip()</function> advance/set back the read pointer by multiple
entries at once, as specified in the <varname>skip</varname> parameter. The <varname>skip</varname> entries at once, as specified in the <varname>skip</varname> parameter. The <varname>skip</varname>
parameter must be less than or equal to 2147483647 (2³¹-1).</para> parameter must be less than or equal to 2147483647 (2^31-1).</para>
<para>The journal is strictly ordered by reception time, and hence <para>The journal is strictly ordered by reception time, and hence
advancing to the next entry guarantees that the entry then advancing to the next entry guarantees that the entry then

View File

@ -71,7 +71,7 @@
</para> </para>
<para>Log data collected by the journal is primarily text-based but can also include binary data where <para>Log data collected by the journal is primarily text-based but can also include binary data where
necessary. Individual fields making up a log record stored in the journal may be up to 2⁶⁴-1 bytes in size.</para> necessary. Individual fields making up a log record stored in the journal may be up to 2^64-1 bytes in size.</para>
<para>The journal service stores log data either persistently below <filename>/var/log/journal</filename> or in a <para>The journal service stores log data either persistently below <filename>/var/log/journal</filename> or in a
volatile way below <filename>/run/log/journal/</filename> (in the latter case it is lost at reboot). By default, log volatile way below <filename>/run/log/journal/</filename> (in the latter case it is lost at reboot). By default, log

View File

@ -384,10 +384,10 @@
numbers, which could either result in an incorrect value of the <varname>ID_NET_NAME_SLOT</varname> numbers, which could either result in an incorrect value of the <varname>ID_NET_NAME_SLOT</varname>
property or none at all.</para> property or none at all.</para>
<para>Some firmware and hypervisor implementations report unreasonably high numbers for the onboard <para>Some firmware and hypervisor implementations report unreasonable high numbers for the onboard
index. To prevent the generation of bogus onbard interface names, index numbers greater than 16381 index. To prevent the generation of bogus onbard interface names, index numbers greater than 16381
(2¹⁴-1) were ignored. For s390 PCI devices index values up to 65535 (2¹⁶-1) are valid. To account (2^14-1) were ignored. For s390 PCI devices index values up to 65535 (2^16-1) are valid. To account
for that, the limit was increased to 65535.</para> for that, the limit is increased to now 65535.</para>
<para>The udev rule <varname>NAME=</varname> replaces <literal>:</literal>, <para>The udev rule <varname>NAME=</varname> replaces <literal>:</literal>,
<literal>/</literal>, and <literal>%</literal> with an underscore (<literal>_</literal>), and <literal>/</literal>, and <literal>%</literal> with an underscore (<literal>_</literal>), and

View File

@ -60,10 +60,6 @@ static inline const char *empty_to_null(const char *p) {
return isempty(p) ? NULL : p; return isempty(p) ? NULL : p;
} }
static inline const char *empty_to_na(const char *p) {
return isempty(p) ? "n/a" : p;
}
static inline const char *empty_to_dash(const char *str) { static inline const char *empty_to_dash(const char *str) {
return isempty(str) ? "-" : str; return isempty(str) ? "-" : str;
} }

View File

@ -139,7 +139,7 @@ int config_parse_ipoib_pkey(
rvalue); rvalue);
return 0; return 0;
} }
if (IN_SET(u, 0, 0x8000)) { if (u == 0 || u == 0x8000) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"IPoIB pkey cannot be 0 nor 0x8000, ignoring assignment: %s", "IPoIB pkey cannot be 0 nor 0x8000, ignoring assignment: %s",
rvalue); rvalue);

View File

@ -358,9 +358,10 @@ int config_parse_address_generation_type(
addr = addr_alloc; addr = addr_alloc;
} }
} else if (*addr == ',') } else if (*addr == ',') {
comma = TAKE_PTR(addr); comma = addr;
else if (*addr == '\0') { addr = NULL;
} else if (*addr == '\0') {
comma = NULL; comma = NULL;
addr = NULL; addr = NULL;
} else { } else {

View File

@ -1528,7 +1528,7 @@ static int dhcp4_configure(Link *link) {
return log_link_debug_errno(link, r, "DHCPv4 CLIENT: Failed to set max attempts: %m"); return log_link_debug_errno(link, r, "DHCPv4 CLIENT: Failed to set max attempts: %m");
} }
if (link->network->dhcp_ip_service_type >= 0) { if (link->network->dhcp_ip_service_type > 0) {
r = sd_dhcp_client_set_service_type(link->dhcp_client, link->network->dhcp_ip_service_type); r = sd_dhcp_client_set_service_type(link->dhcp_client, link->network->dhcp_ip_service_type);
if (r < 0) if (r < 0)
return log_link_debug_errno(link, r, "DHCPv4 CLIENT: Failed to set IP service type: %m"); return log_link_debug_errno(link, r, "DHCPv4 CLIENT: Failed to set IP service type: %m");

View File

@ -176,33 +176,27 @@ static int dev_pci_onboard(sd_device *dev, const LinkInfo *info, NetNames *names
assert(names); assert(names);
/* ACPI _DSM — device specific method for naming a PCI or PCI Express device */ /* ACPI _DSM — device specific method for naming a PCI or PCI Express device */
if (sd_device_get_sysattr_value(names->pcidev, "acpi_index", &attr) >= 0) if (sd_device_get_sysattr_value(names->pcidev, "acpi_index", &attr) < 0) {
log_device_debug(names->pcidev, "acpi_index=%s", attr);
else {
/* SMBIOS type 41 — Onboard Devices Extended Information */ /* SMBIOS type 41 — Onboard Devices Extended Information */
r = sd_device_get_sysattr_value(names->pcidev, "index", &attr); r = sd_device_get_sysattr_value(names->pcidev, "index", &attr);
if (r < 0) if (r < 0)
return r; return r;
log_device_debug(names->pcidev, "index=%s", attr);
} }
r = safe_atolu(attr, &idx); r = safe_atolu(attr, &idx);
if (r < 0) if (r < 0)
return log_device_debug_errno(names->pcidev, r, return r;
"Failed to parse onboard index \"%s\": %m", attr);
if (idx == 0 && !naming_scheme_has(NAMING_ZERO_ACPI_INDEX)) if (idx == 0 && !naming_scheme_has(NAMING_ZERO_ACPI_INDEX))
return log_device_debug_errno(names->pcidev, SYNTHETIC_ERRNO(EINVAL), return -EINVAL;
"Naming scheme does not allow onboard index==0.");
if (!is_valid_onboard_index(idx)) if (!is_valid_onboard_index(idx))
return log_device_debug_errno(names->pcidev, SYNTHETIC_ERRNO(ENOENT), return -ENOENT;
"Not a valid onboard index: %lu", idx);
/* kernel provided port index for multiple ports on a single PCI function */ /* kernel provided port index for multiple ports on a single PCI function */
if (sd_device_get_sysattr_value(dev, "dev_port", &attr) >= 0) { if (sd_device_get_sysattr_value(dev, "dev_port", &attr) >= 0) {
r = safe_atolu_full(attr, 10, &dev_port); r = safe_atolu_full(attr, 10, &dev_port);
if (r < 0) if (r < 0)
log_device_debug_errno(dev, r, "Failed to parse dev_port, ignoring: %m"); log_device_debug_errno(dev, r, "Failed to parse dev_port, ignoring: %m");
log_device_debug(dev, "dev_port=%lu", dev_port);
} }
s = names->pci_onboard; s = names->pci_onboard;
@ -215,13 +209,8 @@ static int dev_pci_onboard(sd_device *dev, const LinkInfo *info, NetNames *names
l = strpcpyf(&s, l, "d%lu", dev_port); l = strpcpyf(&s, l, "d%lu", dev_port);
if (l == 0) if (l == 0)
names->pci_onboard[0] = '\0'; names->pci_onboard[0] = '\0';
log_device_debug(dev, "Onboard index identifier: index=%lu phys_port=%s dev_port=%lu → %s",
idx, strempty(info->phys_port_name), dev_port,
empty_to_na(names->pci_slot));
if (sd_device_get_sysattr_value(names->pcidev, "label", &names->pci_onboard_label) >= 0) if (sd_device_get_sysattr_value(names->pcidev, "label", &names->pci_onboard_label) < 0)
log_device_debug(dev, "Onboard label from PCI device: %s", names->pci_onboard_label);
else
names->pci_onboard_label = NULL; names->pci_onboard_label = NULL;
return 0; return 0;
@ -272,10 +261,7 @@ static bool is_pci_bridge(sd_device *dev) {
return false; return false;
/* PCI device subclass 04 corresponds to PCI bridge */ /* PCI device subclass 04 corresponds to PCI bridge */
bool b = strneq(p + 2, "04", 2); return strneq(p + 2, "04", 2);
if (b)
log_device_debug(dev, "Device is a PCI bridge.");
return b;
} }
static int parse_hotplug_slot_from_function_id(sd_device *dev, const char *slots, uint32_t *ret) { static int parse_hotplug_slot_from_function_id(sd_device *dev, const char *slots, uint32_t *ret) {
@ -340,12 +326,9 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) {
r = sd_device_get_sysname(names->pcidev, &sysname); r = sd_device_get_sysname(names->pcidev, &sysname);
if (r < 0) if (r < 0)
return log_device_debug_errno(names->pcidev, r, "Failed to get sysname: %m"); return r;
r = sscanf(sysname, "%x:%x:%x.%u", &domain, &bus, &slot, &func); if (sscanf(sysname, "%x:%x:%x.%u", &domain, &bus, &slot, &func) != 4)
log_device_debug(dev, "Parsing slot information from PCI device sysname \"%s\": %s",
sysname, r == 4 ? "success" : "failure");
if (r != 4)
return -ENOENT; return -ENOENT;
if (naming_scheme_has(NAMING_NPAR_ARI) && if (naming_scheme_has(NAMING_NPAR_ARI) &&
@ -357,8 +340,6 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) {
/* kernel provided port index for multiple ports on a single PCI function */ /* kernel provided port index for multiple ports on a single PCI function */
if (sd_device_get_sysattr_value(dev, "dev_port", &attr) >= 0) { if (sd_device_get_sysattr_value(dev, "dev_port", &attr) >= 0) {
log_device_debug(dev, "dev_port=%s", attr);
r = safe_atolu_full(attr, 10, &dev_port); r = safe_atolu_full(attr, 10, &dev_port);
if (r < 0) if (r < 0)
log_device_debug_errno(dev, r, "Failed to parse attribute dev_port, ignoring: %m"); log_device_debug_errno(dev, r, "Failed to parse attribute dev_port, ignoring: %m");
@ -369,8 +350,6 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) {
if (dev_port == 0 && if (dev_port == 0 &&
info->iftype == ARPHRD_INFINIBAND && info->iftype == ARPHRD_INFINIBAND &&
sd_device_get_sysattr_value(dev, "dev_id", &attr) >= 0) { sd_device_get_sysattr_value(dev, "dev_id", &attr) >= 0) {
log_device_debug(dev, "dev_id=%s", attr);
r = safe_atolu_full(attr, 10, &dev_port); r = safe_atolu_full(attr, 10, &dev_port);
if (r < 0) if (r < 0)
log_device_debug_errno(dev, r, "Failed to parse attribute dev_id, ignoring: %m"); log_device_debug_errno(dev, r, "Failed to parse attribute dev_id, ignoring: %m");
@ -393,26 +372,20 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) {
if (l == 0) if (l == 0)
names->pci_path[0] = '\0'; names->pci_path[0] = '\0';
log_device_debug(dev, "PCI path identifier: domain=%u bus=%u slot=%u func=%u phys_port=%s dev_port=%lu → %s",
domain, bus, slot, func, strempty(info->phys_port_name), dev_port,
empty_to_na(names->pci_path));
/* ACPI _SUN — slot user number */ /* ACPI _SUN — slot user number */
r = sd_device_new_from_subsystem_sysname(&pci, "subsystem", "pci"); r = sd_device_new_from_subsystem_sysname(&pci, "subsystem", "pci");
if (r < 0) if (r < 0)
return log_debug_errno(r, "sd_device_new_from_subsystem_sysname failed: %m"); return r;
r = sd_device_get_syspath(pci, &syspath); r = sd_device_get_syspath(pci, &syspath);
if (r < 0) if (r < 0)
return log_device_debug_errno(pci, r, "sd_device_get_syspath failed: %m"); return r;
if (!snprintf_ok(slots, sizeof slots, "%s/slots", syspath)) if (!snprintf_ok(slots, sizeof slots, "%s/slots", syspath))
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ENAMETOOLONG), return -ENAMETOOLONG;
"Cannot access %s/slots: %m", syspath);
dir = opendir(slots); dir = opendir(slots);
if (!dir) if (!dir)
return log_device_debug_errno(dev, errno, "Cannot access %s: %m", slots); return -errno;
hotplug_slot_dev = names->pcidev; hotplug_slot_dev = names->pcidev;
while (hotplug_slot_dev) { while (hotplug_slot_dev) {
@ -450,10 +423,8 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) {
* slot index if the device is a PCI bridge, because it can have other child * slot index if the device is a PCI bridge, because it can have other child
* devices that will try to claim the same index and that would create name * devices that will try to claim the same index and that would create name
* collision. */ * collision. */
if (naming_scheme_has(NAMING_BRIDGE_NO_SLOT) && is_pci_bridge(hotplug_slot_dev)) { if (naming_scheme_has(NAMING_BRIDGE_NO_SLOT) && is_pci_bridge(hotplug_slot_dev))
log_device_debug(dev, "Not using slot information because the PCI device is a bridge.");
return 0; return 0;
}
break; break;
} }
@ -469,20 +440,16 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) {
s = names->pci_slot; s = names->pci_slot;
l = sizeof(names->pci_slot); l = sizeof(names->pci_slot);
if (domain > 0) if (domain > 0)
l = strpcpyf(&s, l, "P%u", domain); l = strpcpyf(&s, l, "P%d", domain);
l = strpcpyf(&s, l, "s%"PRIu32, hotplug_slot); l = strpcpyf(&s, l, "s%"PRIu32, hotplug_slot);
if (func > 0 || is_pci_multifunction(names->pcidev)) if (func > 0 || is_pci_multifunction(names->pcidev))
l = strpcpyf(&s, l, "f%u", func); l = strpcpyf(&s, l, "f%d", func);
if (!isempty(info->phys_port_name)) if (!isempty(info->phys_port_name))
l = strpcpyf(&s, l, "n%s", info->phys_port_name); l = strpcpyf(&s, l, "n%s", info->phys_port_name);
else if (dev_port > 0) else if (dev_port > 0)
l = strpcpyf(&s, l, "d%lu", dev_port); l = strpcpyf(&s, l, "d%lu", dev_port);
if (l == 0) if (l == 0)
names->pci_slot[0] = '\0'; names->pci_slot[0] = '\0';
log_device_debug(dev, "Slot identifier: domain=%u slot=%"PRIu32" func=%u phys_port=%s dev_port=%lu → %s",
domain, hotplug_slot, func, strempty(info->phys_port_name), dev_port,
empty_to_na(names->pci_slot));
} }
return 0; return 0;
@ -497,14 +464,13 @@ static int names_vio(sd_device *dev, NetNames *names) {
/* check if our direct parent is a VIO device with no other bus in-between */ /* check if our direct parent is a VIO device with no other bus in-between */
r = sd_device_get_parent(dev, &parent); r = sd_device_get_parent(dev, &parent);
if (r < 0) if (r < 0)
return log_device_debug_errno(dev, r, "sd_device_get_parent failed: %m"); return r;
r = sd_device_get_subsystem(parent, &subsystem); r = sd_device_get_subsystem(parent, &subsystem);
if (r < 0) if (r < 0)
return log_device_debug_errno(parent, r, "sd_device_get_subsystem failed: %m"); return r;
if (!streq("vio", subsystem)) if (!streq("vio", subsystem))
return -ENOENT; return -ENOENT;
log_device_debug(dev, "Parent device is in the vio subsystem.");
/* The devices' $DEVPATH number is tied to (virtual) hardware (slot id /* The devices' $DEVPATH number is tied to (virtual) hardware (slot id
* selected in the HMC), thus this provides a reliable naming (e.g. * selected in the HMC), thus this provides a reliable naming (e.g.
@ -512,23 +478,19 @@ static int names_vio(sd_device *dev, NetNames *names) {
* there should only ever be one bus, and then remove leading zeros. */ * there should only ever be one bus, and then remove leading zeros. */
r = sd_device_get_syspath(dev, &syspath); r = sd_device_get_syspath(dev, &syspath);
if (r < 0) if (r < 0)
return log_device_debug_errno(dev, r, "sd_device_get_syspath failed: %m"); return r;
r = sscanf(syspath, "/sys/devices/vio/%4x%4x/net/eth%u", &busid, &slotid, &ethid); if (sscanf(syspath, "/sys/devices/vio/%4x%4x/net/eth%u", &busid, &slotid, &ethid) != 3)
log_device_debug(dev, "Parsing vio slot information from syspath \"%s\": %s",
syspath, r == 3 ? "success" : "failure");
if (r != 3)
return -EINVAL; return -EINVAL;
xsprintf(names->vio_slot, "v%u", slotid); xsprintf(names->vio_slot, "v%u", slotid);
names->type = NET_VIO; names->type = NET_VIO;
log_device_debug(dev, "Vio slot identifier: slotid=%u → %s", slotid, names->vio_slot);
return 0; return 0;
} }
#define PLATFORM_TEST "/sys/devices/platform/vvvvPPPP" #define _PLATFORM_TEST "/sys/devices/platform/vvvvPPPP"
#define PLATFORM_PATTERN4 "/sys/devices/platform/%4s%4x:%2x/net/eth%u" #define _PLATFORM_PATTERN4 "/sys/devices/platform/%4s%4x:%2x/net/eth%u"
#define PLATFORM_PATTERN3 "/sys/devices/platform/%3s%4x:%2x/net/eth%u" #define _PLATFORM_PATTERN3 "/sys/devices/platform/%3s%4x:%2x/net/eth%u"
static int names_platform(sd_device *dev, NetNames *names, bool test) { static int names_platform(sd_device *dev, NetNames *names, bool test) {
sd_device *parent; sd_device *parent;
@ -540,32 +502,29 @@ static int names_platform(sd_device *dev, NetNames *names, bool test) {
/* check if our direct parent is a platform device with no other bus in-between */ /* check if our direct parent is a platform device with no other bus in-between */
r = sd_device_get_parent(dev, &parent); r = sd_device_get_parent(dev, &parent);
if (r < 0) if (r < 0)
return log_device_debug_errno(dev, r, "sd_device_get_parent failed: %m"); return r;
r = sd_device_get_subsystem(parent, &subsystem); r = sd_device_get_subsystem(parent, &subsystem);
if (r < 0) if (r < 0)
return log_device_debug_errno(parent, r, "sd_device_get_subsystem failed: %m"); return r;
if (!streq("platform", subsystem)) if (!streq("platform", subsystem))
return -ENOENT; return -ENOENT;
log_device_debug(dev, "Parent device is in the platform subsystem.");
r = sd_device_get_syspath(dev, &syspath); r = sd_device_get_syspath(dev, &syspath);
if (r < 0) if (r < 0)
return log_device_debug_errno(dev, r, "sd_device_get_syspath failed: %m"); return r;
/* syspath is too short, to have a valid ACPI instance */ /* syspath is too short, to have a valid ACPI instance */
if (strlen(syspath) < STRLEN(PLATFORM_TEST) + 1) if (strlen(syspath) < sizeof _PLATFORM_TEST)
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EINVAL), return -EINVAL;
"Syspath \"%s\" is too short for a valid ACPI instance.",
syspath);
/* Vendor ID can be either PNP ID (3 chars A-Z) or ACPI ID (4 chars A-Z and numerals) */ /* Vendor ID can be either PNP ID (3 chars A-Z) or ACPI ID (4 chars A-Z and numerals) */
if (syspath[STRLEN(PLATFORM_TEST)] == ':') { if (syspath[sizeof _PLATFORM_TEST - 1] == ':') {
pattern = PLATFORM_PATTERN4; pattern = _PLATFORM_PATTERN4;
validchars = UPPERCASE_LETTERS DIGITS; validchars = UPPERCASE_LETTERS DIGITS;
} else { } else {
pattern = PLATFORM_PATTERN3; pattern = _PLATFORM_PATTERN3;
validchars = UPPERCASE_LETTERS; validchars = UPPERCASE_LETTERS;
} }
@ -574,23 +533,17 @@ static int names_platform(sd_device *dev, NetNames *names, bool test) {
* The Vendor (3 or 4 char), followed by hexadecimal model number : instance id. */ * The Vendor (3 or 4 char), followed by hexadecimal model number : instance id. */
DISABLE_WARNING_FORMAT_NONLITERAL; DISABLE_WARNING_FORMAT_NONLITERAL;
r = sscanf(syspath, pattern, vendor, &model, &instance, &ethid); if (sscanf(syspath, pattern, vendor, &model, &instance, &ethid) != 4)
REENABLE_WARNING;
log_device_debug(dev, "Parsing platform device information from syspath \"%s\": %s",
syspath, r == 4 ? "success" : "failure");
if (r != 4)
return -EINVAL; return -EINVAL;
REENABLE_WARNING;
if (!in_charset(vendor, validchars)) if (!in_charset(vendor, validchars))
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ENOENT), return -ENOENT;
"Platform vendor contains invalid characters: %s", vendor);
ascii_strlower(vendor); ascii_strlower(vendor);
xsprintf(names->platform_path, "a%s%xi%u", vendor, model, instance); xsprintf(names->platform_path, "a%s%xi%u", vendor, model, instance);
names->type = NET_PLATFORM; names->type = NET_PLATFORM;
log_device_debug(dev, "Platform identifier: vendor=%s model=%u instance=%u → %s",
vendor, model, instance, names->platform_path);
return 0; return 0;
} }
@ -666,31 +619,28 @@ static int names_usb(sd_device *dev, NetNames *names) {
r = sd_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_interface", &usbdev); r = sd_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_interface", &usbdev);
if (r < 0) if (r < 0)
return log_device_debug_errno(dev, r, "sd_device_get_parent_with_subsystem_devtype() failed: %m"); return r;
r = sd_device_get_sysname(usbdev, &sysname); r = sd_device_get_sysname(usbdev, &sysname);
if (r < 0) if (r < 0)
return log_device_debug_errno(usbdev, r, "sd_device_get_sysname() failed: %m"); return r;
/* get USB port number chain, configuration, interface */ /* get USB port number chain, configuration, interface */
strscpy(name, sizeof(name), sysname); strscpy(name, sizeof(name), sysname);
s = strchr(name, '-'); s = strchr(name, '-');
if (!s) if (!s)
return log_device_debug_errno(usbdev, SYNTHETIC_ERRNO(EINVAL), return -EINVAL;
"sysname \"%s\" does not have '-' in the expected place.", sysname);
ports = s+1; ports = s+1;
s = strchr(ports, ':'); s = strchr(ports, ':');
if (!s) if (!s)
return log_device_debug_errno(usbdev, SYNTHETIC_ERRNO(EINVAL), return -EINVAL;
"sysname \"%s\" does not have ':' in the expected place.", sysname);
s[0] = '\0'; s[0] = '\0';
config = s+1; config = s+1;
s = strchr(config, '.'); s = strchr(config, '.');
if (!s) if (!s)
return log_device_debug_errno(usbdev, SYNTHETIC_ERRNO(EINVAL), return -EINVAL;
"sysname \"%s\" does not have '.' in the expected place.", sysname);
s[0] = '\0'; s[0] = '\0';
interf = s+1; interf = s+1;
@ -709,10 +659,8 @@ static int names_usb(sd_device *dev, NetNames *names) {
if (!streq(interf, "0")) if (!streq(interf, "0"))
l = strpcpyl(&s, sizeof(names->usb_ports), "i", interf, NULL); l = strpcpyl(&s, sizeof(names->usb_ports), "i", interf, NULL);
if (l == 0) if (l == 0)
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ENAMETOOLONG), return -ENAMETOOLONG;
"Generated USB name would be too long.");
log_device_debug(dev, "USB name identifier: ports=%.*s config=%s interface=%s → %s",
(int) strlen(ports), sysname + (ports - name), config, interf, names->usb_ports);
names->type = NET_USB; names->type = NET_USB;
return 0; return 0;
} }
@ -728,31 +676,28 @@ static int names_bcma(sd_device *dev, NetNames *names) {
r = sd_device_get_parent_with_subsystem_devtype(dev, "bcma", NULL, &bcmadev); r = sd_device_get_parent_with_subsystem_devtype(dev, "bcma", NULL, &bcmadev);
if (r < 0) if (r < 0)
return log_device_debug_errno(dev, r, "sd_device_get_parent_with_subsystem_devtype() failed: %m"); return r;
r = sd_device_get_sysname(bcmadev, &sysname); r = sd_device_get_sysname(bcmadev, &sysname);
if (r < 0) if (r < 0)
return log_device_debug_errno(dev, r, "sd_device_get_sysname() failed: %m"); return r;
/* bus num:core num */ /* bus num:core num */
r = sscanf(sysname, "bcma%*u:%u", &core); if (sscanf(sysname, "bcma%*u:%u", &core) != 1)
log_device_debug(dev, "Parsing bcma device information from sysname \"%s\": %s",
sysname, r == 1 ? "success" : "failure");
if (r != 1)
return -EINVAL; return -EINVAL;
/* suppress the common core == 0 */ /* suppress the common core == 0 */
if (core > 0) if (core > 0)
xsprintf(names->bcma_core, "b%u", core); xsprintf(names->bcma_core, "b%u", core);
names->type = NET_BCMA; names->type = NET_BCMA;
log_device_debug(dev, "BCMA core identifier: core=%u → \"%s\"", core, names->bcma_core);
return 0; return 0;
} }
static int names_ccw(sd_device *dev, NetNames *names) { static int names_ccw(sd_device *dev, NetNames *names) {
sd_device *cdev; sd_device *cdev;
const char *bus_id, *subsys; const char *bus_id, *subsys;
size_t bus_id_start, bus_id_len; size_t bus_id_len;
size_t bus_id_start;
int r; int r;
assert(dev); assert(dev);
@ -761,7 +706,7 @@ static int names_ccw(sd_device *dev, NetNames *names) {
/* Retrieve the associated CCW device */ /* Retrieve the associated CCW device */
r = sd_device_get_parent(dev, &cdev); r = sd_device_get_parent(dev, &cdev);
if (r < 0) if (r < 0)
return log_device_debug_errno(dev, r, "sd_device_get_parent() failed: %m"); return r;
/* skip virtio subsystem if present */ /* skip virtio subsystem if present */
cdev = skip_virtio(cdev); cdev = skip_virtio(cdev);
@ -770,12 +715,11 @@ static int names_ccw(sd_device *dev, NetNames *names) {
r = sd_device_get_subsystem(cdev, &subsys); r = sd_device_get_subsystem(cdev, &subsys);
if (r < 0) if (r < 0)
return log_device_debug_errno(cdev, r, "sd_device_get_subsystem() failed: %m"); return r;
/* Network devices are either single or grouped CCW devices */ /* Network devices are either single or grouped CCW devices */
if (!STR_IN_SET(subsys, "ccwgroup", "ccw")) if (!STR_IN_SET(subsys, "ccwgroup", "ccw"))
return -ENOENT; return -ENOENT;
log_device_debug(dev, "Device is CCW.");
/* Retrieve bus-ID of the CCW device. The bus-ID uniquely /* Retrieve bus-ID of the CCW device. The bus-ID uniquely
* identifies the network device on the Linux on System z channel * identifies the network device on the Linux on System z channel
@ -783,15 +727,14 @@ static int names_ccw(sd_device *dev, NetNames *names) {
*/ */
r = sd_device_get_sysname(cdev, &bus_id); r = sd_device_get_sysname(cdev, &bus_id);
if (r < 0) if (r < 0)
return log_device_debug_errno(cdev, r, "Failed to get sysname: %m"); return r;
/* Check the length of the bus-ID. Rely on the fact that the kernel provides a correct bus-ID; /* Check the length of the bus-ID. Rely on the fact that the kernel provides a correct bus-ID;
* alternatively, improve this check and parse and verify each bus-ID part... * alternatively, improve this check and parse and verify each bus-ID part...
*/ */
bus_id_len = strlen(bus_id); bus_id_len = strlen(bus_id);
if (!IN_SET(bus_id_len, 8, 9)) if (!IN_SET(bus_id_len, 8, 9))
return log_device_debug_errno(cdev, SYNTHETIC_ERRNO(EINVAL), return -EINVAL;
"Invalid bus_id: %s", bus_id);
/* Strip leading zeros from the bus id for aesthetic purposes. This /* Strip leading zeros from the bus id for aesthetic purposes. This
* keeps the ccw names stable, yet much shorter in general case of * keeps the ccw names stable, yet much shorter in general case of
@ -802,11 +745,9 @@ static int names_ccw(sd_device *dev, NetNames *names) {
bus_id += bus_id_start < bus_id_len ? bus_id_start : bus_id_len - 1; bus_id += bus_id_start < bus_id_len ? bus_id_start : bus_id_len - 1;
/* Store the CCW bus-ID for use as network device name */ /* Store the CCW bus-ID for use as network device name */
if (!snprintf_ok(names->ccw_busid, sizeof(names->ccw_busid), "c%s", bus_id)) if (snprintf_ok(names->ccw_busid, sizeof(names->ccw_busid), "c%s", bus_id))
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ENAMETOOLONG),
"Generated CCW name would be too long.");
names->type = NET_CCW; names->type = NET_CCW;
log_device_debug(dev, "CCW identifier: ccw_busid=%s → \"%s\"", bus_id, names->ccw_busid);
return 0; return 0;
} }
@ -821,24 +762,19 @@ static int names_mac(sd_device *dev, const LinkInfo *info) {
/* The persistent part of a hardware address of an InfiniBand NIC is 8 bytes long. We cannot /* The persistent part of a hardware address of an InfiniBand NIC is 8 bytes long. We cannot
* fit this much in an iface name. * fit this much in an iface name.
* TODO: but it can be used as alternative names?? */ * TODO: but it can be used as alternative names?? */
if (info->iftype == ARPHRD_INFINIBAND) if (info->iftype == ARPHRD_INFINIBAND || info->hw_addr.length != 6)
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EOPNOTSUPP), return -EOPNOTSUPP;
"Not generating MAC name for infiniband device.");
if (info->hw_addr.length != 6)
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EOPNOTSUPP),
"Not generating MAC name for device with MAC address of length %zu.",
info->hw_addr.length);
/* check for NET_ADDR_PERM, skip random MAC addresses */ /* check for NET_ADDR_PERM, skip random MAC addresses */
r = sd_device_get_sysattr_value(dev, "addr_assign_type", &s); r = sd_device_get_sysattr_value(dev, "addr_assign_type", &s);
if (r < 0) if (r < 0)
return log_device_debug_errno(dev, r, "Failed to read addr_assign_type: %m"); return r;
r = safe_atou(s, &i); r = safe_atou(s, &i);
if (r < 0) if (r < 0)
return log_device_debug_errno(dev, r, "Failed to parse addr_assign_type: %m"); return r;
if (i != NET_ADDR_PERM) if (i != NET_ADDR_PERM)
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EINVAL), return -EINVAL;
"addr_assign_type=%d, MAC address is not permanent.", i);
return 0; return 0;
} }
@ -1020,8 +956,6 @@ static int builtin_net_id(sd_device *dev, sd_netlink **rtnl, int argc, char *arg
xsprintf(str, "%s%s", prefix, HW_ADDR_TO_STR_FULL(&info.hw_addr, HW_ADDR_TO_STRING_NO_COLON)); xsprintf(str, "%s%s", prefix, HW_ADDR_TO_STR_FULL(&info.hw_addr, HW_ADDR_TO_STRING_NO_COLON));
udev_builtin_add_property(dev, test, "ID_NET_NAME_MAC", str); udev_builtin_add_property(dev, test, "ID_NET_NAME_MAC", str);
log_device_debug(dev, "MAC address identifier: hw_addr=%s → %s",
HW_ADDR_TO_STR(&info.hw_addr), str + strlen(prefix));
ieee_oui(dev, &info, test); ieee_oui(dev, &info, test);
} }

View File

@ -5,6 +5,6 @@ Description=Create a lot of memory pressure
[Service] [Service]
# A VERY small memory.high will cause the script (trying to use a lot of memory) # A VERY small memory.high will cause the script (trying to use a lot of memory)
# to throttle and be put under heavy pressure. # to throttle and be put under heavy pressure.
MemoryHigh=5M MemoryHigh=1M
Slice=testsuite-55-workload.slice Slice=testsuite-55-workload.slice
ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-55-slowgrowth.sh ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-55-slowgrowth.sh

View File

@ -3,6 +3,5 @@
Description=No memory pressure Description=No memory pressure
[Service] [Service]
MemoryHigh=3M
Slice=testsuite-55-workload.slice Slice=testsuite-55-workload.slice
ExecStart=sleep infinity ExecStart=sleep infinity

View File

@ -3,6 +3,6 @@
Description=Create some memory pressure Description=Create some memory pressure
[Service] [Service]
MemoryHigh=6M MemoryHigh=2M
Slice=testsuite-55-workload.slice Slice=testsuite-55-workload.slice
ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-55-slowgrowth.sh ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-55-slowgrowth.sh