update some patches from community

This commit is contained in:
jiangheng 2021-06-26 16:10:37 +08:00
parent 016cda09d2
commit f63465810c
9 changed files with 561 additions and 2 deletions

View File

@ -0,0 +1,42 @@
From 6b8fa2ea2d5024345277240acc2252c049e561b3 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Wed, 14 Apr 2021 00:48:37 +0200
Subject: [PATCH] devlink: always check strslashrsplit() return value
strslashrsplit() return value is not checked in __dl_argv_handle(),
despite the fact that it can return EINVAL.
This commit fix it and make __dl_argv_handle() return error if
strslashrsplit() return an error code.
Fixes: 2f85a9c53587 ("devlink: allow to parse both devlink and port handle in the same time")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Conflict: NA
Reference: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=6b8fa2ea2d5024345277240acc2252c049e561b3
---
devlink/devlink.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index c6e85ff9..faa87b3d 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -965,7 +965,13 @@ static int strtobool(const char *str, bool *p_val)
static int __dl_argv_handle(char *str, char **p_bus_name, char **p_dev_name)
{
- strslashrsplit(str, p_bus_name, p_dev_name);
+ int err;
+
+ err = strslashrsplit(str, p_bus_name, p_dev_name);
+ if (err) {
+ pr_err("Devlink identification (\"bus_name/dev_name\") \"%s\" is invalid\n", str);
+ return err;
+ }
return 0;
}
--
2.23.0

View File

@ -0,0 +1,82 @@
From e705b19d489f769228902e100b4f375c03becfbb Mon Sep 17 00:00:00 2001
From: Tony Ambardar <tony.ambardar@gmail.com>
Date: Tue, 20 Apr 2021 01:26:36 -0700
Subject: [PATCH] ip: drop 2-char command assumption
The 'ip' utility hardcodes the assumption of being a 2-char command, where
any follow-on characters are passed as an argument:
$ ./ip-full help
Object "-full" is unknown, try "ip help".
This confusing behaviour isn't seen with 'tc' for example, and was added in
a 2005 commit without documentation. It was noticed during testing of 'ip'
variants built/packaged with different feature sets (e.g. w/o BPF support).
Mitigate the problem by redoing the command without the 2-char assumption
if the follow-on characters fail to parse as a valid command.
Fixes: 351efcde4e62 ("Update header files to 2.6.14")
Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
Conflict: batch function has refactor
Reference: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=e705b19d489f769228902e100b4f375c03becfbb
---
ip/ip.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/ip/ip.c b/ip/ip.c
index 90392c2..90c04dc 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -107,7 +107,7 @@ static const struct cmd {
{ 0 }
};
-static int do_cmd(const char *argv0, int argc, char **argv)
+static int do_cmd(const char *argv0, int argc, char **argv, bool final)
{
const struct cmd *c;
@@ -116,7 +116,8 @@ static int do_cmd(const char *argv0, int argc, char **argv)
return -(c->func(argc-1, argv+1));
}
- fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv0);
+ if (final)
+ fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv0);
return EXIT_FAILURE;
}
@@ -154,7 +155,7 @@ static int batch(const char *name)
if (largc == 0)
continue; /* blank line */
- if (do_cmd(largv[0], largc, largv)) {
+ if (do_cmd(largv[0], largc, largv, true)) {
fprintf(stderr, "Command failed %s:%d\n",
name, cmdlineno);
ret = EXIT_FAILURE;
@@ -315,11 +316,15 @@ int main(int argc, char **argv)
rtnl_set_strict_dump(&rth);
- if (strlen(basename) > 2)
- return do_cmd(basename+2, argc, argv);
+ if (strlen(basename) > 2) {
+ int ret = do_cmd(basename+2, argc, argv, false);
+ if (ret != EXIT_FAILURE)
+ return ret;
+ }
+
if (argc > 1)
- return do_cmd(argv[1], argc-1, argv+1);
+ return do_cmd(argv[1], argc-1, argv+1, true);
rtnl_close(&rth);
usage();
--
2.23.0

View File

@ -0,0 +1,138 @@
From 38ef5bb7b4a7e8b191f4087c140a07a0779fa903 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Mon, 19 Apr 2021 15:37:25 +0200
Subject: [PATCH] ip: netns: fix missing netns close on some error paths
In functions netns_pids() and netns_identify_pid(), the netns file is
not closed on some error paths.
Fix this using a conditional close and a single return point on both
functions.
Fixes: 44b563269ea1 ("ip-nexthop: support flush by id")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Conflict: The function reconstructs
Reference: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=38ef5bb7b4a7e8b191f4087c140a07a0779fa903
---
ip/ipnetns.c | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index cf9a471..4b88810 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -627,18 +627,18 @@ static int netns_pids(int argc, char **argv)
{
const char *name;
char net_path[PATH_MAX];
- int netns;
+ int netns = -1, ret = -1;
struct stat netst;
DIR *dir;
struct dirent *entry;
if (argc < 1) {
fprintf(stderr, "No netns name specified\n");
- return -1;
+ goto out;
}
if (argc > 1) {
fprintf(stderr, "extra arguments specified\n");
- return -1;
+ goto out;
}
name = argv[0];
@@ -647,17 +647,17 @@ static int netns_pids(int argc, char **argv)
if (netns < 0) {
fprintf(stderr, "Cannot open network namespace: %s\n",
strerror(errno));
- return -1;
+ goto out;
}
if (fstat(netns, &netst) < 0) {
fprintf(stderr, "Stat of netns failed: %s\n",
strerror(errno));
- return -1;
+ goto out;
}
dir = opendir(get_proc_string());
if (!dir) {
fprintf(stderr, "Open of %s failed: %s\n", get_proc_string(), strerror(errno));
- return -1;
+ goto out;
}
while ((entry = readdir(dir))) {
char pid_net_path[PATH_MAX];
@@ -673,15 +673,18 @@ static int netns_pids(int argc, char **argv)
printf("%s\n", entry->d_name);
}
}
+ ret = 0;
closedir(dir);
- return 0;
-
+out:
+ if (netns >= 0)
+ close(netns);
+ return ret;
}
int netns_identify_pid(const char *pidstr, char *name, int len)
{
char net_path[PATH_MAX];
- int netns;
+ int netns = -1, ret = -1;
struct stat netst;
DIR *dir;
struct dirent *entry;
@@ -693,22 +696,24 @@ int netns_identify_pid(const char *pidstr, char *name, int len)
if (netns < 0) {
fprintf(stderr, "Cannot open network namespace: %s\n",
strerror(errno));
- return -1;
+ goto out;
}
if (fstat(netns, &netst) < 0) {
fprintf(stderr, "Stat of netns failed: %s\n",
strerror(errno));
- return -1;
+ goto out;
}
dir = opendir(NETNS_RUN_DIR);
if (!dir) {
/* Succeed treat a missing directory as an empty directory */
- if (errno == ENOENT)
- return 0;
+ if (errno == ENOENT) {
+ ret = 0;
+ goto out;
+ }
fprintf(stderr, "Failed to open directory %s:%s\n",
NETNS_RUN_DIR, strerror(errno));
- return -1;
+ goto out;
}
while ((entry = readdir(dir))) {
@@ -731,9 +736,12 @@ int netns_identify_pid(const char *pidstr, char *name, int len)
strlcpy(name, entry->d_name, len);
}
}
+ ret = 0;
closedir(dir);
- return 0;
-
+out:
+ if (netns >= 0)
+ close(netns);
+ return ret;
}
static int netns_identify(int argc, char **argv)
--
2.23.0

View File

@ -0,0 +1,103 @@
From e1ad689545a0a2a798869cb95de7dbe4b138bdae Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Mon, 19 Apr 2021 15:49:57 +0200
Subject: [PATCH] lib: bpf_legacy: fix missing socket close when connect()
fails
In functions bpf_{send,recv}_map_fds(), when connect fails after a
socket is successfully opened, we return with error missing a close on
the socket.
Fix this closing the socket if opened and using a single return point
for both the functions.
Fixes: 6256f8c9e45f ("tc, bpf: finalize eBPF support for cls and act front-end")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Conflict: rename bpf_legacy.c
Reference: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=e1ad689545a0a2a798869cb95de7dbe4b138bdae
---
lib/bpf.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/lib/bpf.c b/lib/bpf.c
index 23cb0d9..397803f 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -3100,13 +3100,13 @@ int bpf_send_map_fds(const char *path, const char *obj)
.st = &ctx->stat,
.obj = obj,
};
- int fd, ret;
+ int fd, ret = -1;
fd = socket(AF_UNIX, SOCK_DGRAM, 0);
if (fd < 0) {
fprintf(stderr, "Cannot open socket: %s\n",
strerror(errno));
- return -1;
+ goto out;
}
strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
@@ -3115,7 +3115,7 @@ int bpf_send_map_fds(const char *path, const char *obj)
if (ret < 0) {
fprintf(stderr, "Cannot connect to %s: %s\n",
path, strerror(errno));
- return -1;
+ goto out;
}
ret = bpf_map_set_send(fd, &addr, sizeof(addr), &bpf_aux,
@@ -3125,7 +3125,9 @@ int bpf_send_map_fds(const char *path, const char *obj)
path, strerror(errno));
bpf_maps_teardown(ctx);
- close(fd);
+out:
+ if (fd >= 0)
+ close(fd);
return ret;
}
@@ -3133,13 +3135,13 @@ int bpf_recv_map_fds(const char *path, int *fds, struct bpf_map_aux *aux,
unsigned int entries)
{
struct sockaddr_un addr = { .sun_family = AF_UNIX };
- int fd, ret;
+ int fd, ret = -1;
fd = socket(AF_UNIX, SOCK_DGRAM, 0);
if (fd < 0) {
fprintf(stderr, "Cannot open socket: %s\n",
strerror(errno));
- return -1;
+ goto out;
}
strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
@@ -3148,7 +3150,7 @@ int bpf_recv_map_fds(const char *path, int *fds, struct bpf_map_aux *aux,
if (ret < 0) {
fprintf(stderr, "Cannot bind to socket: %s\n",
strerror(errno));
- return -1;
+ goto out;
}
ret = bpf_map_set_recv(fd, fds, aux, entries);
@@ -3157,7 +3159,10 @@ int bpf_recv_map_fds(const char *path, int *fds, struct bpf_map_aux *aux,
path, strerror(errno));
unlink(addr.sun_path);
- close(fd);
+out:
+ if (fd >= 0) {
+ close(fd);
+ }
return ret;
}
#endif /* HAVE_ELF */
--
2.23.0

View File

@ -0,0 +1,37 @@
From 1de363b1800c371037ff2b2a6c1004627e58f68e Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Mon, 22 Feb 2021 19:14:31 +0100
Subject: [PATCH] lib/fs: avoid double call to mkdir on make_path()
make_path() function calls mkdir two times in a row. The first one it
stores mkdir return code, and then it calls it again to check for errno.
This seems unnecessary, as we can use the return code from the first
call and check for errno if not 0.
Fixes: ac3415f5c1b1d ("lib/fs: Fix and simplify make_path()")
Acked-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Conflict: NA
Reference: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=1de363b1800c371037ff2b2a6c1004627e58f68e
---
lib/fs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/fs.c b/lib/fs.c
index 4b90a704..2ae506ec 100644
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -253,7 +253,7 @@ int make_path(const char *path, mode_t mode)
*delim = '\0';
rc = mkdir(dir, mode);
- if (mkdir(dir, mode) != 0 && errno != EEXIST) {
+ if (rc && errno != EEXIST) {
fprintf(stderr, "mkdir failed for %s: %s\n",
dir, strerror(errno));
goto out;
--
2.23.0

View File

@ -0,0 +1,74 @@
From 6a2c51da993ab9f8b385ee2bf13814f8e8000ce5 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Wed, 14 Apr 2021 00:50:45 +0200
Subject: [PATCH] nexthop: fix memory leak in add_nh_group_attr()
grps is dinamically allocated with a calloc, and not freed in a return
path in the for cycle. This commit fix it.
While at it, make the function use a single return point.
Fixes: 63df8e8543b0 ("Add support for nexthop objects")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Conflict: NA
Reference: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=6a2c51da993ab9f8b385ee2bf13814f8e8000ce5
---
ip/ipnexthop.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c
index 20cde586..f0658a9c 100644
--- a/ip/ipnexthop.c
+++ b/ip/ipnexthop.c
@@ -277,8 +277,9 @@ int print_nexthop(struct nlmsghdr *n, void *arg)
static int add_nh_group_attr(struct nlmsghdr *n, int maxlen, char *argv)
{
- struct nexthop_grp *grps;
+ struct nexthop_grp *grps = NULL;
int count = 0, i;
+ int err = -1;
char *sep, *wsep;
if (*argv != '\0')
@@ -292,11 +293,11 @@ static int add_nh_group_attr(struct nlmsghdr *n, int maxlen, char *argv)
}
if (count == 0)
- return -1;
+ goto out;
grps = calloc(count, sizeof(*grps));
if (!grps)
- return -1;
+ goto out;
for (i = 0; i < count; ++i) {
sep = strchr(argv, '/');
@@ -308,7 +309,7 @@ static int add_nh_group_attr(struct nlmsghdr *n, int maxlen, char *argv)
*wsep = '\0';
if (get_unsigned(&grps[i].id, argv, 0))
- return -1;
+ goto out;
if (wsep) {
unsigned int w;
@@ -324,7 +325,12 @@ static int add_nh_group_attr(struct nlmsghdr *n, int maxlen, char *argv)
argv = sep + 1;
}
- return addattr_l(n, maxlen, NHA_GROUP, grps, count * sizeof(*grps));
+ err = addattr_l(n, maxlen, NHA_GROUP, grps, count * sizeof(*grps));
+out:
+ if (grps != NULL) {
+ free(grps);
+ }
+ return err;
}
static int ipnh_modify(int cmd, unsigned int flags, int argc, char **argv)
--
2.23.0

View File

@ -0,0 +1,35 @@
From c8216fabe8d9df3db38283cca1b6caeca033f9b9 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Sun, 18 Apr 2021 14:56:30 +0200
Subject: [PATCH] rdma: stat: fix return code
libmnl defines MNL_CB_OK as 1 and MNL_CB_ERROR as -1. rdma uses these
return codes, and stat_qp_show_parse_cb() should do the same.
Fixes: 16ce4d23661a ("rdma: stat: initialize ret in stat_qp_show_parse_cb()")
Reported-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Acked-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Conflict: ret value is random
Reference: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=c8216fabe8d9df3db38283cca1b6caeca033f9b9
---
rdma/stat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rdma/stat.c b/rdma/stat.c
index 3abedae7..8edf7bf1 100644
--- a/rdma/stat.c
+++ b/rdma/stat.c
@@ -307,7 +307,7 @@ static int stat_qp_show_parse_cb(const struct nlmsghdr *nlh, void *data)
struct rd *rd = data;
const char *name;
uint32_t idx;
- int ret;
+ int ret = MNL_CB_OK;
mnl_attr_parse(nlh, 0, rd_attr_cb, tb);
if (!tb[RDMA_NLDEV_ATTR_DEV_INDEX] || !tb[RDMA_NLDEV_ATTR_DEV_NAME] ||
--
2.23.0

View File

@ -0,0 +1,34 @@
From 932fe3453f39503b5689912d7e0b01ac2b03e7a0 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Mon, 19 Apr 2021 15:36:57 +0200
Subject: [PATCH] tc: e_bpf: fix memory leak in parse_bpf()
envp_run is dinamically allocated with a malloc, and not freed in the
out: return path. This commit fix it.
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Conflict: NA
Reference: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit?id=932fe3453f39503b5689912d7e0b01ac2b03e7a0
---
tc/e_bpf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tc/e_bpf.c b/tc/e_bpf.c
index a48393b7..517ee5b3 100644
--- a/tc/e_bpf.c
+++ b/tc/e_bpf.c
@@ -159,7 +159,9 @@ static int parse_bpf(struct exec_util *eu, int argc, char **argv)
envp_run[env_num - 1] = NULL;
out:
- return execvpe(argv_run[0], argv_run, envp_run);
+ ret = execvpe(argv_run[0], argv_run, envp_run);
+ free(envp_run);
+ return ret;
err_free_env:
for (--i; i >= env_old; i--)
--
2.23.0

View File

@ -1,13 +1,21 @@
Name: iproute
Version: 5.5.0
Release: 5
Release: 6
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
Patch1: bugfix-iproute2-3.10.0-fix-maddr-show.patch
Patch2: bugfix-iproute2-change-proc-to-ipnetnsproc-which-is-private.patch
Patch3: backport-lib-fs-avoid-double-call-to-mkdir-on-make_path.patch
Patch4: backport-devlink-always-check-strslashrsplit-return-value.patch
Patch5: backport-nexthop-fix-memory-leak-in-add_nh_group_attr.patch
Patch6: backport-rdma-stat-fix-return-code.patch
Patch7: backport-ip-drop-2-char-command-assumption.patch
Patch8: backport-ip-netns-fix-missing-netns-close-on-some-error-paths.patch
Patch9: backport-lib-bpf_legacy-fix-missing-socket-close-when-connect.patch
Patch10: backport-tc-e_bpf-fix-memory-leak-in-parse_bpf.patch
Patch9002: feature-iproute-limit-operation-ip-netns-del.patch
Patch9003: feature-iproute-add-support-for-ipvlan-l2e-mode.patch
@ -81,6 +89,12 @@ install -m 0644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
%{_mandir}/*
%changelog
* Sat Jun 26 2021 jiangheng <jiangheng12@huawei.com> - 5.5.0-6
- Type:requirement
- Id:NA
- SUG:NA
- DESC:update patch
* Fri Jan 15 2021 gaihuiying <gaihuiying1@huawei.com> - 5.5.0-5
- Type:requirement
- Id:NA