1 Star 0 Fork 101

YukariChiba/systemd

forked from src-openEuler/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-udev-do-not-try-to-rename-interface-if-it-is-already.patch 1.64 KB
一键复制 编辑 原始数据 按行查看 历史
From 214ea3a26e9cc5dda8530a45a71b052e75a250a4 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Sun, 24 Oct 2021 20:43:34 +0900
Subject: [PATCH] udev: do not try to rename interface if it is already up
See dev_change_name() in kernel's net/core/dev.c.
Fixes #21105.
(cherry picked from commit 6681eb021a0b56ef0dc849e3b358a515ece16482)
Conflict:NA
Reference:https://github.com/systemd/systemd/commit/214ea3a26e9cc5dda8530a45a71b052e75a250a4
---
src/udev/udev-event.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index b28089be71..9854270b27 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -828,6 +828,7 @@ int udev_event_spawn(UdevEvent *event,
static int rename_netif(UdevEvent *event) {
sd_device *dev = event->dev;
const char *oldname;
+ unsigned flags;
int ifindex, r;
if (!event->name)
@@ -855,6 +856,16 @@ static int rename_netif(UdevEvent *event) {
return 0;
}
+ r = rtnl_get_link_info(&event->rtnl, ifindex, NULL, &flags);
+ if (r < 0)
+ return log_device_warning_errno(dev, r, "Failed to get link flags: %m");
+
+ if (FLAGS_SET(flags, IFF_UP)) {
+ log_device_info(dev, "Network interface '%s' is already up, refusing to rename to '%s'.",
+ oldname, event->name);
+ return 0;
+ }
+
/* Set ID_RENAMING boolean property here, and drop it in the corresponding move uevent later. */
r = device_add_property(dev, "ID_RENAMING", "1");
if (r < 0)
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/YukariChiba/systemd.git
git@gitee.com:YukariChiba/systemd.git
YukariChiba
systemd
systemd
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385