1 Star 0 Fork 43

zhongtao/src-iSulad

forked from src-openEuler/iSulad 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0121-get-realpath-before-ns-mountpoint-verification.patch 3.09 KB
一键复制 编辑 原始数据 按行查看 历史
From 6357caaf6bcf413b58e587fe3df5c508275713ee Mon Sep 17 00:00:00 2001
From: zhongtao <[email protected]>
Date: Thu, 15 Aug 2024 19:21:19 +1400
Subject: [PATCH 120/121] get realpath before ns mountpoint verification
Signed-off-by: zhongtao <[email protected]>
---
.../entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc | 9 +++++++--
.../entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc | 9 +++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc b/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc
index 77faf48a..3ece885f 100644
--- a/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc
+++ b/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc
@@ -424,6 +424,7 @@ cleanup_sandbox:
void PodSandboxManagerService::ClearCniNetwork(const std::shared_ptr<sandbox::Sandbox> sandbox, Errors &error)
{
+ char real_path[PATH_MAX] = { 0 };
std::string networkMode = sandbox->GetNetMode();
if (!namespace_is_cni(networkMode.c_str()) || !sandbox->GetNetworkReady()) {
return;
@@ -435,10 +436,14 @@ void PodSandboxManagerService::ClearCniNetwork(const std::shared_ptr<sandbox::Sa
return;
}
+ if (realpath(sandboxKey.c_str(), real_path) == NULL) {
+ ERROR("Failed to get %s realpath", sandboxKey.c_str());
+ }
+
// If the network namespace is not mounted, the network has been cleaned up
// and there is no need to call the cni plugin.
- if (!util_detect_mounted(sandboxKey.c_str())) {
- WARN("Network namespace %s not exist", sandboxKey.c_str());
+ if (strlen(real_path) != 0 && !util_detect_mounted(real_path)) {
+ ERROR("Network namespace %s not exist", real_path);
return;
}
diff --git a/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc b/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc
index 5590827e..1c343cda 100644
--- a/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc
+++ b/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc
@@ -826,6 +826,7 @@ auto PodSandboxManagerService::ClearCniNetwork(const std::string &realSandboxID,
/*error*/) -> int
{
Errors networkErr;
+ char real_path[PATH_MAX] = { 0 };
bool ready = GetNetworkReady(realSandboxID, networkErr);
if (hostNetwork || (!ready && networkErr.Empty())) {
@@ -848,10 +849,14 @@ auto PodSandboxManagerService::ClearCniNetwork(const std::string &realSandboxID,
goto cleanup;
}
+ if (realpath(netnsPath.c_str(), real_path) == NULL) {
+ ERROR("Failed to get %s realpath", netnsPath.c_str());
+ }
+
// If the network namespace is not mounted, the network has been cleaned up
// and there is no need to call the cni plugin.
- if (!util_detect_mounted(netnsPath.c_str())) {
- WARN("Network namespace %s not exist", netnsPath.c_str());
+ if (strlen(real_path) != 0 && !util_detect_mounted(real_path)) {
+ ERROR("Network namespace %s not exist", real_path);
goto cleanup;
}
--
2.25.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/taotao-sauce/src-iSulad.git
[email protected]:taotao-sauce/src-iSulad.git
taotao-sauce
src-iSulad
src-iSulad
master

搜索帮助