fix ip netns attach
(cherry picked from commit 7482f7db673f4fb2c1ce385ea0aa76992ff79252)
This commit is contained in:
parent
9087dae875
commit
c1d6edac4c
@ -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: 5.15.0
|
||||
Epoch: 1
|
||||
Release: 12
|
||||
Release: 13
|
||||
Summary: Linux network configuration utilities
|
||||
License: GPLv2+ and Public Domain
|
||||
URL: https://kernel.org/pub/linux/utils/net/iproute2/
|
||||
@ -107,6 +107,12 @@ install -m 0644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
|
||||
%{_mandir}/*
|
||||
|
||||
%changelog
|
||||
* Thu Mar 02 2023 jiangheng <jiangheng14@huawei.com> - 1:5.15.0-13
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:fix ip netns attach failed
|
||||
|
||||
* Fri Feb 17 2023 gaoxingwang <gaoxingwang1@huawei.com> - 1:5.15.0-12
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user