From 117b3ffe680083091d77cbf2c4289a529ed7dc42 Mon Sep 17 00:00:00 2001 From: Michal Sekletar Date: Wed, 22 Feb 2017 10:17:54 +0100 Subject: [PATCH] Backport support for phys_port_name to net_id Resolves: #1425737 --- ...support-for-phys_port_name-attribute.patch | 105 ++++++++++++++++++ systemd.spec | 6 +- 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 0023-udev-net_id-add-support-for-phys_port_name-attribute.patch diff --git a/0023-udev-net_id-add-support-for-phys_port_name-attribute.patch b/0023-udev-net_id-add-support-for-phys_port_name-attribute.patch new file mode 100644 index 0000000..8652c90 --- /dev/null +++ b/0023-udev-net_id-add-support-for-phys_port_name-attribute.patch @@ -0,0 +1,105 @@ +From 3081adc053a862e8ccbccd97cd45168c0af052aa Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ji=C5=99=C3=AD=20P=C3=ADrko?= +Date: Wed, 2 Nov 2016 03:46:01 +0100 +Subject: [PATCH] udev: net_id: add support for phys_port_name attribute + (#4506) + +Switch drivers uses phys_port_name attribute to pass front panel port +name to user. Use it to generate netdev names. + +Signed-off-by: Jiri Pirko +(cherry picked from commit 4887b656c22af059d4e833de7b56544f24951184) +--- + src/udev/udev-builtin-net_id.c | 30 ++++++++++++++++++++++-------- + 1 file changed, 22 insertions(+), 8 deletions(-) + +diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c +index a7be2a4..0eb2500 100644 +--- a/src/udev/udev-builtin-net_id.c ++++ b/src/udev/udev-builtin-net_id.c +@@ -35,10 +35,12 @@ + * Type of names: + * b — BCMA bus core number + * c — CCW bus group name, without leading zeros [s390] +- * o[d] — on-board device index number +- * s[f][d] — hotplug slot index number ++ * o[n|d] ++ * — on-board device index number ++ * s[f][n|d] ++ * — hotplug slot index number + * x — MAC address +- * [P]ps[f][d] ++ * [P]ps[f][n|d] + * — PCI geographical location + * [P]ps[f][u][..][c][i] + * — USB port number chain +@@ -137,7 +139,7 @@ static int dev_pci_onboard(struct udev_device *dev, struct netnames *names) { + unsigned dev_port = 0; + size_t l; + char *s; +- const char *attr; ++ const char *attr, *port_name; + int idx; + + /* ACPI _DSM — device specific method for naming a PCI or PCI Express device */ +@@ -164,10 +166,15 @@ static int dev_pci_onboard(struct udev_device *dev, struct netnames *names) { + if (attr) + dev_port = strtol(attr, NULL, 10); + ++ /* kernel provided front panel port name for multiple port PCI device */ ++ port_name = udev_device_get_sysattr_value(dev, "phys_port_name"); ++ + s = names->pci_onboard; + l = sizeof(names->pci_onboard); + l = strpcpyf(&s, l, "o%d", idx); +- if (dev_port > 0) ++ if (port_name) ++ l = strpcpyf(&s, l, "n%s", port_name); ++ else if (dev_port > 0) + l = strpcpyf(&s, l, "d%d", dev_port); + if (l == 0) + names->pci_onboard[0] = '\0'; +@@ -202,7 +209,7 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) { + unsigned domain, bus, slot, func, dev_port = 0; + size_t l; + char *s; +- const char *attr; ++ const char *attr, *port_name; + struct udev_device *pci = NULL; + char slots[256], str[256]; + _cleanup_closedir_ DIR *dir = NULL; +@@ -217,6 +224,9 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) { + if (attr) + dev_port = strtol(attr, NULL, 10); + ++ /* kernel provided front panel port name for multiple port PCI device */ ++ port_name = udev_device_get_sysattr_value(dev, "phys_port_name"); ++ + /* compose a name based on the raw kernel's PCI bus, slot numbers */ + s = names->pci_path; + l = sizeof(names->pci_path); +@@ -225,7 +235,9 @@ static int dev_pci_slot(struct udev_device *dev, struct 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 (dev_port > 0) ++ if (port_name) ++ l = strpcpyf(&s, l, "n%s", port_name); ++ else if (dev_port > 0) + l = strpcpyf(&s, l, "d%u", dev_port); + if (l == 0) + names->pci_path[0] = '\0'; +@@ -275,7 +287,9 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) { + l = strpcpyf(&s, l, "s%d", hotplug_slot); + if (func > 0 || is_pci_multifunction(names->pcidev)) + l = strpcpyf(&s, l, "f%d", func); +- if (dev_port > 0) ++ if (port_name) ++ l = strpcpyf(&s, l, "n%s", port_name); ++ else if (dev_port > 0) + l = strpcpyf(&s, l, "d%d", dev_port); + if (l == 0) + names->pci_slot[0] = '\0'; +-- +2.9.3 + diff --git a/systemd.spec b/systemd.spec index 818d38e..006595c 100644 --- a/systemd.spec +++ b/systemd.spec @@ -12,7 +12,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 231 -Release: 13%{?gitcommit:.git%{gitcommitshort}}%{?dist} +Release: 14%{?gitcommit:.git%{gitcommitshort}}%{?dist} # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: A System and Service Manager @@ -59,6 +59,7 @@ Patch0019: 0019-shared-install-fix-set-default-with-empty-root-4118.patch Patch0020: 0020-Various-simplifications.patch Patch0021: 0021-build-sys-check-for-lz4-in-the-old-and-new-numbering.patch Patch0022: 0022-pid1-do-not-use-mtime-0-as-sign-of-masking-4388.patch +Patch0023: 0023-udev-net_id-add-support-for-phys_port_name-attribute.patch Patch0998: 0998-resolved-create-etc-resolv.conf-symlink-at-runtime.patch @@ -957,6 +958,9 @@ getent passwd systemd-journal-upload >/dev/null 2>&1 || useradd -r -l -g systemd %{_mandir}/man[1578]/systemd-nspawn.* %changelog +* Wed Feb 22 2017 Michal Sekletar - 231-14 +- Backport support for phys_port_name to net_id (#1425737) + * Tue Jan 17 2017 Zbigniew Jędrzejewski-Szmek - 231-13 - Backport mtime==0 fix (#1384150) - Add fake dependency on systemd-pam to systemd-devel to ensure systemd-pam