fix ip netns attach failed
(cherry picked from commit c38c10dca3305d043daac1b60f21974355ca7a63)
This commit is contained in:
parent
6050bf780f
commit
6340f84b9d
@ -116,20 +116,18 @@ index fc58a04..fedc3db 100644
|
||||
netns = open(net_path, O_RDONLY);
|
||||
if (netns < 0) {
|
||||
fprintf(stderr, "Cannot open network namespace: %s\n",
|
||||
@@ -917,9 +972,11 @@ static int netns_add(int argc, char **argv, bool create)
|
||||
@@ -911,9 +965,9 @@ static int netns_add(int argc, char **argv, bool create)
|
||||
goto out_delete;
|
||||
}
|
||||
|
||||
- strcpy(proc_path, "/proc/self/ns/net");
|
||||
+ snprintf(proc_path, sizeof(proc_path), "/%s/self/ns/net", get_proc_string());
|
||||
} else {
|
||||
- snprintf(proc_path, sizeof(proc_path), "/proc/%d/ns/net", pid);
|
||||
+ snprintf(proc_path, sizeof(proc_path), "/%s/%d/ns/net", get_proc_string(), pid);
|
||||
}
|
||||
|
||||
/* Bind the netns last so I can watch for it */
|
||||
- if (mount(proc_path, netns_path, "none", MS_BIND, NULL) < 0) {
|
||||
+ char pid_net_path[MAXPATHLEN];
|
||||
+ snprintf(pid_net_path, sizeof(pid_net_path), "%s/self/ns/net", get_proc_string());
|
||||
+ if (mount(pid_net_path, netns_path, "none", MS_BIND, NULL) < 0) {
|
||||
fprintf(stderr, "Bind %s -> %s failed: %s\n",
|
||||
- proc_path, netns_path, strerror(errno));
|
||||
+ pid_net_path, netns_path, strerror(errno));
|
||||
goto out_delete;
|
||||
}
|
||||
netns_restore();
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
Name: iproute
|
||||
Version: 6.1.0
|
||||
Epoch: 1
|
||||
Release: 5
|
||||
Release: 6
|
||||
Summary: Linux network configuration utilities
|
||||
License: GPLv2+ and Public Domain
|
||||
URL: https://kernel.org/pub/linux/utils/net/iproute2/
|
||||
@ -89,6 +89,12 @@ install -m 0644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
|
||||
%{_mandir}/*
|
||||
|
||||
%changelog
|
||||
* Sat Feb 25 2023 jiangheng <jiangheng14@huawei.com> - 1:6.1.0-6
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:fix ip netns attach failed
|
||||
|
||||
* Sat Feb 18 2023 gaoxingwang <gaoxingwang1@huawei.com> - 1:6.1.0-5
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user