diff --git a/bugfix-iproute2-3.10.0-fix-maddr-show.patch b/bugfix-iproute2-3.10.0-fix-maddr-show.patch new file mode 100644 index 0000000000000000000000000000000000000000..0c6d51dbb101c350a071340505419a1bf704aa1d --- /dev/null +++ b/bugfix-iproute2-3.10.0-fix-maddr-show.patch @@ -0,0 +1,39 @@ +From 9b190596f7d26ad640bd3e56b65c3fedf80d3963 Mon Sep 17 00:00:00 2001 +From: Feilong Lin +Date: Mon, 20 Jan 2020 23:21:25 +0800 +Subject: [PATCH] fix maddr show + +--- + ip/ipmaddr.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c +index 3400e05..e37929e 100644 +--- a/ip/ipmaddr.c ++++ b/ip/ipmaddr.c +@@ -138,9 +138,11 @@ static void read_igmp(struct ma_info **result_p) + while (fgets(buf, sizeof(buf), fp)) { + struct ma_info *ma; + ++ int index; + if (buf[0] != '\t') { + size_t len; + ++ memset(&m.name, 0, sizeof(m.name)); + sscanf(buf, "%d%s", &m.index, m.name); + len = strlen(m.name); + if (m.name[len - 1] == ':') +@@ -148,6 +150,10 @@ static void read_igmp(struct ma_info **result_p) + continue; + } + ++ index = strlen(m.name) - 1; ++ if (index > 0 && m.name[index] == ':') { ++ m.name[index] = 0; ++ } + if (filter.dev && strcmp(filter.dev, m.name)) + continue; + +-- +1.8.3.1 + diff --git a/bugfix-iproute2-change-proc-to-ipnetnsproc-which-is-private.patch b/bugfix-iproute2-change-proc-to-ipnetnsproc-which-is-private.patch new file mode 100644 index 0000000000000000000000000000000000000000..bcd9ce7485d768a71fbb01b47af7c4ac2a7383c4 --- /dev/null +++ b/bugfix-iproute2-change-proc-to-ipnetnsproc-which-is-private.patch @@ -0,0 +1,135 @@ +From 19ed63e8ed3c5dece47c83949b61815f661c9036 Mon Sep 17 00:00:00 2001 +From: Minhua Chen +Date: Tue, 21 Jan 2020 00:19:13 +0800 +Subject: [PATCH] iproute2: change proc to ipnetnsproc which is private system +proc is mounted shared, if use this, it will cause the list size of mnt_share +become too large to loop, and will casue kernel softlockup. + +so we need a private mounted proc which is /ipnetnsproc to avoid +the large list in kernel. + +use /etc/iproute_private.conf to switch on or off this patch. +if file exist and file content equals use_ipnetnsproc=1 then +switch on, or else switch off. + +Signed-off-by: Minhua Chen +--- + ip/ipnetns.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++------- + 1 file changed, 64 insertions(+), 8 deletions(-) + +diff --git a/ip/ipnetns.c b/ip/ipnetns.c +index fc58a04..fedc3db 100644 +--- a/ip/ipnetns.c ++++ b/ip/ipnetns.c +@@ -24,6 +24,62 @@ + #include "namespace.h" + #include "json_print.h" + ++const char *conf_file = "/etc/iproute2/iproute_private.conf"; ++static int conf_file_parsed = 0; ++static int should_use_ipnetnsproc = 0; ++ ++static void parse_config() ++{ ++ FILE *fp = NULL; ++ char buffer[256] = {0}; ++ char *str = NULL; ++ char *p = NULL; ++ ++ fp = fopen(conf_file, "r"); ++ if(fp){ ++ while (fgets(buffer, sizeof(buffer), fp)) { ++ str = buffer; ++ /* skip the space */ ++ while (isspace(*str)) ++ str++; ++ /* skip the comment line */ ++ if (strncmp(str, "#", 1) == 0) ++ continue; ++ /* skip line feed */ ++ if((p = strchr(str, '\n')) != NULL) ++ *p = '\0'; ++ if (strstr(str, "use_ipnetnsproc") != NULL && (p = strstr(str, "=")) != NULL){ ++ str = p + 1; ++ /* skip the space */ ++ while (isspace(*str)) ++ str++; ++ if (strcmp(str, "1") == 0){ ++ should_use_ipnetnsproc = 1; ++ } ++ break; ++ } ++ } ++ fclose(fp); ++ fp = NULL; ++ } ++ conf_file_parsed = 1; ++} ++static int get_should_use_ipnetnsproc() ++{ ++ if (!conf_file_parsed) ++ parse_config(); ++ return should_use_ipnetnsproc; ++} ++ ++static char* get_proc_string() ++{ ++ if(get_should_use_ipnetnsproc()){ ++ return "/ipnetnsproc"; ++ } else { ++ return "/proc"; ++ } ++} ++ + static int usage(void) + { + fprintf(stderr, +@@ -589,10 +645,9 @@ static int netns_pids(int argc, char **argv) + strerror(errno)); + return -1; + } +- dir = opendir("/proc/"); ++ dir = opendir(get_proc_string()); + if (!dir) { +- fprintf(stderr, "Open of /proc failed: %s\n", +- strerror(errno)); ++ fprintf(stderr, "Open of %s failed: %s\n", get_proc_string(), strerror(errno)); + return -1; + } + while ((entry = readdir(dir))) { +@@ -601,8 +656,7 @@ static int netns_pids(int argc, char **argv) + + if (!is_pid(entry->d_name)) + continue; +- snprintf(pid_net_path, sizeof(pid_net_path), "/proc/%s/ns/net", +- entry->d_name); ++ snprintf(pid_net_path, sizeof(pid_net_path), "/%s/%s/ns/net", get_proc_string(), entry->d_name); + if (stat(pid_net_path, &st) != 0) + continue; + if ((st.st_dev == netst.st_dev) && +@@ -625,7 +679,7 @@ int netns_identify_pid(const char *pidstr, char *name, int len) + + name[0] = '\0'; + +- snprintf(net_path, sizeof(net_path), "/proc/%s/ns/net", pidstr); ++ snprintf(net_path, sizeof(net_path), "/%s/%s/ns/net", get_proc_string(), pidstr); + netns = open(net_path, O_RDONLY); + if (netns < 0) { + fprintf(stderr, "Cannot open network namespace: %s\n", +@@ -856,9 +910,11 @@ static int netns_add(int argc, char **argv, bool create) + } + + /* 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 + diff --git a/iproute.spec b/iproute.spec index f7265e530ac02b63952df876e209a3f53d76fc31..ee1dabae2fe4e0401459f0510b5c7e1684d594fb 100644 --- a/iproute.spec +++ b/iproute.spec @@ -1,11 +1,14 @@ Name: iproute Version: 5.4.0 -Release: 1 +Release: 2 Summary: Linux network configuration utilities License: GPLv2+ and Public Domain URL: https://kernel.org/pub/linux/utils/net/iproute2/ Source0: https://mirrors.edge.kernel.org/pub/linux/utils/net/iproute2/iproute2-%{version}.tar.xz +Patch1: bugfix-iproute2-3.10.0-fix-maddr-show.patch +Patch2: bugfix-iproute2-change-proc-to-ipnetnsproc-which-is-private.patch + BuildRequires: gcc bison elfutils-libelf-devel flex iptables-devel libcap-devel BuildRequires: libdb-devel libmnl-devel libselinux-devel pkgconfig git @@ -70,6 +73,9 @@ install -m 0644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a %{_mandir}/* %changelog +* Mon Jan 20 2020 openEuler Buildteam - 5.4.0-2 +- fix maddr show and change proc to ipnetnsproc + * Tue Jan 14 2020 openEuler Buildteam - 5.4.0-1 - update to 5.4.0