update code
This commit is contained in:
parent
10a9d53236
commit
9d65145baf
@ -0,0 +1,124 @@
|
||||
From 85bfad96a5562a5b57575a7eed35e63a63ae7288 Mon Sep 17 00:00:00 2001
|
||||
From: Minhua Chen <chenminhua1@huawei.com>
|
||||
Date: Fri, 18 Oct 2019 11:29:00 +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 <chenminhua1@huawei.com>
|
||||
---
|
||||
ip/ipnetns.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 67 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
|
||||
index 7e6cfe8..14c3b19 100644
|
||||
--- a/ip/ipnetns.c
|
||||
+++ b/ip/ipnetns.c
|
||||
@@ -24,6 +24,63 @@
|
||||
#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, "Usage: ip netns list\n");
|
||||
@@ -483,10 +540,10 @@ 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))) {
|
||||
@@ -495,8 +552,8 @@ 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) &&
|
||||
@@ -519,7 +576,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",
|
||||
--
|
||||
2.19.1
|
||||
|
||||
27
bugfix-iproute-support-assume-default-route.patch
Normal file
27
bugfix-iproute-support-assume-default-route.patch
Normal file
@ -0,0 +1,27 @@
|
||||
From 1d9bf6b69e4bdeecf23d00a1d083912ad479269e Mon Sep 17 00:00:00 2001
|
||||
From: Li Shang <shangli1@huawei.com>
|
||||
Date: Tue, 13 Nov 2018 22:43:48 +0800
|
||||
Subject: [PATCH] huawei bugfix support ip route add vai
|
||||
|
||||
---
|
||||
ip/iproute.c | 3 ---
|
||||
1 file changed, 3 deletions(-)
|
||||
|
||||
diff --git a/ip/iproute.c b/ip/iproute.c
|
||||
index f252df4..2560b27 100644
|
||||
--- a/ip/iproute.c
|
||||
+++ b/ip/iproute.c
|
||||
@@ -1467,9 +1467,6 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
|
||||
argc--; argv++;
|
||||
}
|
||||
|
||||
- if (!dst_ok)
|
||||
- usage();
|
||||
-
|
||||
if (d) {
|
||||
int idx = ll_name_to_index(d);
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
|
||||
41
bugfix-iproute2-3.10.0-fix-maddr-show.patch
Normal file
41
bugfix-iproute2-3.10.0-fix-maddr-show.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From c246386b595a2e2f88c5cf5e293a23824c2ba2c6 Mon Sep 17 00:00:00 2001
|
||||
From: Feilong Lin <linfeilong@huawei.com>
|
||||
Date: Tue, 16 Oct 2018 18:15:34 +0800
|
||||
Subject: [PATCH] fix maddr show
|
||||
|
||||
---
|
||||
ip/ipmaddr.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c
|
||||
index 4f726fd..1434093 100644
|
||||
--- a/ip/ipmaddr.c
|
||||
+++ b/ip/ipmaddr.c
|
||||
@@ -137,9 +137,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] == ':')
|
||||
@@ -147,6 +149,11 @@ 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
|
||||
|
||||
|
||||
14
iproute.spec
14
iproute.spec
@ -1,6 +1,6 @@
|
||||
Name: iproute
|
||||
Version: 5.2.0
|
||||
Release: 1
|
||||
Release: 2
|
||||
Summary: Linux network configuration utilities
|
||||
License: GPLv2+ and Public Domain
|
||||
URL: https://kernel.org/pub/linux/utils/net/iproute2/
|
||||
@ -9,7 +9,9 @@ Source0: https://mirrors.edge.kernel.org/pub/linux/utils/net/iproute2/iproute2-%
|
||||
BuildRequires: gcc bison elfutils-libelf-devel flex iptables-devel libcap-devel
|
||||
BuildRequires: libdb-devel libmnl-devel libselinux-devel pkgconfig git
|
||||
|
||||
#Pacth1-Patch9 comes from fedora
|
||||
Patch9001: bugfix-iproute2-3.10.0-fix-maddr-show.patch
|
||||
Patch9002: bugfix-iproute-support-assume-default-route.patch
|
||||
|
||||
Patch0001: 0001-Revert-ip6tunnel-fix-ip-6-show-change-dev-name-cmds.patch
|
||||
Patch0002: 0002-ip-tunnel-warn-when-changing-IPv6-tunnel-without-tun.patch
|
||||
Patch0003: 0003-ip-route-fix-json-formatting-for-metrics.patch
|
||||
@ -19,6 +21,8 @@ Patch0006: 0006-devlink-Change-devlink-health-dump-show-command-to-d.patch
|
||||
Patch0007: 0007-devlink-Fix-binary-values-print.patch
|
||||
Patch0008: 0008-devlink-Remove-enclosing-array-brackets-binary-print.patch
|
||||
Patch0009: 0009-json-fix-backslash-escape-typo-in-jsonw_puts.patch
|
||||
|
||||
Patch9003: bugfix-1001-iproute-change-proc-to-ipnetnsproc-which-is-private.patch
|
||||
|
||||
Provides: /sbin/ip iproute-tc tc
|
||||
Obsoletes: iproute-tc
|
||||
@ -82,5 +86,11 @@ install -m 0644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
|
||||
%{_mandir}/*
|
||||
|
||||
%changelog
|
||||
* Fri Oct 18 2019 openEuler Buildteam <buildteam@openeuler.org> - 5.2.0-2
|
||||
- Type:bugfix
|
||||
- Id:NA
|
||||
- SUG:NA
|
||||
- DESC:add the bugfix about iproute
|
||||
|
||||
* Thu Sep 19 2019 openEuler Buildteam <buildteam@openeuler.org> - 5.2.0-1
|
||||
- Package init
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user