From e05170dd87f59bae61aa87823e0d8e8e9bd7a426 Mon Sep 17 00:00:00 2001 From: openeuler-basic Date: Thu, 5 Mar 2020 16:09:24 +0800 Subject: [PATCH] add 1603-udev-add-actions-while-rename-netif-failed.patch --- ...dd-actions-while-rename-netif-failed.patch | 79 +++++++++++++++++++ systemd.spec | 9 ++- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 1603-udev-add-actions-while-rename-netif-failed.patch diff --git a/1603-udev-add-actions-while-rename-netif-failed.patch b/1603-udev-add-actions-while-rename-netif-failed.patch new file mode 100644 index 0000000..6d82946 --- /dev/null +++ b/1603-udev-add-actions-while-rename-netif-failed.patch @@ -0,0 +1,79 @@ +From e21318d22359c7160ea7c7f4a610b28a30d48c84 Mon Sep 17 00:00:00 2001 +From: systemd team +Date: Tue, 7 Mar 2017 08:20:10 +0000 +Subject: [PATCH] udev-add-actions-while-rename-netif-failed +--- + src/udev/udev-event.c | 42 ++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 38 insertions(+), 4 deletions(-) + +diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c +index 8cfa2cd..46bbcb1 100644 +--- a/src/udev/udev-event.c ++++ b/src/udev/udev-event.c +@@ -788,6 +788,7 @@ static int rename_netif(UdevEvent *event) { + sd_device *dev = event->dev; + const char *oldname; + int ifindex, r; ++ char name[IFNAMSIZ]; + + if (!event->name) + return 0; /* No new name is requested. */ +@@ -808,10 +809,43 @@ static int rename_netif(UdevEvent *event) { + if (r < 0) + return log_device_error_errno(dev, r, "Failed to get ifindex: %m"); + +- r = rtnl_set_link_name(&event->rtnl, ifindex, event->name); ++ strscpy(name, IFNAMSIZ, event->name); ++ ++ r = rtnl_set_link_name(&event->rtnl, ifindex, name); + if (r < 0) +- return log_device_error_errno(dev, r, "Failed to rename network interface %i from '%s' to '%s': %m", +- ifindex, oldname, event->name); ++ { ++ int loop; ++ if (r != -EEXIST) { ++ return log_error_errno(r, "error changing net interface name '%s' to '%s': %m", oldname, name); ++ } ++ ++ snprintf(name, IFNAMSIZ, "rename%u", ifindex); ++ r = rtnl_set_link_name(&event->rtnl, ifindex, name); ++ if (r < 0) { ++ return log_error_errno(r, "error changing net interface name '%s' to '%s': %m", oldname, name); ++ } ++ ++ log_device_info(dev, "Network interface %i is renamed from '%s' to '%s'", ifindex, oldname, name); ++ ++ /* wait 90 seconds for our target to become available */ ++ loop = 90 * 20; ++ while (loop--) { ++ const struct timespec duration = { 0, 1000 * 1000 * 1000 / 20 }; ++ ++ r = rtnl_set_link_name(&event->rtnl, ifindex, event->name); ++ if (r == 0) { ++ log_device_info(dev, "Network interface %i is renamed from '%s' to '%s'", ifindex, name, event->name); ++ return 0; ++ } ++ ++ if (r != -EEXIST) { ++ return log_error_errno(r, "error changing net interface name '%s' to '%s': %m", name, event->name); ++ } ++ log_debug( "wait for netif '%s' to become free, loop=%i\n", ++ event->name, (90 * 20) - loop); ++ nanosleep(&duration, NULL); ++ } ++ } + + /* Set ID_RENAMING boolean property here, and drop it in the corresponding move uevent later. */ + r = device_add_property(dev, "ID_RENAMING", "1"); +@@ -822,7 +856,7 @@ static int rename_netif(UdevEvent *event) { + if (r < 0) + return log_device_warning_errno(dev, r, "Failed to update properties with new name '%s': %m", event->name); + +- log_device_debug(dev, "Network interface %i is renamed from '%s' to '%s'", ifindex, oldname, event->name); ++ log_device_info(dev, "Network interface %i is renamed from '%s' to '%s'", ifindex, oldname, event->name); + + return 1; + } +-- +2.19.1 + diff --git a/systemd.spec b/systemd.spec index 5ce76cd..b06805f 100644 --- a/systemd.spec +++ b/systemd.spec @@ -16,7 +16,7 @@ Name: systemd Url: https://www.freedesktop.org/wiki/Software/systemd Version: 243 -Release: 15 +Release: 16 License: MIT and LGPLv2+ and GPLv2+ Summary: System and Service Manager @@ -53,6 +53,7 @@ Patch0006: 0001-core-no-need-to-eat-up-error.patch Patch0007: 0001-core-create-or-remove-unit-bus-name-slots-always-together.patch Patch0008: 0001-core-drop-initial-ListNames-bus-call-from-PID1.patch Patch0009: 1605-update-rtc-with-system-clock-when-shutdown.patch +Patch0010: 1603-udev-add-actions-while-rename-netif-failed.patch #openEuler Patch9002: 1509-fix-journal-file-descriptors-leak-problems.patch @@ -1456,6 +1457,12 @@ fi %exclude /usr/share/man/man3/* %changelog +* Thu Mar 5 2020 openEuler Buildteam - 243-16 +- Type:enhancement +- ID:NA +- SUG:NA +- DESC:add 1603-udev-add-actions-while-rename-netif-failed.patch + * Sat Feb 29 2020 openEuler Buildteam - 243-15 - Type:enhancement - ID:NA -- Gitee