Rebase package on top of iproute2-5.3.0

This commit is contained in:
Phil Sutter 2019-09-26 09:57:04 +02:00
parent 40ec840b2d
commit 34a4fc8582
13 changed files with 350 additions and 617 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/iproute2-5.0.0.tar.xz
/iproute2-5.1.0.tar.xz
/iproute2-5.2.0.tar.xz
/iproute2-5.3.0.tar.xz

View File

@ -1,41 +0,0 @@
From 8cfac8f16a88bac7453da91aeca9e2c4244ca92a Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Tue, 9 Jul 2019 15:16:50 +0200
Subject: [PATCH] Revert "ip6tunnel: fix 'ip -6 {show|change} dev <name>' cmds"
This reverts commit ba126dcad20e6d0e472586541d78bdd1ac4f1123.
It breaks tunnel creation when using 'dev' parameter:
$ ip link add type dummy
$ ip -6 tunnel add ip6tnl1 mode ip6ip6 remote 2001:db8:ffff:100::2 local 2001:db8:ffff:100::1 hoplimit 1 tclass 0x0 dev dummy0
add tunnel "ip6tnl0" failed: File exists
dev parameter must be used to specify the device to which
the tunnel is binded, and not the tunnel itself.
Reported-by: Jianwen Ji <jiji@redhat.com>
Reviewed-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit ad04dbc5b41df509cd6925eab36af73000632fd2)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/ip6tunnel.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/ip/ip6tunnel.c b/ip/ip6tunnel.c
index 56fd3466ed062..999408ed801b1 100644
--- a/ip/ip6tunnel.c
+++ b/ip/ip6tunnel.c
@@ -298,8 +298,6 @@ static int parse_args(int argc, char **argv, int cmd, struct ip6_tnl_parm2 *p)
p->link = ll_name_to_index(medium);
if (!p->link)
return nodev(medium);
- else
- strlcpy(p->name, medium, sizeof(p->name));
}
return 0;
}
--
2.22.0

View File

@ -0,0 +1,341 @@
From e72287abe26945d0cd453021baa75dd51b6c271b Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Mon, 16 Sep 2019 15:00:55 +0200
Subject: [PATCH] bpf: replace snprintf with asprintf when dealing with long
buffers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reduces stack usage, as asprintf allocates memory on the heap.
This indirectly fixes a snprintf truncation warning (from gcc v9.2.1):
bpf.c: In function bpf_get_work_dir:
bpf.c:784:49: warning: snprintf output may be truncated before the last format character [-Wformat-truncation=]
784 | snprintf(bpf_wrk_dir, sizeof(bpf_wrk_dir), "%s/", mnt);
| ^
bpf.c:784:2: note: snprintf output between 2 and 4097 bytes into a destination of size 4096
784 | snprintf(bpf_wrk_dir, sizeof(bpf_wrk_dir), "%s/", mnt);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixes: e42256699cac ("bpf: make tc's bpf loader generic and move into lib")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
(cherry picked from commit c0325b06382cb4f7ebfaf80c29c8800d74666fd9)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
lib/bpf.c | 155 ++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 116 insertions(+), 39 deletions(-)
diff --git a/lib/bpf.c b/lib/bpf.c
index 23cb0d96a85ba..10cf9bf44419a 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -406,13 +406,21 @@ static int bpf_derive_elf_map_from_fdinfo(int fd, struct bpf_elf_map *map,
struct bpf_map_ext *ext)
{
unsigned int val, owner_type = 0, owner_jited = 0;
- char file[PATH_MAX], buff[4096];
+ char *file = NULL;
+ char buff[4096];
FILE *fp;
+ int ret;
- snprintf(file, sizeof(file), "/proc/%d/fdinfo/%d", getpid(), fd);
+ ret = asprintf(&file, "/proc/%d/fdinfo/%d", getpid(), fd);
+ if (ret < 0) {
+ fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
+ free(file);
+ return ret;
+ }
memset(map, 0, sizeof(*map));
fp = fopen(file, "r");
+ free(file);
if (!fp) {
fprintf(stderr, "No procfs support?!\n");
return -EIO;
@@ -600,8 +608,9 @@ int bpf_trace_pipe(void)
0,
};
int fd_in, fd_out = STDERR_FILENO;
- char tpipe[PATH_MAX];
+ char *tpipe = NULL;
const char *mnt;
+ int ret;
mnt = bpf_find_mntpt("tracefs", TRACEFS_MAGIC, tracefs_mnt,
sizeof(tracefs_mnt), tracefs_known_mnts);
@@ -610,9 +619,15 @@ int bpf_trace_pipe(void)
return -1;
}
- snprintf(tpipe, sizeof(tpipe), "%s/trace_pipe", mnt);
+ ret = asprintf(&tpipe, "%s/trace_pipe", mnt);
+ if (ret < 0) {
+ fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
+ free(tpipe);
+ return ret;
+ }
fd_in = open(tpipe, O_RDONLY);
+ free(tpipe);
if (fd_in < 0)
return -1;
@@ -633,37 +648,50 @@ int bpf_trace_pipe(void)
static int bpf_gen_global(const char *bpf_sub_dir)
{
- char bpf_glo_dir[PATH_MAX];
+ char *bpf_glo_dir = NULL;
int ret;
- snprintf(bpf_glo_dir, sizeof(bpf_glo_dir), "%s/%s/",
- bpf_sub_dir, BPF_DIR_GLOBALS);
+ ret = asprintf(&bpf_glo_dir, "%s/%s/", bpf_sub_dir, BPF_DIR_GLOBALS);
+ if (ret < 0) {
+ fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
+ goto out;
+ }
ret = mkdir(bpf_glo_dir, S_IRWXU);
if (ret && errno != EEXIST) {
fprintf(stderr, "mkdir %s failed: %s\n", bpf_glo_dir,
strerror(errno));
- return ret;
+ goto out;
}
- return 0;
+ ret = 0;
+out:
+ free(bpf_glo_dir);
+ return ret;
}
static int bpf_gen_master(const char *base, const char *name)
{
- char bpf_sub_dir[PATH_MAX + NAME_MAX + 1];
+ char *bpf_sub_dir = NULL;
int ret;
- snprintf(bpf_sub_dir, sizeof(bpf_sub_dir), "%s%s/", base, name);
+ ret = asprintf(&bpf_sub_dir, "%s%s/", base, name);
+ if (ret < 0) {
+ fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
+ goto out;
+ }
ret = mkdir(bpf_sub_dir, S_IRWXU);
if (ret && errno != EEXIST) {
fprintf(stderr, "mkdir %s failed: %s\n", bpf_sub_dir,
strerror(errno));
- return ret;
+ goto out;
}
- return bpf_gen_global(bpf_sub_dir);
+ ret = bpf_gen_global(bpf_sub_dir);
+out:
+ free(bpf_sub_dir);
+ return ret;
}
static int bpf_slave_via_bind_mnt(const char *full_name,
@@ -692,13 +720,22 @@ static int bpf_slave_via_bind_mnt(const char *full_name,
static int bpf_gen_slave(const char *base, const char *name,
const char *link)
{
- char bpf_lnk_dir[PATH_MAX + NAME_MAX + 1];
- char bpf_sub_dir[PATH_MAX + NAME_MAX];
+ char *bpf_lnk_dir = NULL;
+ char *bpf_sub_dir = NULL;
struct stat sb = {};
int ret;
- snprintf(bpf_lnk_dir, sizeof(bpf_lnk_dir), "%s%s/", base, link);
- snprintf(bpf_sub_dir, sizeof(bpf_sub_dir), "%s%s", base, name);
+ ret = asprintf(&bpf_lnk_dir, "%s%s/", base, link);
+ if (ret < 0) {
+ fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
+ goto out;
+ }
+
+ ret = asprintf(&bpf_sub_dir, "%s%s", base, name);
+ if (ret < 0) {
+ fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
+ goto out;
+ }
ret = symlink(bpf_lnk_dir, bpf_sub_dir);
if (ret) {
@@ -706,25 +743,30 @@ static int bpf_gen_slave(const char *base, const char *name,
if (errno != EPERM) {
fprintf(stderr, "symlink %s failed: %s\n",
bpf_sub_dir, strerror(errno));
- return ret;
+ goto out;
}
- return bpf_slave_via_bind_mnt(bpf_sub_dir,
- bpf_lnk_dir);
+ ret = bpf_slave_via_bind_mnt(bpf_sub_dir, bpf_lnk_dir);
+ goto out;
}
ret = lstat(bpf_sub_dir, &sb);
if (ret) {
fprintf(stderr, "lstat %s failed: %s\n",
bpf_sub_dir, strerror(errno));
- return ret;
+ goto out;
}
- if ((sb.st_mode & S_IFMT) != S_IFLNK)
- return bpf_gen_global(bpf_sub_dir);
+ if ((sb.st_mode & S_IFMT) != S_IFLNK) {
+ ret = bpf_gen_global(bpf_sub_dir);
+ goto out;
+ }
}
- return 0;
+out:
+ free(bpf_lnk_dir);
+ free(bpf_sub_dir);
+ return ret;
}
static int bpf_gen_hierarchy(const char *base)
@@ -742,7 +784,7 @@ static int bpf_gen_hierarchy(const char *base)
static const char *bpf_get_work_dir(enum bpf_prog_type type)
{
static char bpf_tmp[PATH_MAX] = BPF_DIR_MNT;
- static char bpf_wrk_dir[PATH_MAX];
+ static char *bpf_wrk_dir;
static const char *mnt;
static bool bpf_mnt_cached;
const char *mnt_env = getenv(BPF_ENV_MNT);
@@ -781,7 +823,12 @@ static const char *bpf_get_work_dir(enum bpf_prog_type type)
}
}
- snprintf(bpf_wrk_dir, sizeof(bpf_wrk_dir), "%s/", mnt);
+ ret = asprintf(&bpf_wrk_dir, "%s/", mnt);
+ if (ret < 0) {
+ fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
+ free(bpf_wrk_dir);
+ goto out;
+ }
ret = bpf_gen_hierarchy(bpf_wrk_dir);
if (ret) {
@@ -1438,31 +1485,48 @@ static int bpf_probe_pinned(const char *name, const struct bpf_elf_ctx *ctx,
static int bpf_make_obj_path(const struct bpf_elf_ctx *ctx)
{
- char tmp[PATH_MAX];
+ char *tmp = NULL;
int ret;
- snprintf(tmp, sizeof(tmp), "%s/%s", bpf_get_work_dir(ctx->type),
- ctx->obj_uid);
+ ret = asprintf(&tmp, "%s/%s", bpf_get_work_dir(ctx->type), ctx->obj_uid);
+ if (ret < 0) {
+ fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
+ goto out;
+ }
ret = mkdir(tmp, S_IRWXU);
if (ret && errno != EEXIST) {
fprintf(stderr, "mkdir %s failed: %s\n", tmp, strerror(errno));
- return ret;
+ goto out;
}
- return 0;
+ ret = 0;
+out:
+ free(tmp);
+ return ret;
}
static int bpf_make_custom_path(const struct bpf_elf_ctx *ctx,
const char *todo)
{
- char tmp[PATH_MAX], rem[PATH_MAX], *sub;
+ char *tmp = NULL;
+ char *rem = NULL;
+ char *sub;
int ret;
- snprintf(tmp, sizeof(tmp), "%s/../", bpf_get_work_dir(ctx->type));
- snprintf(rem, sizeof(rem), "%s/", todo);
- sub = strtok(rem, "/");
+ ret = asprintf(&tmp, "%s/../", bpf_get_work_dir(ctx->type));
+ if (ret < 0) {
+ fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
+ goto out;
+ }
+ ret = asprintf(&rem, "%s/", todo);
+ if (ret < 0) {
+ fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
+ goto out;
+ }
+
+ sub = strtok(rem, "/");
while (sub) {
if (strlen(tmp) + strlen(sub) + 2 > PATH_MAX)
return -EINVAL;
@@ -1474,13 +1538,17 @@ static int bpf_make_custom_path(const struct bpf_elf_ctx *ctx,
if (ret && errno != EEXIST) {
fprintf(stderr, "mkdir %s failed: %s\n", tmp,
strerror(errno));
- return ret;
+ goto out;
}
sub = strtok(NULL, "/");
}
- return 0;
+ ret = 0;
+out:
+ free(rem);
+ free(tmp);
+ return ret;
}
static int bpf_place_pinned(int fd, const char *name,
@@ -2587,14 +2655,23 @@ struct bpf_jited_aux {
static int bpf_derive_prog_from_fdinfo(int fd, struct bpf_prog_data *prog)
{
- char file[PATH_MAX], buff[4096];
+ char *file = NULL;
+ char buff[4096];
unsigned int val;
FILE *fp;
+ int ret;
+
+ ret = asprintf(&file, "/proc/%d/fdinfo/%d", getpid(), fd);
+ if (ret < 0) {
+ fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
+ free(file);
+ return ret;
+ }
- snprintf(file, sizeof(file), "/proc/%d/fdinfo/%d", getpid(), fd);
memset(prog, 0, sizeof(*prog));
fp = fopen(file, "r");
+ free(file);
if (!fp) {
fprintf(stderr, "No procfs support?!\n");
return -EIO;
--
2.23.0

View File

@ -1,52 +0,0 @@
From 141c6e6397d373126bba14982678dd6f1e9fbfd7 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Tue, 9 Jul 2019 15:16:51 +0200
Subject: [PATCH] ip tunnel: warn when changing IPv6 tunnel without tunnel name
Tunnel change fails if a tunnel name is not specified while using
'ip -6 tunnel change'. However, no warning message is printed and
no error code is returned.
$ ip -6 tunnel add ip6tnl1 mode ip6gre local fd::1 remote fd::2 tos inherit ttl 127 encaplimit none dev dummy0
$ ip -6 tunnel change dev dummy0 local 2001:1234::1 remote 2001:1234::2
$ ip -6 tunnel show ip6tnl1
ip6tnl1: gre/ipv6 remote fd::2 local fd::1 dev dummy0 encaplimit none hoplimit 127 tclass inherit flowlabel 0x00000 (flowinfo 0x00000000)
This commit checks if tunnel interface name is equal to an empty
string: in this case, it prints a warning message to the user.
It intentionally avoids to return an error to not break existing
script setup.
This is the output after this commit:
$ ip -6 tunnel add ip6tnl1 mode ip6gre local fd::1 remote fd::2 tos inherit ttl 127 encaplimit none dev dummy0
$ ip -6 tunnel change dev dummy0 local 2001:1234::1 remote 2001:1234::2
Tunnel interface name not specified
$ ip -6 tunnel show ip6tnl1
ip6tnl1: gre/ipv6 remote fd::2 local fd::1 dev dummy0 encaplimit none hoplimit 127 tclass inherit flowlabel 0x00000 (flowinfo 0x00000000)
Reviewed-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit d035cc1b4e83e2589ea2115cdc2fa7c6d3693a5a)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/ip6tunnel.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ip/ip6tunnel.c b/ip/ip6tunnel.c
index 999408ed801b1..e3da11eb4518e 100644
--- a/ip/ip6tunnel.c
+++ b/ip/ip6tunnel.c
@@ -386,6 +386,9 @@ static int do_add(int cmd, int argc, char **argv)
if (parse_args(argc, argv, cmd, &p) < 0)
return -1;
+ if (!*p.name)
+ fprintf(stderr, "Tunnel interface name not specified\n");
+
if (p.proto == IPPROTO_GRE)
basedev = "ip6gre0";
else if (p.i_flags & VTI_ISVTI)
--
2.22.0

View File

@ -1,78 +0,0 @@
From 9da7fb1dd27624ed6ab62f5595451f43c3a07d2d Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Mon, 8 Jul 2019 11:36:42 +0200
Subject: [PATCH] ip-route: fix json formatting for metrics
Setting metrics for routes currently lead to non-parsable
json output. For example:
$ ip link add type dummy
$ ip route add 192.168.2.0 dev dummy0 metric 100 mtu 1000 rto_min 3
$ ip -j route | jq
parse error: ':' not as part of an object at line 1, column 319
Fixing this opening a json object in the metrics array and using
print_string() instead of fprintf().
This is the output for the above commands applying this patch:
$ ip -j route | jq
[
{
"dst": "192.168.2.0",
"dev": "dummy0",
"scope": "link",
"metric": 100,
"flags": [],
"metrics": [
{
"mtu": 1000,
"rto_min": 3
}
]
}
]
Fixes: 663c3cb23103f ("iproute: implement JSON and color output")
Fixes: 968272e791710 ("iproute: refactor metrics print")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Reported-by: Frank Hofmann <fhofmann@cloudflare.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 89ce8012d71f5689074dc4cbe3db102cbdf76460)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/iproute.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ip/iproute.c b/ip/iproute.c
index 1669e0138259e..2f9b612b0b506 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -578,6 +578,7 @@ static void print_rta_metrics(FILE *fp, const struct rtattr *rta)
int i;
open_json_array(PRINT_JSON, "metrics");
+ open_json_object(NULL);
parse_rtattr(mxrta, RTAX_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta));
@@ -611,7 +612,7 @@ static void print_rta_metrics(FILE *fp, const struct rtattr *rta)
print_rtax_features(fp, val);
break;
default:
- fprintf(fp, "%u ", val);
+ print_uint(PRINT_ANY, mx_names[i], "%u ", val);
break;
case RTAX_RTT:
@@ -639,6 +640,7 @@ static void print_rta_metrics(FILE *fp, const struct rtattr *rta)
}
}
+ close_json_object();
close_json_array(PRINT_JSON, NULL);
}
--
2.22.0

View File

@ -1,113 +0,0 @@
From 5b17171ce7363e597009e07fb143522a2d79c77b Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Fri, 28 Jun 2019 18:03:45 +0200
Subject: [PATCH] utils: move parse_percent() to tc_util
As parse_percent() is used only in tc.
This reduces ip, bridge and genl binaries size:
$ bloat-o-meter -t bridge/bridge bridge/bridge.new
add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-109 (-109)
Total: Before=50973, After=50864, chg -0.21%
$ bloat-o-meter -t genl/genl genl/genl.new
add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-109 (-109)
Total: Before=30298, After=30189, chg -0.36%
$ bloat-o-meter ip/ip ip/ip.new
add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-109 (-109)
Total: Before=674164, After=674055, chg -0.02%
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
(cherry picked from commit 1e5746d5e13d895b63da954f0290cffbb076cefa)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
include/utils.h | 1 -
lib/utils.c | 16 ----------------
tc/tc_util.c | 16 ++++++++++++++++
tc/tc_util.h | 1 +
4 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/include/utils.h b/include/utils.h
index 927fdc17e09dd..f9a4916b517ab 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -145,7 +145,6 @@ int get_addr_rta(inet_prefix *dst, const struct rtattr *rta, int family);
int get_addr_ila(__u64 *val, const char *arg);
int read_prop(const char *dev, char *prop, long *value);
-int parse_percent(double *val, const char *str);
int get_hex(char c);
int get_integer(int *val, const char *arg, int base);
int get_unsigned(unsigned *val, const char *arg, int base);
diff --git a/lib/utils.c b/lib/utils.c
index be0f11b00280d..5da9a47848966 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -101,22 +101,6 @@ out:
return -1;
}
-/* Parse a percent e.g: '30%'
- * return: 0 = ok, -1 = error, 1 = out of range
- */
-int parse_percent(double *val, const char *str)
-{
- char *p;
-
- *val = strtod(str, &p) / 100.;
- if (*val == HUGE_VALF || *val == HUGE_VALL)
- return 1;
- if (*p && strcmp(p, "%"))
- return -1;
-
- return 0;
-}
-
int get_hex(char c)
{
if (c >= 'A' && c <= 'F')
diff --git a/tc/tc_util.c b/tc/tc_util.c
index e5d15281581df..53d15e08e9734 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -190,6 +190,22 @@ static const struct rate_suffix {
{ NULL }
};
+/* Parse a percent e.g: '30%'
+ * return: 0 = ok, -1 = error, 1 = out of range
+ */
+int parse_percent(double *val, const char *str)
+{
+ char *p;
+
+ *val = strtod(str, &p) / 100.;
+ if (*val == HUGE_VALF || *val == HUGE_VALL)
+ return 1;
+ if (*p && strcmp(p, "%"))
+ return -1;
+
+ return 0;
+}
+
static int parse_percent_rate(char *rate, size_t len,
const char *str, const char *dev)
{
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 825fea36a0809..eb4b60db3fdd7 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -101,6 +101,7 @@ int print_tc_classid(char *buf, int len, __u32 h);
char *sprint_tc_classid(__u32 h, char *buf);
int tc_print_police(FILE *f, struct rtattr *tb);
+int parse_percent(double *val, const char *str);
int parse_police(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n);
int parse_action_control(int *argc_p, char ***argv_p,
--
2.22.0

View File

@ -1,97 +0,0 @@
From 29a5b8d072d06b685c428f15125ff62b8b470064 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Sat, 13 Jul 2019 11:44:07 +0200
Subject: [PATCH] tc: util: constrain percentage in 0-100 interval
parse_percent() currently allows to specify negative percentages
or value above 100%. However this does not seems to make sense,
as the function is used for probabilities or bandiwidth rates.
Moreover, using negative values leads to erroneous results
(using Bernoulli loss model as example):
$ ip link add test type dummy
$ ip link set test up
$ tc qdisc add dev test root netem loss gemodel -10% limit 10
$ tc qdisc show dev test
qdisc netem 800c: root refcnt 2 limit 10 loss gemodel p 90% r 10% 1-h 100% 1-k 0%
Using values above 100% we have instead:
$ ip link add test type dummy
$ ip link set test up
$ tc qdisc add dev test root netem loss gemodel 140% limit 10
$ tc qdisc show dev test
qdisc netem 800f: root refcnt 2 limit 10 loss gemodel p 40% r 60% 1-h 100% 1-k 0%
This commit changes parse_percent() with a check to ensure
percentage values stay between 1.0 and 0.0.
parse_percent_rate() function, which already employs a similar
check, is adjusted accordingly.
With this check in place, we have:
$ ip link add test type dummy
$ ip link set test up
$ tc qdisc add dev test root netem loss gemodel -10% limit 10
Illegal "loss gemodel p"
Fixes: 927e3cfb52b58 ("tc: B.W limits can now be specified in %.")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 6bc13e4a20f50e9c37d5a504c78222913c433fd3)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
tc/tc_util.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 53d15e08e9734..b90d256c33a4a 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -198,7 +198,7 @@ int parse_percent(double *val, const char *str)
char *p;
*val = strtod(str, &p) / 100.;
- if (*val == HUGE_VALF || *val == HUGE_VALL)
+ if (*val > 1.0 || *val < 0.0)
return 1;
if (*p && strcmp(p, "%"))
return -1;
@@ -226,16 +226,16 @@ static int parse_percent_rate(char *rate, size_t len,
if (ret != 1)
goto malf;
- if (parse_percent(&perc, str_perc))
+ ret = parse_percent(&perc, str_perc);
+ if (ret == 1) {
+ fprintf(stderr, "Invalid rate specified; should be between [0,100]%% but is %s\n", str);
+ goto err;
+ } else if (ret == -1) {
goto malf;
+ }
free(str_perc);
- if (perc > 1.0 || perc < 0.0) {
- fprintf(stderr, "Invalid rate specified; should be between [0,100]%% but is %s\n", str);
- return -1;
- }
-
rate_bit = perc * dev_mbit * 1000 * 1000;
ret = snprintf(rate, len, "%lf", rate_bit);
@@ -247,8 +247,9 @@ static int parse_percent_rate(char *rate, size_t len,
return 0;
malf:
- free(str_perc);
fprintf(stderr, "Specified rate value could not be read or is malformed\n");
+err:
+ free(str_perc);
return -1;
}
--
2.22.0

View File

@ -1,64 +0,0 @@
From f12ee1269f04a5f4ab5c18326004af32da4061ae Mon Sep 17 00:00:00 2001
From: Aya Levin <ayal@mellanox.com>
Date: Wed, 10 Jul 2019 14:03:19 +0300
Subject: [PATCH] devlink: Change devlink health dump show command to dumpit
Although devlink health dump show command is given per reporter, it
returns large amounts of data. Trying to use the doit cb results in
OUT-OF-BUFFER error. This complementary patch raises the DUMP flag in
order to invoke the dumpit cb. We're safe as no existing drivers
implement the dump health reporter option yet.
Fixes: 041e6e651a8e ("devlink: Add devlink health dump show command")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit b4d97ef57fd4b7669971ed209065a72d115dffc2)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
devlink/devlink.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 5618ba26d6fb3..9c338cb4ccc84 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -6072,13 +6072,13 @@ static int cmd_fmsg_object_cb(const struct nlmsghdr *nlh, void *data)
return MNL_CB_OK;
}
-static int cmd_health_object_common(struct dl *dl, uint8_t cmd)
+static int cmd_health_object_common(struct dl *dl, uint8_t cmd, uint16_t flags)
{
struct fmsg_cb_data data;
struct nlmsghdr *nlh;
int err;
- nlh = mnlg_msg_prepare(dl->nlg, cmd, NLM_F_REQUEST | NLM_F_ACK);
+ nlh = mnlg_msg_prepare(dl->nlg, cmd, flags | NLM_F_REQUEST | NLM_F_ACK);
err = dl_argv_parse_put(nlh, dl,
DL_OPT_HANDLE | DL_OPT_HEALTH_REPORTER_NAME, 0);
@@ -6093,12 +6093,16 @@ static int cmd_health_object_common(struct dl *dl, uint8_t cmd)
static int cmd_health_dump_show(struct dl *dl)
{
- return cmd_health_object_common(dl, DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET);
+ return cmd_health_object_common(dl,
+ DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET,
+ NLM_F_DUMP);
}
static int cmd_health_diagnose(struct dl *dl)
{
- return cmd_health_object_common(dl, DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE);
+ return cmd_health_object_common(dl,
+ DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
+ 0);
}
static int cmd_health_recover(struct dl *dl)
--
2.22.0

View File

@ -1,83 +0,0 @@
From 4aaf5d7099e7b985973b49f59ceef9b1fd6f6810 Mon Sep 17 00:00:00 2001
From: Aya Levin <ayal@mellanox.com>
Date: Wed, 10 Jul 2019 14:03:20 +0300
Subject: [PATCH] devlink: Fix binary values print
Fix function pr_out_binary_value() to start printing the binary buffer
from offset 0 instead of offset 1. Remove redundant new line at the
beginning of the output
Example:
With patch:
mlx5e_txqsq:
05 00 00 00 05 00 00 00 01 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 8e 6e 3a 13 07 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0
Without patch
mlx5e_txqsq:
00 00 00 05 00 00 00 01 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 8e 6e 3a 13 07 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c0
Fixes: 844a61764c6f ("devlink: Add helper functions for name and value separately")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 1d05cca2fd70a5bc8a9f4e978aa5629dbc99a973)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
devlink/devlink.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 9c338cb4ccc84..5dff974c93c93 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -1779,29 +1779,31 @@ static void pr_out_uint64_value(struct dl *dl, uint64_t value)
pr_out(" %"PRIu64, value);
}
+static bool is_binary_eol(int i)
+{
+ return !(i%16);
+}
+
static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
{
- int i = 1;
+ int i = 0;
if (dl->json_output)
jsonw_start_array(dl->jw);
- else
- pr_out("\n");
while (i < len) {
- if (dl->json_output) {
+ if (dl->json_output)
jsonw_printf(dl->jw, "%d", data[i]);
- } else {
- pr_out(" %02x", data[i]);
- if (!(i % 16))
- pr_out("\n");
- }
+ else
+ pr_out("%02x ", data[i]);
i++;
+ if (!dl->json_output && is_binary_eol(i))
+ __pr_out_newline();
}
if (dl->json_output)
jsonw_end_array(dl->jw);
- else if ((i - 1) % 16)
- pr_out("\n");
+ else if (!is_binary_eol(i))
+ __pr_out_newline();
}
static void pr_out_str_value(struct dl *dl, const char *value)
--
2.22.0

View File

@ -1,47 +0,0 @@
From a5d73c80107321aafd1e2007a059a7eb950412d7 Mon Sep 17 00:00:00 2001
From: Aya Levin <ayal@mellanox.com>
Date: Wed, 10 Jul 2019 14:03:21 +0300
Subject: [PATCH] devlink: Remove enclosing array brackets binary print with
json format
Keep pr_out_binary_value function only for printing. Inner relations
like array grouping should be done outside the function.
Fixes: 844a61764c6f ("devlink: Add helper functions for name and value separately")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit f359942a25d368ccf2e47b79f95db2798e09f7a4)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
devlink/devlink.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 5dff974c93c93..ebb1de3eb2eaa 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -1788,9 +1788,6 @@ static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
{
int i = 0;
- if (dl->json_output)
- jsonw_start_array(dl->jw);
-
while (i < len) {
if (dl->json_output)
jsonw_printf(dl->jw, "%d", data[i]);
@@ -1800,9 +1797,7 @@ static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
if (!dl->json_output && is_binary_eol(i))
__pr_out_newline();
}
- if (dl->json_output)
- jsonw_end_array(dl->jw);
- else if (!is_binary_eol(i))
+ if (!dl->json_output && !is_binary_eol(i))
__pr_out_newline();
}
--
2.22.0

View File

@ -1,30 +0,0 @@
From 742a2436d344ac15330c56a2326c03c8c56686a5 Mon Sep 17 00:00:00 2001
From: Ivan Delalande <colona@arista.com>
Date: Wed, 17 Jul 2019 18:15:31 -0700
Subject: [PATCH] json: fix backslash escape typo in jsonw_puts
Fixes: fcc16c22 ("provide common json output formatter")
Signed-off-by: Ivan Delalande <colona@arista.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit ed54f76484b5ee47b190a202ecf29fce60d0d878)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
lib/json_writer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/json_writer.c b/lib/json_writer.c
index 5004c181e6225..88c5eb8882254 100644
--- a/lib/json_writer.c
+++ b/lib/json_writer.c
@@ -75,7 +75,7 @@ static void jsonw_puts(json_writer_t *self, const char *str)
fputs("\\b", self->out);
break;
case '\\':
- fputs("\\n", self->out);
+ fputs("\\\\", self->out);
break;
case '"':
fputs("\\\"", self->out);
--
2.22.0

View File

@ -1,20 +1,12 @@
%global cbq_version v0.7.3
Summary: Advanced IP routing and network device configuration tools
Name: iproute
Version: 5.2.0
Release: 2%{?dist}
Version: 5.3.0
Release: 1%{?dist}
URL: http://kernel.org/pub/linux/utils/net/%{name}2/
Source0: http://kernel.org/pub/linux/utils/net/%{name}2/%{name}2-%{version}.tar.xz
Patch1: 0001-Revert-ip6tunnel-fix-ip-6-show-change-dev-name-cmds.patch
Patch2: 0002-ip-tunnel-warn-when-changing-IPv6-tunnel-without-tun.patch
Patch3: 0003-ip-route-fix-json-formatting-for-metrics.patch
Patch4: 0004-utils-move-parse_percent-to-tc_util.patch
Patch5: 0005-tc-util-constrain-percentage-in-0-100-interval.patch
Patch6: 0006-devlink-Change-devlink-health-dump-show-command-to-d.patch
Patch7: 0007-devlink-Fix-binary-values-print.patch
Patch8: 0008-devlink-Remove-enclosing-array-brackets-binary-print.patch
Patch9: 0009-json-fix-backslash-escape-typo-in-jsonw_puts.patch
Patch1: 0001-bpf-replace-snprintf-with-asprintf-when-dealing-with.patch
License: GPLv2+ and Public Domain
BuildRequires: gcc
@ -132,6 +124,10 @@ install -D -m644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
%{_includedir}/iproute2/bpf_elf.h
%changelog
* Thu Sep 26 2019 Phil Sutter <psutter@redhat.com> - 5.3.0-1
- New version 5.3.0
- Add upstream-suggested backports
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 5.2.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

View File

@ -1 +1 @@
SHA512 (iproute2-5.2.0.tar.xz) = 82bbeae29d98129d822c95ff7523186569e32c66132b8d781d501d61f396b04d122e3d13057dd4236455264008e5bfac7cb63c325908fc1c46d416cbde6ac7e1
SHA512 (iproute2-5.3.0.tar.xz) = c20ce477cb3ec24194ea56d3d9037795e26975ffde188b63ba974a0aa671dd169f356e9446bf43dc56523e01c0bafa442b91d83da9b2302daee18e237f2f3157