integ/base/systemd/debian/patches/0014-Introduce-and-use-custom-NIC-naming-scheme.patch
Wentao Zhang 583e744578 Debian: Upgrade systemd version from 247.3-7 to 251.3-1
Debian systemd 247. 3-7 will result in greater
overall CPU usage than Centos.
The upgrade to 251 can reduce overall CPU usage
by about 8%, about the same as Centos.

Remove some patches that already involved in systemd 251.3-1

Test Plan(Debian only):
Pass: package and Image build successfully.
Pass: Image boot successfully.
Pass: Ran the high-stress system test for about
      4 days and found nothing abnormal.

Story: 2009221
Task: 46034
Signed-off-by: Wentao Zhang <Wentao.Zhang@windriver.com>
Change-Id: I732fa51db50e2affc33c4b2ec39a912fb16240cb
2022-08-26 13:10:48 +08:00

119 lines
5.3 KiB
Diff

From b03d8485ebf90da8bdf70d51e022dff738cc0107 Mon Sep 17 00:00:00 2001
From: Dan Voiculeasa <dan.voiculeasa@windriver.com>
Date: Wed, 18 May 2022 13:20:33 +0300
Subject: [PATCH] Introduce and use custom NIC naming scheme
To add some context we start by referencing [1].
More lab tests are enabled now, which reveal more systemd naming
inconsistencies: searching parent slots ([2] vs [3]),
usage of port_name for path and slot ([4] vs [5], [6] vs [7]).
Based on previous observations infer that port_name[8] has to be
dropped from [9], even though it is not yet observed in any lab.
We observe we can't rely on a particular naming scheme already
implemented in systemd, thus we must create a custom one.
Name based on upcoming STX7.0 release.
Align naming to CentOS for discovered differences.
[1]: https://review.opendev.org/c/starlingx/kernel/+/841369
[2]: https://github.com/systemd/systemd/blob/v247/src/udev/
udev-builtin-net_id.c#L362,L373
[3]: https://github.com/systemd/systemd/blob/v219/src/udev/
udev-builtin-net_id.c#L229,L237
[4]: https://github.com/systemd/systemd/blob/v247/src/udev/
udev-builtin-net_id.c#L321-L324
[5]: https://github.com/systemd/systemd/blob/v219/src/udev/
udev-builtin-net_id.c#L198-L199
[6]: https://github.com/systemd/systemd/blob/v247/src/udev/
udev-builtin-net_id.c#L391-L394
[7]: https://github.com/systemd/systemd/blob/v219/src/udev/
udev-builtin-net_id.c#L248-L249
[8]: https://github.com/systemd/systemd/commit/
4887b656c22af059d4e833de7b56544f24951184
[9]: https://github.com/systemd/systemd/blob/v247/src/udev/
udev-builtin-net_id.c#L204-L207
Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com>
---
src/shared/netif-naming-scheme.c | 2 ++
src/shared/netif-naming-scheme.h | 8 ++++++
src/udev/udev-builtin-net_id.c | 6 ++--
4 files changed, 54 insertions(+), 10 deletions(-)
diff --git a/src/shared/netif-naming-scheme.c b/src/shared/netif-naming-scheme.c
index e95072e..dcb233d 100644
--- a/src/shared/netif-naming-scheme.c
+++ b/src/shared/netif-naming-scheme.c
@@ -24,6 +24,8 @@ static const NamingScheme naming_schemes[] = {
{ "v249", NAMING_V249 },
{ "v250", NAMING_V250 },
{ "v251", NAMING_V251 },
+ { "vSTX7_0", NAMING_VSTX7_0 },
+
/* … add more schemes here, as the logic to name devices is updated … */
EXTRA_NET_NAMING_MAP
diff --git a/src/shared/netif-naming-scheme.h b/src/shared/netif-naming-scheme.h
index 5303348..907b3d2 100644
--- a/src/shared/netif-naming-scheme.h
+++ b/src/shared/netif-naming-scheme.h
@@ -38,6 +38,9 @@ typedef enum NamingSchemeFlags {
NAMING_XEN_VIF = 1 << 13, /* Generate names for Xen netfront devices */
NAMING_BRIDGE_MULTIFUNCTION_SLOT = 1 << 14, /* Use PCI hotplug slot information associated with bridge, but only if PCI device is multifunction */
+ NAMING_VSTX7_0 = NAMING_BRIDGE_NO_SLOT,
+
+
/* And now the masks that combine the features above */
NAMING_V238 = 0,
NAMING_V239 = NAMING_V238 | NAMING_SR_IOV_V | NAMING_NPAR_ARI,
@@ -63,10 +66,15 @@ typedef struct NamingScheme {
const NamingScheme* naming_scheme_from_name(const char *name);
const NamingScheme* naming_scheme(void);
+
static inline bool naming_scheme_has(NamingSchemeFlags flags) {
return FLAGS_SET(naming_scheme()->flags, flags);
}
+static inline bool naming_scheme_is(NamingSchemeFlags flags) {
+ return naming_scheme()->flags == flags;
+}
+
typedef enum NamePolicy {
NAMEPOLICY_KERNEL,
NAMEPOLICY_KEEP,
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index f2ea2a7..755a3f7 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -208,7 +208,7 @@ static int dev_pci_onboard(sd_device *dev, const LinkInfo *info, NetNames *names
s = names->pci_onboard;
l = sizeof(names->pci_onboard);
l = strpcpyf(&s, l, "o%lu", idx);
- if (!isempty(info->phys_port_name))
+ if (!isempty(info->phys_port_name) && !naming_scheme_is(NAMING_VSTX7_0))
/* kernel provided front panel port name for multiple port PCI device */
l = strpcpyf(&s, l, "n%s", info->phys_port_name);
else if (dev_port > 0)
@@ -385,7 +385,7 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) {
l = strpcpyf(&s, l, "p%us%u", bus, slot);
if (func > 0 || is_pci_multifunction(names->pcidev))
l = strpcpyf(&s, l, "f%u", func);
- if (!isempty(info->phys_port_name))
+ if (!isempty(info->phys_port_name) && !naming_scheme_is(NAMING_VSTX7_0))
/* kernel provided front panel port name for multi-port PCI device */
l = strpcpyf(&s, l, "n%s", info->phys_port_name);
else if (dev_port > 0)
@@ -480,7 +480,7 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) {
l = strpcpyf(&s, l, "s%"PRIu32, hotplug_slot);
if (func > 0 || is_pci_multifunction(names->pcidev))
l = strpcpyf(&s, l, "f%u", func);
- if (!isempty(info->phys_port_name))
+ if (!isempty(info->phys_port_name) && !naming_scheme_is(NAMING_VSTX7_0))
l = strpcpyf(&s, l, "n%s", info->phys_port_name);
else if (dev_port > 0)
l = strpcpyf(&s, l, "d%lu", dev_port);
--
2.25.1