From 7824e5a16e8fd70eef3885a9f1a73e070e424027 Mon Sep 17 00:00:00 2001
From: importbot <releng@rockylinux.org>
Date: Thu, 15 Aug 2024 23:25:49 +0000
Subject: [PATCH] import systemd-256-12.el10

---
 ...if-naming-scheme-add-rhel-9.5-scheme.patch |  64 ++++++
 ..._id-use-firmware_node-sun-for-ID_NET.patch | 197 ++++++++++++++++++
 ...net-naming-scheme-add-missing-period.patch |  36 ++++
 ...-drop-the-dependency-on-python3-zstd.patch |  28 +++
 SPECS/systemd.spec                            |  14 +-
 5 files changed, 337 insertions(+), 2 deletions(-)
 create mode 100644 SOURCES/0076-netif-naming-scheme-add-rhel-9.5-scheme.patch
 create mode 100644 SOURCES/0077-udev-builtin-net_id-use-firmware_node-sun-for-ID_NET.patch
 create mode 100644 SOURCES/0078-man-net-naming-scheme-add-missing-period.patch
 create mode 100644 SOURCES/0079-Revert-packit-drop-the-dependency-on-python3-zstd.patch

diff --git a/SOURCES/0076-netif-naming-scheme-add-rhel-9.5-scheme.patch b/SOURCES/0076-netif-naming-scheme-add-rhel-9.5-scheme.patch
new file mode 100644
index 0000000..69e96ab
--- /dev/null
+++ b/SOURCES/0076-netif-naming-scheme-add-rhel-9.5-scheme.patch
@@ -0,0 +1,64 @@
+From fefc4bc15fe28d8f7def8bd75ada13ede21663cb Mon Sep 17 00:00:00 2001
+From: Jan Macku <jamacku@redhat.com>
+Date: Thu, 8 Aug 2024 13:12:58 +0200
+Subject: [PATCH] netif-naming-scheme: add rhel-9.5 scheme
+
+rhel-only: policy
+
+Resolves: RHEL-44416
+---
+ man/systemd.net-naming-scheme.xml | 15 +++++++++++++++
+ src/shared/netif-naming-scheme.c  |  1 +
+ src/shared/netif-naming-scheme.h  |  1 +
+ 3 files changed, 17 insertions(+)
+
+diff --git a/man/systemd.net-naming-scheme.xml b/man/systemd.net-naming-scheme.xml
+index 690e3d2c27..b2d78c95ab 100644
+--- a/man/systemd.net-naming-scheme.xml
++++ b/man/systemd.net-naming-scheme.xml
+@@ -592,6 +592,21 @@
+           <xi:include href="version-info.xml" xpointer="rhel-9.4"/>
+           </listitem>
+         </varlistentry>
++
++        <varlistentry>
++            <term><constant>rhel-9.5</constant></term>
++
++          <listitem><para>Never generate a slot name when a PCI bridge is detected.</para>
++
++          <para>Since version <constant>"rhel-9.0"</constant>, we have generated slot-based names
++          for PCI multifunction devices, because we assumed that it is enough to use function numbers
++          to distinguish between devices. However, name conflict can occur if these devices are not
++          children of the same PCI bridge, e.g. there are multiple PCI bridges in the same slot.
++          </para>
++
++          <xi:include href="version-info.xml" xpointer="rhel-9.5"/>
++          </listitem>
++        </varlistentry>
+       </variablelist>
+       </refsect2>
+ 
+diff --git a/src/shared/netif-naming-scheme.c b/src/shared/netif-naming-scheme.c
+index e4d4c0ba88..149794e926 100644
+--- a/src/shared/netif-naming-scheme.c
++++ b/src/shared/netif-naming-scheme.c
+@@ -40,6 +40,7 @@ static const NamingScheme naming_schemes[] = {
+         { "rhel-9.2", NAMING_RHEL_9_2 },
+         { "rhel-9.3", NAMING_RHEL_9_3 },
+         { "rhel-9.4", NAMING_RHEL_9_4 },
++        { "rhel-9.5", NAMING_RHEL_9_5 },
+         { "rhel-10.0", NAMING_RHEL_10_0 },
+         /* … add more schemes here, as the logic to name devices is updated … */
+ 
+diff --git a/src/shared/netif-naming-scheme.h b/src/shared/netif-naming-scheme.h
+index b0697c141e..a55bb0b1cb 100644
+--- a/src/shared/netif-naming-scheme.h
++++ b/src/shared/netif-naming-scheme.h
+@@ -80,6 +80,7 @@ typedef enum NamingSchemeFlags {
+         NAMING_RHEL_9_2 = NAMING_RHEL_9_0,
+         NAMING_RHEL_9_3 = NAMING_RHEL_9_0 | NAMING_SR_IOV_R,
+         NAMING_RHEL_9_4 = NAMING_RHEL_9_3,
++        NAMING_RHEL_9_5 = NAMING_RHEL_9_4 & ~NAMING_BRIDGE_MULTIFUNCTION_SLOT,
+ 
+         NAMING_RHEL_10_0 = NAMING_V255,
+ 
diff --git a/SOURCES/0077-udev-builtin-net_id-use-firmware_node-sun-for-ID_NET.patch b/SOURCES/0077-udev-builtin-net_id-use-firmware_node-sun-for-ID_NET.patch
new file mode 100644
index 0000000..ff6c617
--- /dev/null
+++ b/SOURCES/0077-udev-builtin-net_id-use-firmware_node-sun-for-ID_NET.patch
@@ -0,0 +1,197 @@
+From 45fe2e91e4f73c998ff4d29c316cc4fca9d25942 Mon Sep 17 00:00:00 2001
+From: Etienne Champetier <e.champetier@ateme.com>
+Date: Tue, 9 Jul 2024 11:53:50 -0400
+Subject: [PATCH] udev-builtin-net_id: use firmware_node/sun for
+ ID_NET_NAME_SLOT
+
+pci_get_hotplug_slot() has the following limitations:
+- if slots are not hotpluggable, they are not in /sys/bus/pci/slots.
+- the address at /sys/bus/pci/slots/X/addr doesn't contains the function part,
+  so on some system, 2 different slots with different _SUN end up with the same
+  hotplug_slot, leading to naming conflicts.
+- it tries all parent devices until it finds a slot number, which is incorrect,
+  and what led to NAMING_BRIDGE_MULTIFUNCTION_SLOT being disabled.
+
+The use of PCI hotplug to find the slot (ACPI _SUN) was introduced in
+https://github.com/systemd/systemd/commit/0035597a30d120f70df2dd7da3d6128fb8ba6051
+"udev: net_id - export PCI hotplug slot names" on 2012/11/26.
+At the same time on the kernel side we got
+https://github.com/torvalds/linux/commit/bb74ac23b10820d8722c3e1f4add9ef59e703f63
+"ACPI: create _SUN sysfs file" on 2012/11/16.
+
+Using PCI hotplug was the only way at the time, but now 12 years later we can use
+firmware_node/sun sysfs file.
+Looking at a small selection of server HW, for HPE (Gen10 DL325), the _SUN is attached
+to the NIC device, whereas for Dell (R640/R6515/R6615) and Cisco (UCSC-C220-M5SX),
+the _SUN is on the first parent pcieport.
+
+We still fallback to pci_get_hotplug_slot() to handle the s390 case and
+maybe some other coner cases (_SUN on grand parent device that is not a
+bridge ?).
+
+(cherry picked from commit 0a4ecc54cb9f2d3418b970c51bfadb69c34ae9eb)
+
+Related: RHEL-44416
+---
+ man/systemd.net-naming-scheme.xml |  6 ++-
+ src/shared/netif-naming-scheme.h  |  5 ++-
+ src/udev/udev-builtin-net_id.c    | 72 ++++++++++++++++++++++++++-----
+ 3 files changed, 69 insertions(+), 14 deletions(-)
+
+diff --git a/man/systemd.net-naming-scheme.xml b/man/systemd.net-naming-scheme.xml
+index b2d78c95ab..ea9a9c8d3c 100644
+--- a/man/systemd.net-naming-scheme.xml
++++ b/man/systemd.net-naming-scheme.xml
+@@ -528,7 +528,7 @@
+         <varlistentry>
+           <term><constant>rhel-10.0</constant></term>
+ 
+-          <listitem><para>Same as naming scheme <constant>v255</constant>.</para>
++          <listitem><para>PCI slot number is now read from <constant>firmware_node/sun</constant> sysfs file</para>
+ 
+           <xi:include href="version-info.xml" xpointer="rhel-10.0"/>
+           </listitem>
+@@ -604,6 +604,8 @@
+           children of the same PCI bridge, e.g. there are multiple PCI bridges in the same slot.
+           </para>
+ 
++          <para>PCI slot number is now read from <constant>firmware_node/sun</constant> sysfs file</para>
++
+           <xi:include href="version-info.xml" xpointer="rhel-9.5"/>
+           </listitem>
+         </varlistentry>
+@@ -798,7 +800,7 @@ ID_NET_NAME_ONBOARD_LABEL=Ethernet Port 1
+     </example>
+ 
+     <example>
+-      <title>PCI Ethernet card in hotplug slot with firmware index number</title>
++      <title>PCI Ethernet card in slot with firmware index number</title>
+ 
+       <programlisting># /sys/devices/pci0000:00/0000:00:1c.3/0000:05:00.0/net/ens1
+ ID_NET_NAME_MAC=enx000000000466
+diff --git a/src/shared/netif-naming-scheme.h b/src/shared/netif-naming-scheme.h
+index a55bb0b1cb..229232d452 100644
+--- a/src/shared/netif-naming-scheme.h
++++ b/src/shared/netif-naming-scheme.h
+@@ -43,6 +43,7 @@ typedef enum NamingSchemeFlags {
+         NAMING_DEVICETREE_ALIASES        = 1 << 15, /* Generate names from devicetree aliases */
+         NAMING_USB_HOST                  = 1 << 16, /* Generate names for usb host */
+         NAMING_SR_IOV_R                  = 1 << 17, /* Use "r" suffix for SR-IOV VF representors */
++        NAMING_FIRMWARE_NODE_SUN         = 1 << 18, /* Use firmware_node/sun to get PCI slot number */
+ 
+         /* And now the masks that combine the features above */
+         NAMING_V238 = 0,
+@@ -80,9 +81,9 @@ typedef enum NamingSchemeFlags {
+         NAMING_RHEL_9_2 = NAMING_RHEL_9_0,
+         NAMING_RHEL_9_3 = NAMING_RHEL_9_0 | NAMING_SR_IOV_R,
+         NAMING_RHEL_9_4 = NAMING_RHEL_9_3,
+-        NAMING_RHEL_9_5 = NAMING_RHEL_9_4 & ~NAMING_BRIDGE_MULTIFUNCTION_SLOT,
++        NAMING_RHEL_9_5 = (NAMING_RHEL_9_4 & ~NAMING_BRIDGE_MULTIFUNCTION_SLOT) | NAMING_FIRMWARE_NODE_SUN,
+ 
+-        NAMING_RHEL_10_0 = NAMING_V255,
++        NAMING_RHEL_10_0 = NAMING_V255 | NAMING_FIRMWARE_NODE_SUN,
+ 
+         EXTRA_NET_NAMING_SCHEMES
+ 
+diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
+index 384a1f31cb..d34357fdb2 100644
+--- a/src/udev/udev-builtin-net_id.c
++++ b/src/udev/udev-builtin-net_id.c
+@@ -566,6 +566,51 @@ static int pci_get_hotplug_slot(sd_device *dev, uint32_t *ret) {
+         return -ENOENT;
+ }
+ 
++static int get_device_firmware_node_sun(sd_device *dev, uint32_t *ret) {
++        const char *attr;
++        int r;
++
++        assert(dev);
++        assert(ret);
++
++        r = device_get_sysattr_value_filtered(dev, "firmware_node/sun", &attr);
++        if (r < 0)
++                return log_device_debug_errno(dev, r, "Failed to read firmware_node/sun, ignoring: %m");
++
++        r = safe_atou32(attr, ret);
++        if (r < 0)
++                return log_device_warning_errno(dev, r, "Failed to parse firmware_node/sun '%s', ignoring: %m", attr);
++
++        return 0;
++}
++
++static int pci_get_slot_from_firmware_node_sun(sd_device *dev, uint32_t *ret) {
++        int r;
++        sd_device *slot_dev;
++
++        assert(dev);
++        assert(ret);
++
++        /* Try getting the ACPI _SUN for the device */
++        if (get_device_firmware_node_sun(dev, ret) >= 0)
++                return 0;
++
++        r = sd_device_get_parent_with_subsystem_devtype(dev, "pci", NULL, &slot_dev);
++        if (r < 0)
++                return log_device_debug_errno(dev, r, "Failed to find pci parent, ignoring: %m");
++
++        if (is_pci_bridge(slot_dev) && is_pci_multifunction(dev) <= 0)
++                return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ESTALE),
++                                              "Not using slot information because the parent pcieport "
++                                              "is a bridge and the PCI device is not multifunction.");
++
++        /* Try getting the ACPI _SUN from the parent pcieport */
++        if (get_device_firmware_node_sun(slot_dev, ret) >= 0)
++                return 0;
++
++        return -ENOENT;
++}
++
+ static int get_pci_slot_specifiers(
+                 sd_device *dev,
+                 char **ret_domain,
+@@ -616,7 +661,7 @@ static int get_pci_slot_specifiers(
+ 
+ static int names_pci_slot(sd_device *dev, sd_device *pci_dev, const char *prefix, const char *suffix, EventMode mode) {
+         _cleanup_free_ char *domain = NULL, *bus_and_slot = NULL, *func = NULL, *port = NULL;
+-        uint32_t hotplug_slot = 0;  /* avoid false maybe-uninitialized warning */
++        uint32_t slot = 0;  /* avoid false maybe-uninitialized warning */
+         char str[ALTIFNAMSIZ];
+         int r;
+ 
+@@ -641,20 +686,27 @@ static int names_pci_slot(sd_device *dev, sd_device *pci_dev, const char *prefix
+                          strna(domain), bus_and_slot, strna(func), strna(port),
+                          special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), empty_to_na(str));
+ 
+-        r = pci_get_hotplug_slot(pci_dev, &hotplug_slot);
+-        if (r < 0)
+-                return r;
+-        if (r > 0)
+-                /* If the hotplug slot is found through the function ID, then drop the domain from the name.
+-                 * See comments in parse_hotplug_slot_from_function_id(). */
+-                domain = mfree(domain);
++        if (naming_scheme_has(NAMING_FIRMWARE_NODE_SUN))
++                r = pci_get_slot_from_firmware_node_sun(pci_dev, &slot);
++        else
++                r = -1;
++        /* If we don't find a slot using firmware_node/sun, fallback to hotplug_slot */
++        if (r < 0) {
++                r = pci_get_hotplug_slot(pci_dev, &slot);
++                if (r < 0)
++                        return r;
++                if (r > 0)
++                        /* If the hotplug slot is found through the function ID, then drop the domain from the name.
++                        * See comments in parse_hotplug_slot_from_function_id(). */
++                        domain = mfree(domain);
++        }
+ 
+         if (snprintf_ok(str, sizeof str, "%s%ss%"PRIu32"%s%s%s",
+-                        prefix, strempty(domain), hotplug_slot, strempty(func), strempty(port), strempty(suffix)))
++                        prefix, strempty(domain), slot, strempty(func), strempty(port), strempty(suffix)))
+                 udev_builtin_add_property(dev, mode, "ID_NET_NAME_SLOT", str);
+ 
+         log_device_debug(dev, "Slot identifier: domain=%s slot=%"PRIu32" func=%s port=%s %s %s",
+-                         strna(domain), hotplug_slot, strna(func), strna(port),
++                         strna(domain), slot, strna(func), strna(port),
+                          special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), empty_to_na(str));
+ 
+         return 0;
diff --git a/SOURCES/0078-man-net-naming-scheme-add-missing-period.patch b/SOURCES/0078-man-net-naming-scheme-add-missing-period.patch
new file mode 100644
index 0000000..5a04788
--- /dev/null
+++ b/SOURCES/0078-man-net-naming-scheme-add-missing-period.patch
@@ -0,0 +1,36 @@
+From f5470e9076138ccf69fb6576e950a75da4b89717 Mon Sep 17 00:00:00 2001
+From: Yu Watanabe <watanabe.yu+github@gmail.com>
+Date: Fri, 2 Aug 2024 16:51:15 +0900
+Subject: [PATCH] man/net-naming-scheme: add missing period
+
+Follow-up for 0a4ecc54cb9f2d3418b970c51bfadb69c34ae9eb.
+
+(cherry picked from commit 2bb72aadb8169c9310c8ca0d586d277a4a71e2f8)
+
+Related: RHEL-44416
+---
+ man/systemd.net-naming-scheme.xml | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/man/systemd.net-naming-scheme.xml b/man/systemd.net-naming-scheme.xml
+index ea9a9c8d3c..e458b5dd6b 100644
+--- a/man/systemd.net-naming-scheme.xml
++++ b/man/systemd.net-naming-scheme.xml
+@@ -528,7 +528,7 @@
+         <varlistentry>
+           <term><constant>rhel-10.0</constant></term>
+ 
+-          <listitem><para>PCI slot number is now read from <constant>firmware_node/sun</constant> sysfs file</para>
++          <listitem><para>PCI slot number is now read from <constant>firmware_node/sun</constant> sysfs file.</para>
+ 
+           <xi:include href="version-info.xml" xpointer="rhel-10.0"/>
+           </listitem>
+@@ -604,7 +604,7 @@
+           children of the same PCI bridge, e.g. there are multiple PCI bridges in the same slot.
+           </para>
+ 
+-          <para>PCI slot number is now read from <constant>firmware_node/sun</constant> sysfs file</para>
++          <para>PCI slot number is now read from <constant>firmware_node/sun</constant> sysfs file.</para>
+ 
+           <xi:include href="version-info.xml" xpointer="rhel-9.5"/>
+           </listitem>
diff --git a/SOURCES/0079-Revert-packit-drop-the-dependency-on-python3-zstd.patch b/SOURCES/0079-Revert-packit-drop-the-dependency-on-python3-zstd.patch
new file mode 100644
index 0000000..c3f26af
--- /dev/null
+++ b/SOURCES/0079-Revert-packit-drop-the-dependency-on-python3-zstd.patch
@@ -0,0 +1,28 @@
+From 6bec94d825960a39bed6429531e722fd1571664b Mon Sep 17 00:00:00 2001
+From: Jan Macku <jamacku@redhat.com>
+Date: Wed, 14 Aug 2024 12:21:59 +0200
+Subject: [PATCH] Revert "packit: drop the dependency on python3-zstd"
+
+This reverts commit 43bf3e1a42e2c1a6ecd0ca6fd72c9bc6fe904703.
+
+rhel-only: ci
+
+Related: RHEL-36636
+---
+ .packit.yml | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/.packit.yml b/.packit.yml
+index 48ba210947..03b3aae7d5 100644
+--- a/.packit.yml
++++ b/.packit.yml
+@@ -39,9 +39,6 @@ actions:
+     - 'sed -i "/^CONFIGURE_OPTS=(/a--werror" .packit_rpm/systemd.spec'
+     # Ignore unpackaged standalone binaries
+     - "sed -i 's/assert False,.*/pass/' .packit_rpm/split-files.py"
+-    # Drop the python3dist(zstd) dependency, as it's only in the RHEL buildroot
+-    # repo
+-    - "sed -i '/python3dist(zstd)/d' .packit_rpm/systemd.spec"
+ 
+ # Available targets can be listed via `copr-cli list-chroots`
+ jobs:
diff --git a/SPECS/systemd.spec b/SPECS/systemd.spec
index 5ac2225..95e7ad6 100644
--- a/SPECS/systemd.spec
+++ b/SPECS/systemd.spec
@@ -48,7 +48,7 @@ Url:            https://systemd.io
 # Allow users to specify the version and release when building the rpm by 
 # setting the %%version_override and %%release_override macros.
 Version:        %{?version_override}%{!?version_override:256}
-Release:        11%{?dist}
+Release:        12%{?dist}
 
 %global stable %(c="%version"; [ "$c" = "${c#*.*}" ]; echo $?)
 
@@ -181,6 +181,10 @@ Patch0072: 0072-Avoid-tmp-being-mounted-as-tmpfs-without-the-user-s-.patch
 Patch0073: 0073-unit-don-t-add-Requires-for-tmp.mount.patch
 Patch0074: 0074-units-add-Install-section-to-tmp.mount.patch
 Patch0075: 0075-units-don-t-enable-tmp.mount-statically-in-local-fs..patch
+Patch0076: 0076-netif-naming-scheme-add-rhel-9.5-scheme.patch
+Patch0077: 0077-udev-builtin-net_id-use-firmware_node-sun-for-ID_NET.patch
+Patch0078: 0078-man-net-naming-scheme-add-missing-period.patch
+Patch0079: 0079-Revert-packit-drop-the-dependency-on-python3-zstd.patch
 
 # Downstream-only patches (9000–9999)
 
@@ -621,7 +625,7 @@ CONFIGURE_OPTS=(
         -Drc-local=/etc/rc.d/rc.local
         -Ddns-servers=
         -Duser-path=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
-        -Dservice-watchdog=
+        -Dservice-watchdog=3min
         -Ddev-kvm-mode=0666
         -Dkmod=enabled
         -Dxkbcommon=enabled
@@ -1107,6 +1111,12 @@ rm -f .file-list-*
 rm -f %{name}.lang
 
 %changelog
+* Thu Aug 15 2024 systemd maintenance team <systemd-maint@redhat.com> - 256-12
+- netif-naming-scheme: add rhel-9.5 scheme (RHEL-44416)
+- udev-builtin-net_id: use firmware_node/sun for ID_NET_NAME_SLOT (RHEL-44416)
+- man/net-naming-scheme: add missing period (RHEL-44416)
+- Revert "packit: drop the dependency on python3-zstd" (RHEL-36636)
+
 * Tue Jul 30 2024 systemd maintenance team <systemd-maint@redhat.com> - 256-11
 - fix OpenScanHub builds (RHEL-40924)
 
-- 
GitLab