Compare commits

...
Sign in to create a new pull request.

4 commits

Author SHA1 Message Date
Phil Sutter
962fa90165 iproute-5.4.0-2
- Add further upstream-suggested backports
- Fix for missing newline in last line of ss output
2020-08-21 00:27:53 +02:00
Phil Sutter
cfee7312aa Update sources and .gitignore 2020-01-28 11:41:11 +01:00
Phil Sutter
26727e741e Rebase package on top of iproute2-5.4.0 2020-01-28 11:34:50 +01:00
Phil Sutter
beac68c348 Rebase package on top of iproute2-5.3.0 2019-09-26 10:17:44 +02:00
44 changed files with 2610 additions and 634 deletions

2
.gitignore vendored
View file

@ -3,3 +3,5 @@
/iproute2-5.0.0.tar.xz
/iproute2-5.1.0.tar.xz
/iproute2-5.2.0.tar.xz
/iproute2-5.3.0.tar.xz
/iproute2-5.4.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,43 @@
From 6304309e2ab98c9125c58f3bcc7e86abcf904f35 Mon Sep 17 00:00:00 2001
From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Tue, 5 Nov 2019 13:17:07 -0800
Subject: [PATCH] devlink: allow full range of resource sizes
Resource size is a 64 bit attribute at netlink level.
Make the command line argument 64 bit as well.
Fixes: 8cd644095842 ("devlink: Add support for devlink resource abstraction")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
(cherry picked from commit c3f69bf923dea50e48564fd520fec6314ddbcf5f)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
devlink/devlink.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 056ac95ee726f..ebffa8c80ffef 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -281,7 +281,7 @@ struct dl_opts {
bool dpipe_counters_enable;
bool eswitch_encap_mode;
const char *resource_path;
- uint32_t resource_size;
+ uint64_t resource_size;
uint32_t resource_id;
bool resource_id_valid;
const char *param_name;
@@ -1334,7 +1334,7 @@ static int dl_argv_parse(struct dl *dl, uint64_t o_required,
} else if (dl_argv_match(dl, "size") &&
(o_all & DL_OPT_RESOURCE_SIZE)) {
dl_arg_inc(dl);
- err = dl_argv_uint32_t(dl, &opts->resource_size);
+ err = dl_argv_uint64_t(dl, &opts->resource_size);
if (err)
return err;
o_found |= DL_OPT_RESOURCE_SIZE;
--
2.27.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

@ -0,0 +1,35 @@
From fc3fd84e56052c7f29a052f4f903a86feab50fe5 Mon Sep 17 00:00:00 2001
From: Brian Vazquez <brianvv@google.com>
Date: Tue, 26 Nov 2019 21:19:34 -0800
Subject: [PATCH] tc: fix warning in tc/m_ct.c
Warning was:
m_ct.c:370:13: warning: variable 'nat' is used uninitialized whenever
'if' condition is false
Cc: Paul Blakey <paulb@mellanox.com>
Fixes: c8a494314c40 ("tc: Introduce tc ct action")
Signed-off-by: Brian Vazquez <brianvv@google.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit cad1b0bc5f12be7c3b5a1a4c1b55646a0766c9a8)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
tc/m_ct.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tc/m_ct.c b/tc/m_ct.c
index 8df2f61036014..45fa4a8c9ff49 100644
--- a/tc/m_ct.c
+++ b/tc/m_ct.c
@@ -359,7 +359,7 @@ static void ct_print_nat(int ct_action, struct rtattr **tb)
{
size_t done = 0;
char out[256] = "";
- bool nat;
+ bool nat = false;
if (!(ct_action & TCA_CT_ACT_NAT))
return;
--
2.27.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

@ -0,0 +1,40 @@
From 4f058d48daf52e9a0bad4a7b2bf8e2a78ecd37a3 Mon Sep 17 00:00:00 2001
From: Brian Vazquez <brianvv@google.com>
Date: Wed, 4 Dec 2019 13:32:03 -0800
Subject: [PATCH] tc: fix warning in tc/q_pie.c
Warning was:
q_pie.c:202:22: error: implicit conversion from 'unsigned long' to
'double'
Fixes: 492ec9558b30 ("tc: pie: change maximum integer value of tc_pie_xstats->prob")
Cc: Leslie Monis <lesliemonis@gmail.com>
Signed-off-by: Brian Vazquez <brianvv@google.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 908985c6709b6c0673501d61748c080889382d4f)
Conflicts:
* tc/q_pie.c - Change applied manually, conflicts due to missing commit
920700a425e51 ("tc: pie: add dq_rate_estimator option").
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
tc/q_pie.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tc/q_pie.c b/tc/q_pie.c
index 40982f9618783..52ba725614e30 100644
--- a/tc/q_pie.c
+++ b/tc/q_pie.c
@@ -199,7 +199,7 @@ static int pie_print_xstats(struct qdisc_util *qu, FILE *f,
st = RTA_DATA(xstats);
/*prob is returned as a fracion of maximum integer value */
fprintf(f, "prob %f delay %uus avg_dq_rate %u\n",
- (double)st->prob / UINT64_MAX, st->delay,
+ (double)st->prob / (double)UINT64_MAX, st->delay,
st->avg_dq_rate);
fprintf(f, "pkts_in %u overlimit %u dropped %u maxq %u ecn_mark %u\n",
st->packets_in, st->overlimit, st->dropped, st->maxq,
--
2.27.0

View file

@ -0,0 +1,30 @@
From 936a32a7b52175f8fed43651d15cb9b4740e821d Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Date: Mon, 16 Dec 2019 15:43:37 +0900
Subject: [PATCH] json_print: Remove declaration without implementation
Fixes: 6377572f0aa8 ("ip: ip_print: add new API to print JSON or regular format output")
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 15322f46c3427a7d065b41fc5b0e513755329295)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
include/json_print.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/include/json_print.h b/include/json_print.h
index fe92d14ca451f..6695654f71947 100644
--- a/include/json_print.h
+++ b/include/json_print.h
@@ -34,8 +34,6 @@ void delete_json_obj(void);
bool is_json_context(void);
-void fflush_fp(void);
-
void open_json_object(const char *str);
void close_json_object(void);
void open_json_array(enum output_type type, const char *delim);
--
2.27.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

@ -0,0 +1,32 @@
From dda39d1122c5538247190287b3cc0a42196f9215 Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Date: Mon, 16 Dec 2019 15:43:38 +0900
Subject: [PATCH] testsuite: Fix line count test
a substring match is not enough, ex: 10 != 1
Fixes: 30383b074de1 ("tests: Add output testing")
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit d88a6a98e86da9446487ecc4f1fea435323ef21d)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
testsuite/lib/generic.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testsuite/lib/generic.sh b/testsuite/lib/generic.sh
index f92260fc40cf3..e909008aa49cb 100644
--- a/testsuite/lib/generic.sh
+++ b/testsuite/lib/generic.sh
@@ -121,7 +121,7 @@ test_on_not()
test_lines_count()
{
echo -n "test on lines count ($1): "
- if cat "$STD_OUT" | wc -l | grep -q "$1"
+ if [ $(cat "$STD_OUT" | wc -l) -eq "$1" ]
then
pr_success
else
--
2.27.0

View file

@ -0,0 +1,49 @@
From 07772a2b3ab7d3ca8cd9994bfd2d45d4ddedf33f Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Date: Mon, 16 Dec 2019 15:43:39 +0900
Subject: [PATCH] bridge: Fix typo in error messages
Fixes: 9eff0e5cc447 ("bridge: Add vlan configuration support")
Fixes: 7abf5de677e3 ("bridge: vlan: add support to display per-vlan statistics")
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 43b0b6ec840c27bd9b8d014f338d0235cb2618a0)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
bridge/vlan.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/bridge/vlan.c b/bridge/vlan.c
index 6d33b0a990a5e..6dc694b6565b7 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -576,7 +576,7 @@ static int vlan_show(int argc, char **argv)
(compress_vlans ?
RTEXT_FILTER_BRVLAN_COMPRESSED :
RTEXT_FILTER_BRVLAN)) < 0) {
- perror("Cannont send dump request");
+ perror("Cannot send dump request");
exit(1);
}
@@ -601,7 +601,7 @@ static int vlan_show(int argc, char **argv)
filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS);
if (rtnl_statsdump_req_filter(&rth, AF_UNSPEC, filt_mask) < 0) {
- perror("Cannont send dump request");
+ perror("Cannot send dump request");
exit(1);
}
@@ -615,7 +615,7 @@ static int vlan_show(int argc, char **argv)
filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS_SLAVE);
if (rtnl_statsdump_req_filter(&rth, AF_UNSPEC, filt_mask) < 0) {
- perror("Cannont send slave dump request");
+ perror("Cannot send slave dump request");
exit(1);
}
--
2.27.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

@ -0,0 +1,44 @@
From 038122146f45759893040d7ae648c99ac0058060 Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Date: Mon, 16 Dec 2019 15:43:40 +0900
Subject: [PATCH] bridge: Fix src_vni argument in man page
"SRC VNI" is only one argument and should appear as such. Moreover, this
argument to the src_vni option is documented under three forms: "SRC_VNI",
"SRC VNI" and "VNI" in different places. Consistenly use the simplest form,
"VNI".
Fixes: c5b176e5ba1f ("bridge: fdb: add support for src_vni option")
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit df1262155c4b3102e6d01ec082ad123377248019)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
man/man8/bridge.8 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/man/man8/bridge.8 b/man/man8/bridge.8
index bb4fb521f8e57..fafdee75e2b36 100644
--- a/man/man8/bridge.8
+++ b/man/man8/bridge.8
@@ -71,7 +71,7 @@ bridge \- show / manipulate bridge addresses and devices
.B dst
.IR IPADDR " ] [ "
.B src_vni
-.IR SRC_VNI " ] ["
+.IR VNI " ] ["
.B vni
.IR VNI " ] ["
.B port
@@ -487,7 +487,7 @@ the IP address of the destination
VXLAN tunnel endpoint where the Ethernet MAC ADDRESS resides.
.TP
-.BI src_vni " SRC VNI"
+.BI src_vni " VNI"
the src VNI Network Identifier (or VXLAN Segment ID)
this entry belongs to. Used only when the vxlan device is in
external or collect metadata mode. If omitted the value specified at
--
2.27.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

@ -0,0 +1,53 @@
From 7787d5f4124cf617eb0726ddf6f0b65af3153c11 Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Date: Mon, 16 Dec 2019 15:43:41 +0900
Subject: [PATCH] bridge: Fix BRIDGE_VLAN_TUNNEL attribute sizes
As per the kernel's vlan_tunnel_policy, IFLA_BRIDGE_VLAN_TUNNEL_VID and
IFLA_BRIDGE_VLAN_TUNNEL_FLAGS have type NLA_U16.
Fixes: 8652eeb3ab12 ("bridge: vlan: support for per vlan tunnel info")
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 1f53ba7297a8b8189fd6853c480de2f6bf9ac787)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
bridge/vlan.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/bridge/vlan.c b/bridge/vlan.c
index 6dc694b6565b7..c0294aa6990cb 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -71,8 +71,8 @@ static int add_tunnel_info(struct nlmsghdr *n, int reqsize,
tinfo = addattr_nest(n, reqsize, IFLA_BRIDGE_VLAN_TUNNEL_INFO);
addattr32(n, reqsize, IFLA_BRIDGE_VLAN_TUNNEL_ID, tun_id);
- addattr32(n, reqsize, IFLA_BRIDGE_VLAN_TUNNEL_VID, vid);
- addattr32(n, reqsize, IFLA_BRIDGE_VLAN_TUNNEL_FLAGS, flags);
+ addattr16(n, reqsize, IFLA_BRIDGE_VLAN_TUNNEL_VID, vid);
+ addattr16(n, reqsize, IFLA_BRIDGE_VLAN_TUNNEL_FLAGS, flags);
addattr_nest_end(n, tinfo);
@@ -304,7 +304,7 @@ static void print_vlan_tunnel_info(FILE *fp, struct rtattr *tb, int ifindex)
if (ttb[IFLA_BRIDGE_VLAN_TUNNEL_VID])
tunnel_vid =
- rta_getattr_u32(ttb[IFLA_BRIDGE_VLAN_TUNNEL_VID]);
+ rta_getattr_u16(ttb[IFLA_BRIDGE_VLAN_TUNNEL_VID]);
else
continue;
@@ -314,7 +314,7 @@ static void print_vlan_tunnel_info(FILE *fp, struct rtattr *tb, int ifindex)
if (ttb[IFLA_BRIDGE_VLAN_TUNNEL_FLAGS])
tunnel_flags =
- rta_getattr_u32(ttb[IFLA_BRIDGE_VLAN_TUNNEL_FLAGS]);
+ rta_getattr_u16(ttb[IFLA_BRIDGE_VLAN_TUNNEL_FLAGS]);
if (!(tunnel_flags & BRIDGE_VLAN_INFO_RANGE_END)) {
last_vid_start = tunnel_vid;
--
2.27.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

@ -0,0 +1,114 @@
From 198678f2115f2c0f50bea3754116779f5adf6a0b Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Date: Mon, 16 Dec 2019 15:43:42 +0900
Subject: [PATCH] bridge: Fix vni printing
Since commit c7c1a1ef51ae ("bridge: colorize output and use JSON print
library"), print_range() is used for vid (16bits) and vni. However, the
latter are 32bits so they get truncated. They got truncated even before
that commit though.
Fixes: 8652eeb3ab12 ("bridge: vlan: support for per vlan tunnel info")
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit dfa13e2273b206419ec0199a11c92122f2e8ea33)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
bridge/vlan.c | 6 +++---
testsuite/Makefile | 3 ++-
testsuite/lib/generic.sh | 6 +++++-
testsuite/tests/bridge/vlan/tunnelshow.t | 24 ++++++++++++++++++++++++
4 files changed, 34 insertions(+), 5 deletions(-)
create mode 100755 testsuite/tests/bridge/vlan/tunnelshow.t
diff --git a/bridge/vlan.c b/bridge/vlan.c
index c0294aa6990cb..428eeee3c5aef 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -266,15 +266,15 @@ static void close_vlan_port(void)
close_json_object();
}
-static void print_range(const char *name, __u16 start, __u16 id)
+static void print_range(const char *name, __u32 start, __u32 id)
{
char end[64];
snprintf(end, sizeof(end), "%sEnd", name);
- print_hu(PRINT_ANY, name, "\t %hu", start);
+ print_uint(PRINT_ANY, name, "\t %u", start);
if (start != id)
- print_hu(PRINT_ANY, end, "-%hu", id);
+ print_uint(PRINT_ANY, end, "-%u", id);
}
diff --git a/testsuite/Makefile b/testsuite/Makefile
index 4451f316910df..fb50f618a3beb 100644
--- a/testsuite/Makefile
+++ b/testsuite/Makefile
@@ -82,7 +82,8 @@ endif
TMP_OUT=`mktemp /tmp/tc_testsuite.XXXXXX`; \
. $(KENVFN); \
STD_ERR="$$TMP_ERR" STD_OUT="$$TMP_OUT" \
- TC="$$i/tc/tc" IP="$$i/ip/ip" SS=$$i/misc/ss DEV="$(DEV)" IPVER="$@" SNAME="$$i" \
+ TC="$$i/tc/tc" IP="$$i/ip/ip" SS=$$i/misc/ss BRIDGE="$$i/bridge/bridge" \
+ DEV="$(DEV)" IPVER="$@" SNAME="$$i" \
ERRF="$(RESULTS_DIR)/$@.$$o.err" $(PREFIX) tests/$@ > $(RESULTS_DIR)/$@.$$o.out; \
if [ "$$?" = "127" ]; then \
printf "\033[1;35mSKIPPED\033[0m\n"; \
diff --git a/testsuite/lib/generic.sh b/testsuite/lib/generic.sh
index e909008aa49cb..8b339ec175037 100644
--- a/testsuite/lib/generic.sh
+++ b/testsuite/lib/generic.sh
@@ -1,4 +1,3 @@
-
export DEST="127.0.0.1"
ts_log()
@@ -66,6 +65,11 @@ ts_ss()
__ts_cmd "$SS" "$@"
}
+ts_bridge()
+{
+ __ts_cmd "$BRIDGE" "$@"
+}
+
ts_qdisc_available()
{
HELPOUT=`$TC qdisc add $1 help 2>&1`
diff --git a/testsuite/tests/bridge/vlan/tunnelshow.t b/testsuite/tests/bridge/vlan/tunnelshow.t
new file mode 100755
index 0000000000000..1583abb92f472
--- /dev/null
+++ b/testsuite/tests/bridge/vlan/tunnelshow.t
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+. lib/generic.sh
+
+ts_log "[Testing tunnelshow]"
+
+BR_DEV="$(rand_dev)"
+VX_DEV="$(rand_dev)"
+
+ts_ip "$0" "Add $BR_DEV bridge interface" link add $BR_DEV type bridge
+
+ts_ip "$0" "Add $VX_DEV vxlan interface" \
+ link add $VX_DEV type vxlan dstport 4789 external
+ts_ip "$0" "Enslave $VX_DEV under $BR_DEV" \
+ link set dev $VX_DEV master $BR_DEV
+ts_ip "$0" "Set vlan_tunnel on $VX_DEV" \
+ link set dev $VX_DEV type bridge_slave vlan_tunnel on
+
+ts_bridge "$0" "Add single vlan" vlan add dev $VX_DEV vid 1030
+ts_bridge "$0" "Add tunnel with vni > 16k" \
+ vlan add dev $VX_DEV vid 1030 tunnel_info id 65556
+
+ts_bridge "$0" "Show tunnel info" vlan tunnelshow dev $VX_DEV
+test_on "1030\s+65556"
--
2.27.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

@ -0,0 +1,203 @@
From 20fc76587210e8d03fe753bb039ac2c874fd0a4c Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Date: Mon, 16 Dec 2019 15:43:43 +0900
Subject: [PATCH] bridge: Deduplicate vlan show functions
print_vlan() and print_vlan_tunnel() are almost identical copies, save for
a missing newline in the latter which leads to broken output of "vlan
tunnelshow" in normal mode.
Fixes: c7c1a1ef51ae ("bridge: colorize output and use JSON print library")
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 955a20be027d2ff47b0c6fab3353c85cee614b90)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
bridge/vlan.c | 91 +++++++-----------------
testsuite/tests/bridge/vlan/tunnelshow.t | 7 ++
2 files changed, 34 insertions(+), 64 deletions(-)
diff --git a/bridge/vlan.c b/bridge/vlan.c
index 428eeee3c5aef..19283bca7c986 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -16,7 +16,11 @@
#include "utils.h"
static unsigned int filter_index, filter_vlan;
-static int show_vlan_tunnel_info = 0;
+
+enum vlan_show_subject {
+ VLAN_SHOW_VLAN,
+ VLAN_SHOW_TUNNELINFO,
+};
static void usage(void)
{
@@ -278,7 +282,7 @@ static void print_range(const char *name, __u32 start, __u32 id)
}
-static void print_vlan_tunnel_info(FILE *fp, struct rtattr *tb, int ifindex)
+static void print_vlan_tunnel_info(struct rtattr *tb, int ifindex)
{
struct rtattr *i, *list = tb;
int rem = RTA_PAYLOAD(list);
@@ -347,52 +351,9 @@ static void print_vlan_tunnel_info(FILE *fp, struct rtattr *tb, int ifindex)
close_vlan_port();
}
-static int print_vlan_tunnel(struct nlmsghdr *n, void *arg)
-{
- struct ifinfomsg *ifm = NLMSG_DATA(n);
- struct rtattr *tb[IFLA_MAX+1];
- int len = n->nlmsg_len;
- FILE *fp = arg;
-
- if (n->nlmsg_type != RTM_NEWLINK) {
- fprintf(stderr, "Not RTM_NEWLINK: %08x %08x %08x\n",
- n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
- return 0;
- }
-
- len -= NLMSG_LENGTH(sizeof(*ifm));
- if (len < 0) {
- fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
- return -1;
- }
-
- if (ifm->ifi_family != AF_BRIDGE)
- return 0;
-
- if (filter_index && filter_index != ifm->ifi_index)
- return 0;
-
- parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifm), len);
-
- /* if AF_SPEC isn't there, vlan table is not preset for this port */
- if (!tb[IFLA_AF_SPEC]) {
- if (!filter_vlan && !is_json_context()) {
- color_fprintf(fp, COLOR_IFNAME, "%s",
- ll_index_to_name(ifm->ifi_index));
- fprintf(fp, "\tNone\n");
- }
- return 0;
- }
-
- print_vlan_tunnel_info(fp, tb[IFLA_AF_SPEC], ifm->ifi_index);
-
- fflush(fp);
- return 0;
-}
-
static int print_vlan(struct nlmsghdr *n, void *arg)
{
- FILE *fp = arg;
+ enum vlan_show_subject *subject = arg;
struct ifinfomsg *ifm = NLMSG_DATA(n);
int len = n->nlmsg_len;
struct rtattr *tb[IFLA_MAX+1];
@@ -420,17 +381,24 @@ static int print_vlan(struct nlmsghdr *n, void *arg)
/* if AF_SPEC isn't there, vlan table is not preset for this port */
if (!tb[IFLA_AF_SPEC]) {
if (!filter_vlan && !is_json_context()) {
- color_fprintf(fp, COLOR_IFNAME, "%s",
+ color_fprintf(stdout, COLOR_IFNAME, "%s",
ll_index_to_name(ifm->ifi_index));
- fprintf(fp, "\tNone\n");
+ fprintf(stdout, "\tNone\n");
}
return 0;
}
- print_vlan_info(tb[IFLA_AF_SPEC], ifm->ifi_index);
+ switch (*subject) {
+ case VLAN_SHOW_VLAN:
+ print_vlan_info(tb[IFLA_AF_SPEC], ifm->ifi_index);
+ break;
+ case VLAN_SHOW_TUNNELINFO:
+ print_vlan_tunnel_info(tb[IFLA_AF_SPEC], ifm->ifi_index);
+ break;
+ }
print_string(PRINT_FP, NULL, "%s", _SL_);
- fflush(fp);
+ fflush(stdout);
return 0;
}
@@ -543,7 +511,7 @@ static int print_vlan_stats(struct nlmsghdr *n, void *arg)
return 0;
}
-static int vlan_show(int argc, char **argv)
+static int vlan_show(int argc, char **argv, int subject)
{
char *filter_dev = NULL;
int ret = 0;
@@ -581,17 +549,13 @@ static int vlan_show(int argc, char **argv)
}
if (!is_json_context()) {
- if (show_vlan_tunnel_info)
- printf("port\tvlan ids\ttunnel id\n");
- else
- printf("port\tvlan ids\n");
+ printf("port\tvlan ids");
+ if (subject == VLAN_SHOW_TUNNELINFO)
+ printf("\ttunnel id");
+ printf("\n");
}
- if (show_vlan_tunnel_info)
- ret = rtnl_dump_filter(&rth, print_vlan_tunnel,
- stdout);
- else
- ret = rtnl_dump_filter(&rth, print_vlan, stdout);
+ ret = rtnl_dump_filter(&rth, print_vlan, &subject);
if (ret < 0) {
fprintf(stderr, "Dump ternminated\n");
exit(1);
@@ -677,15 +641,14 @@ int do_vlan(int argc, char **argv)
if (matches(*argv, "show") == 0 ||
matches(*argv, "lst") == 0 ||
matches(*argv, "list") == 0)
- return vlan_show(argc-1, argv+1);
+ return vlan_show(argc-1, argv+1, VLAN_SHOW_VLAN);
if (matches(*argv, "tunnelshow") == 0) {
- show_vlan_tunnel_info = 1;
- return vlan_show(argc-1, argv+1);
+ return vlan_show(argc-1, argv+1, VLAN_SHOW_TUNNELINFO);
}
if (matches(*argv, "help") == 0)
usage();
} else {
- return vlan_show(0, NULL);
+ return vlan_show(0, NULL, VLAN_SHOW_VLAN);
}
fprintf(stderr, "Command \"%s\" is unknown, try \"bridge vlan help\".\n", *argv);
diff --git a/testsuite/tests/bridge/vlan/tunnelshow.t b/testsuite/tests/bridge/vlan/tunnelshow.t
index 1583abb92f472..b2141e7c5ea4c 100755
--- a/testsuite/tests/bridge/vlan/tunnelshow.t
+++ b/testsuite/tests/bridge/vlan/tunnelshow.t
@@ -16,9 +16,16 @@ ts_ip "$0" "Enslave $VX_DEV under $BR_DEV" \
ts_ip "$0" "Set vlan_tunnel on $VX_DEV" \
link set dev $VX_DEV type bridge_slave vlan_tunnel on
+ts_bridge "$0" "Add single vlan" vlan add dev $VX_DEV vid 1000
+ts_bridge "$0" "Add single tunnel" \
+ vlan add dev $VX_DEV vid 1000 tunnel_info id 1000
+ts_bridge "$0" "Add vlan range" vlan add dev $VX_DEV vid 1010-1020
+ts_bridge "$0" "Add tunnel range" \
+ vlan add dev $VX_DEV vid 1010-1020 tunnel_info id 1010-1020
ts_bridge "$0" "Add single vlan" vlan add dev $VX_DEV vid 1030
ts_bridge "$0" "Add tunnel with vni > 16k" \
vlan add dev $VX_DEV vid 1030 tunnel_info id 65556
ts_bridge "$0" "Show tunnel info" vlan tunnelshow dev $VX_DEV
test_on "1030\s+65556"
+test_lines_count 5
--
2.27.0

View file

@ -0,0 +1,115 @@
From 1eaf42ad3be39090c6735f4de37669f38d8ed8eb Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Date: Mon, 16 Dec 2019 15:43:44 +0900
Subject: [PATCH] bridge: Fix tunnelshow json output
repeats for "vlan tunnelshow" what commit 0f36267485e3 ("bridge: fix vlan
show formatting") did for "vlan show". This fixes problems in json output.
Note that the resulting json output format of "vlan tunnelshow" is not the
same as the original, introduced in commit 8652eeb3ab12 ("bridge: vlan:
support for per vlan tunnel info"). Changes similar to the ones done for
"vlan show" in commit 0f36267485e3 ("bridge: fix vlan show formatting") are
carried over to "vlan tunnelshow".
Fixes: c7c1a1ef51ae ("bridge: colorize output and use JSON print library")
Fixes: 0f36267485e3 ("bridge: fix vlan show formatting")
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 1a500c78aef0d4fd33c1700dbfcf435ea2c53847)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
bridge/vlan.c | 27 +++++++-----------------
testsuite/tests/bridge/vlan/tunnelshow.t | 2 ++
2 files changed, 10 insertions(+), 19 deletions(-)
diff --git a/bridge/vlan.c b/bridge/vlan.c
index 19283bca7c986..205851e4f78ec 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -256,12 +256,14 @@ static int filter_vlan_check(__u16 vid, __u16 flags)
return 1;
}
-static void open_vlan_port(int ifi_index, const char *fmt)
+static void open_vlan_port(int ifi_index, const char *fmt,
+ enum vlan_show_subject subject)
{
open_json_object(NULL);
print_color_string(PRINT_ANY, COLOR_IFNAME, "ifname", fmt,
ll_index_to_name(ifi_index));
- open_json_array(PRINT_JSON, "vlans");
+ open_json_array(PRINT_JSON,
+ subject == VLAN_SHOW_VLAN ? "vlans": "tunnels");
}
static void close_vlan_port(void)
@@ -289,10 +291,8 @@ static void print_vlan_tunnel_info(struct rtattr *tb, int ifindex)
__u16 last_vid_start = 0;
__u32 last_tunid_start = 0;
- if (!filter_vlan)
- open_vlan_port(ifindex, "%s");
+ open_vlan_port(ifindex, "%s", VLAN_SHOW_TUNNELINFO);
- open_json_array(PRINT_JSON, "tunnel");
for (i = RTA_DATA(list); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
struct rtattr *ttb[IFLA_BRIDGE_VLAN_TUNNEL_MAX+1];
__u32 tunnel_id = 0;
@@ -331,24 +331,13 @@ static void print_vlan_tunnel_info(struct rtattr *tb, int ifindex)
else if (vcheck_ret == 0)
continue;
- if (tunnel_flags & BRIDGE_VLAN_INFO_RANGE_BEGIN)
- continue;
-
- if (filter_vlan)
- open_vlan_port(ifindex, "%s");
-
open_json_object(NULL);
print_range("vlan", last_vid_start, tunnel_vid);
print_range("tunid", last_tunid_start, tunnel_id);
close_json_object();
-
print_string(PRINT_FP, NULL, "%s", _SL_);
- if (filter_vlan)
- close_vlan_port();
}
-
- if (!filter_vlan)
- close_vlan_port();
+ close_vlan_port();
}
static int print_vlan(struct nlmsghdr *n, void *arg)
@@ -467,7 +456,7 @@ static void print_vlan_stats_attr(struct rtattr *attr, int ifindex)
/* found vlan stats, first time print the interface name */
if (!found_vlan) {
- open_vlan_port(ifindex, "%-16s");
+ open_vlan_port(ifindex, "%-16s", VLAN_SHOW_VLAN);
found_vlan = true;
} else {
print_string(PRINT_FP, NULL, "%-16s", "");
@@ -600,7 +589,7 @@ void print_vlan_info(struct rtattr *tb, int ifindex)
int rem = RTA_PAYLOAD(list);
__u16 last_vid_start = 0;
- open_vlan_port(ifindex, "%s");
+ open_vlan_port(ifindex, "%s", VLAN_SHOW_VLAN);
for (i = RTA_DATA(list); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
struct bridge_vlan_info *vinfo;
diff --git a/testsuite/tests/bridge/vlan/tunnelshow.t b/testsuite/tests/bridge/vlan/tunnelshow.t
index b2141e7c5ea4c..fd41bfcb32a2b 100755
--- a/testsuite/tests/bridge/vlan/tunnelshow.t
+++ b/testsuite/tests/bridge/vlan/tunnelshow.t
@@ -29,3 +29,5 @@ ts_bridge "$0" "Add tunnel with vni > 16k" \
ts_bridge "$0" "Show tunnel info" vlan tunnelshow dev $VX_DEV
test_on "1030\s+65556"
test_lines_count 5
+
+ts_bridge "$0" "Dump tunnel info" -j vlan tunnelshow dev $VX_DEV
--
2.27.0

View file

@ -0,0 +1,81 @@
From e3da5872ed0cb8180eff30a133e586868411fde3 Mon Sep 17 00:00:00 2001
From: Aya Levin <ayal@mellanox.com>
Date: Wed, 11 Dec 2019 17:45:34 +0200
Subject: [PATCH] devlink: Print health reporter's dump time-stamp in a helper
function
Add pr_out_dump_reporter prefix to the helper function's name and
encapsulate the print in it.
Fixes: 2f1242efe9d0 ("devlink: Add devlink health show command")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit f678a2d08e9793fbd5996d206061b94aa3b8d88a)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
devlink/devlink.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index ebffa8c80ffef..592e774ea0324 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -6618,8 +6618,11 @@ static const char *health_state_name(uint8_t state)
}
}
-static void format_logtime(uint64_t time_ms, char *ts_date, char *ts_time)
+static void pr_out_dump_reporter_format_logtime(struct dl *dl, const struct nlattr *attr)
{
+ char dump_date[HEALTH_REPORTER_TIMESTAMP_FMT_LEN];
+ char dump_time[HEALTH_REPORTER_TIMESTAMP_FMT_LEN];
+ uint64_t time_ms = mnl_attr_get_u64(attr);
struct sysinfo s_info;
struct tm *info;
time_t now, sec;
@@ -6637,16 +6640,16 @@ static void format_logtime(uint64_t time_ms, char *ts_date, char *ts_time)
sec = now - s_info.uptime + time_ms / 1000;
info = localtime(&sec);
out:
- strftime(ts_date, HEALTH_REPORTER_TIMESTAMP_FMT_LEN, "%Y-%m-%d", info);
- strftime(ts_time, HEALTH_REPORTER_TIMESTAMP_FMT_LEN, "%H:%M:%S", info);
+ strftime(dump_date, HEALTH_REPORTER_TIMESTAMP_FMT_LEN, "%Y-%m-%d", info);
+ strftime(dump_time, HEALTH_REPORTER_TIMESTAMP_FMT_LEN, "%H:%M:%S", info);
+ pr_out_str(dl, "last_dump_date", dump_date);
+ pr_out_str(dl, "last_dump_time", dump_time);
}
static void pr_out_health(struct dl *dl, struct nlattr **tb_health)
{
struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
enum devlink_health_reporter_state state;
- const struct nlattr *attr;
- uint64_t time_ms;
int err;
err = mnl_attr_parse_nested(tb_health[DEVLINK_ATTR_HEALTH_REPORTER],
@@ -6674,17 +6677,8 @@ static void pr_out_health(struct dl *dl, struct nlattr **tb_health)
mnl_attr_get_u64(tb[DEVLINK_ATTR_HEALTH_REPORTER_ERR_COUNT]));
pr_out_u64(dl, "recover",
mnl_attr_get_u64(tb[DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT]));
- if (tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS]) {
- char dump_date[HEALTH_REPORTER_TIMESTAMP_FMT_LEN];
- char dump_time[HEALTH_REPORTER_TIMESTAMP_FMT_LEN];
-
- attr = tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS];
- time_ms = mnl_attr_get_u64(attr);
- format_logtime(time_ms, dump_date, dump_time);
-
- pr_out_str(dl, "last_dump_date", dump_date);
- pr_out_str(dl, "last_dump_time", dump_time);
- }
+ if (tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS])
+ pr_out_dump_reporter_format_logtime(dl, tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS]);
if (tb[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD])
pr_out_u64(dl, "grace_period",
mnl_attr_get_u64(tb[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD]));
--
2.27.0

View file

@ -0,0 +1,65 @@
From f4879d29863f0696de5673a4ca00b54523c831da Mon Sep 17 00:00:00 2001
From: Aya Levin <ayal@mellanox.com>
Date: Wed, 11 Dec 2019 17:45:35 +0200
Subject: [PATCH] devlink: Add a new time-stamp format for health reporter's
dump
Introduce a new attribute representing a new time-stamp format: current
time in ns (to comply with y2038) instead of jiffies. If the new
attribute was received, translate the time-stamp accordingly (ns).
Fixes: 2f1242efe9d0 ("devlink: Add devlink health show command")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 746b66b005782dc9621f4fc84d0a1859300a6d01)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
devlink/devlink.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 592e774ea0324..4a01b0a8f6b88 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -6646,6 +6646,25 @@ out:
pr_out_str(dl, "last_dump_time", dump_time);
}
+static void pr_out_dump_report_timestamp(struct dl *dl, const struct nlattr *attr)
+{
+ char dump_date[HEALTH_REPORTER_TIMESTAMP_FMT_LEN];
+ char dump_time[HEALTH_REPORTER_TIMESTAMP_FMT_LEN];
+ time_t tv_sec;
+ struct tm *tm;
+ uint64_t ts;
+
+ ts = mnl_attr_get_u64(attr);
+ tv_sec = ts / 1000000000;
+ tm = localtime(&tv_sec);
+
+ strftime(dump_date, HEALTH_REPORTER_TIMESTAMP_FMT_LEN, "%Y-%m-%d", tm);
+ strftime(dump_time, HEALTH_REPORTER_TIMESTAMP_FMT_LEN, "%H:%M:%S", tm);
+
+ pr_out_str(dl, "last_dump_date", dump_date);
+ pr_out_str(dl, "last_dump_time", dump_time);
+}
+
static void pr_out_health(struct dl *dl, struct nlattr **tb_health)
{
struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
@@ -6677,7 +6696,9 @@ static void pr_out_health(struct dl *dl, struct nlattr **tb_health)
mnl_attr_get_u64(tb[DEVLINK_ATTR_HEALTH_REPORTER_ERR_COUNT]));
pr_out_u64(dl, "recover",
mnl_attr_get_u64(tb[DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT]));
- if (tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS])
+ if (tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS_NS])
+ pr_out_dump_report_timestamp(dl, tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS_NS]);
+ else if (tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS])
pr_out_dump_reporter_format_logtime(dl, tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS]);
if (tb[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD])
pr_out_u64(dl, "grace_period",
--
2.27.0

View file

@ -0,0 +1,250 @@
From 7f80e4520b72a6063e5db3f4507ad9f8f90a9176 Mon Sep 17 00:00:00 2001
From: Aya Levin <ayal@mellanox.com>
Date: Wed, 11 Dec 2019 17:45:36 +0200
Subject: [PATCH] devlink: Fix fmsg nesting in non JSON output
When an object or an array opening follows a name (label), add a new
line and indentation before printing the label. When name (label) is
followed by a value, print both at the same line.
Prior to this patch nesting was not visible in a non JSON output:
JSON:
{
"Common config": {
"SQ": {
"stride size": 64,
"size": 1024
},
"CQ": {
"stride size": 64,
"size": 1024
} },
"SQs": [ {
"channel ix": 0,
"sqn": 10,
"HW state": 1,
"stopped": false,
"cc": 0,
"pc": 0,
"CQ": {
"cqn": 6,
"HW status": 0
}
},{
"channel ix": 0,
"sqn": 14,
"HW state": 1,
"stopped": false,
"cc": 0,
"pc": 0,
"CQ": {
"cqn": 10,
"HW status": 0
}
} ]
}
Before this patch:
Common Config: SQ: stride size: 64 size: 1024
CQ: stride size: 64 size: 1024
SQs:
channel ix: 0 tc: 0 txq ix: 0 sqn: 10 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 6 HW status: 0
channel ix: 1 tc: 0 txq ix: 1 sqn: 14 HW state: 1 stopped: false cc: 0 pc: 0 CQ: cqn: 10 HW status: 0
With this patch:
Common config:
SQ:
stride size: 64 size: 1024
CQ:
stride size: 64 size: 1024
SQs:
channel ix: 0 sqn: 10 HW state: 1 stopped: false cc: 0 pc: 0
CQ:
cqn: 6 HW status: 0
channel ix: 1 sqn: 14 HW state: 1 stopped: false cc: 0 pc: 0
CQ:
cqn: 10 HW status: 0
Fixes: 7b8baf834d5e ("devlink: Add devlink health diagnose command")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit af646bf95381964187d1128999c3265073609fe3)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
devlink/devlink.c | 106 ++++++++++++++++++++++++++++++++++++++--------
1 file changed, 88 insertions(+), 18 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 4a01b0a8f6b88..9bbc223c12973 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -6427,12 +6427,23 @@ static int fmsg_value_show(struct dl *dl, int type, struct nlattr *nl_data)
return MNL_CB_OK;
}
+static void pr_out_fmsg_name(struct dl *dl, char **name)
+{
+ if (!*name)
+ return;
+
+ pr_out_name(dl, *name);
+ free(*name);
+ *name = NULL;
+}
+
struct nest_entry {
int attr_type;
struct list_head list;
};
struct fmsg_cb_data {
+ char *name;
struct dl *dl;
uint8_t value_type;
struct list_head entry_list;
@@ -6462,6 +6473,56 @@ static int cmd_fmsg_nest_queue(struct fmsg_cb_data *fmsg_data,
return MNL_CB_OK;
}
+static void pr_out_fmsg_group_start(struct dl *dl, char **name)
+{
+ __pr_out_newline();
+ pr_out_fmsg_name(dl, name);
+ __pr_out_newline();
+ __pr_out_indent_inc();
+}
+
+static void pr_out_fmsg_group_end(struct dl *dl)
+{
+ __pr_out_newline();
+ __pr_out_indent_dec();
+}
+
+static void pr_out_fmsg_start_object(struct dl *dl, char **name)
+{
+ if (dl->json_output) {
+ pr_out_fmsg_name(dl, name);
+ jsonw_start_object(dl->jw);
+ } else {
+ pr_out_fmsg_group_start(dl, name);
+ }
+}
+
+static void pr_out_fmsg_end_object(struct dl *dl)
+{
+ if (dl->json_output)
+ jsonw_end_object(dl->jw);
+ else
+ pr_out_fmsg_group_end(dl);
+}
+
+static void pr_out_fmsg_start_array(struct dl *dl, char **name)
+{
+ if (dl->json_output) {
+ pr_out_fmsg_name(dl, name);
+ jsonw_start_array(dl->jw);
+ } else {
+ pr_out_fmsg_group_start(dl, name);
+ }
+}
+
+static void pr_out_fmsg_end_array(struct dl *dl)
+{
+ if (dl->json_output)
+ jsonw_end_array(dl->jw);
+ else
+ pr_out_fmsg_group_end(dl);
+}
+
static int cmd_fmsg_nest(struct fmsg_cb_data *fmsg_data, uint8_t nest_value,
bool start)
{
@@ -6476,26 +6537,17 @@ static int cmd_fmsg_nest(struct fmsg_cb_data *fmsg_data, uint8_t nest_value,
switch (value) {
case DEVLINK_ATTR_FMSG_OBJ_NEST_START:
if (start)
- pr_out_entry_start(dl);
+ pr_out_fmsg_start_object(dl, &fmsg_data->name);
else
- pr_out_entry_end(dl);
+ pr_out_fmsg_end_object(dl);
break;
case DEVLINK_ATTR_FMSG_PAIR_NEST_START:
break;
case DEVLINK_ATTR_FMSG_ARR_NEST_START:
- if (dl->json_output) {
- if (start)
- jsonw_start_array(dl->jw);
- else
- jsonw_end_array(dl->jw);
- } else {
- if (start) {
- __pr_out_newline();
- __pr_out_indent_inc();
- } else {
- __pr_out_indent_dec();
- }
- }
+ if (start)
+ pr_out_fmsg_start_array(dl, &fmsg_data->name);
+ else
+ pr_out_fmsg_end_array(dl);
break;
default:
return -EINVAL;
@@ -6533,12 +6585,16 @@ static int cmd_fmsg_object_cb(const struct nlmsghdr *nlh, void *data)
return err;
break;
case DEVLINK_ATTR_FMSG_OBJ_NAME:
- pr_out_name(dl, mnl_attr_get_str(nla_object));
+ free(fmsg_data->name);
+ fmsg_data->name = strdup(mnl_attr_get_str(nla_object));
+ if (!fmsg_data->name)
+ return -ENOMEM;
break;
case DEVLINK_ATTR_FMSG_OBJ_VALUE_TYPE:
fmsg_data->value_type = mnl_attr_get_u8(nla_object);
break;
case DEVLINK_ATTR_FMSG_OBJ_VALUE_DATA:
+ pr_out_fmsg_name(dl, &fmsg_data->name);
err = fmsg_value_show(dl, fmsg_data->value_type,
nla_object);
if (err != MNL_CB_OK)
@@ -6551,6 +6607,20 @@ static int cmd_fmsg_object_cb(const struct nlmsghdr *nlh, void *data)
return MNL_CB_OK;
}
+static void cmd_fmsg_init(struct dl *dl, struct fmsg_cb_data *data)
+{
+ /* FMSG is dynamic: opening of an object or array causes a
+ * newline. JSON starts with an { or [, but plain text should
+ * not start with a new line. Ensure this by setting
+ * g_new_line_count to 1: avoiding newline before the first
+ * print.
+ */
+ g_new_line_count = 1;
+ data->name = NULL;
+ data->dl = dl;
+ INIT_LIST_HEAD(&data->entry_list);
+}
+
static int cmd_health_object_common(struct dl *dl, uint8_t cmd, uint16_t flags)
{
struct fmsg_cb_data data;
@@ -6564,9 +6634,9 @@ static int cmd_health_object_common(struct dl *dl, uint8_t cmd, uint16_t flags)
if (err)
return err;
- data.dl = dl;
- INIT_LIST_HEAD(&data.entry_list);
+ cmd_fmsg_init(dl, &data);
err = _mnlg_socket_sndrcv(dl->nlg, nlh, cmd_fmsg_object_cb, &data);
+ free(data.name);
return err;
}
--
2.27.0

View file

@ -0,0 +1,45 @@
From 0b3206b57515ed544a4151bd05bb5fb02651bb1b Mon Sep 17 00:00:00 2001
From: Antony Antony <antony@phenome.org>
Date: Thu, 19 Dec 2019 15:18:03 +0100
Subject: [PATCH] ip: xfrm if_id -ve value is error
if_id is u32, error on -ve values instead of setting to 0
after :
ip link add ipsec1 type xfrm dev lo if_id -10
Error: argument "-10" is wrong: if_id value is invalid
before : note xfrm if_id 0
ip link add ipsec1 type xfrm dev lo if_id -10
ip -d link show dev ipsec1
9: ipsec1@lo: <NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/none 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 1500
xfrm if_id 0 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
Fixes: 286446c1e8c ("ip: support for xfrm interfaces")
Signed-off-by: Antony Antony <antony@phenome.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 2cf4d7af72e308fe40acef5788d1890b6b966035)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/link_xfrm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ip/link_xfrm.c b/ip/link_xfrm.c
index a28f308d56104..7dbfb13f88d68 100644
--- a/ip/link_xfrm.c
+++ b/ip/link_xfrm.c
@@ -37,7 +37,9 @@ static int xfrm_parse_opt(struct link_util *lu, int argc, char **argv,
exit(nodev(*argv));
} else if (!matches(*argv, "if_id")) {
NEXT_ARG();
- if (!get_u32(&if_id, *argv, 0))
+ if (get_u32(&if_id, *argv, 0))
+ invarg("if_id value is invalid", *argv);
+ else
addattr32(n, 1024, IFLA_XFRM_IF_ID, if_id);
} else {
xfrm_print_help(lu, argc, argv, stderr);
--
2.27.0

View file

@ -0,0 +1,43 @@
From dd3c87f75ca1ef88384ce3f0e301763569bba89f Mon Sep 17 00:00:00 2001
From: Leslie Monis <lesliemonis@gmail.com>
Date: Thu, 26 Dec 2019 00:34:18 +0530
Subject: [PATCH] tc: fq_codel: fix missing statistic in JSON output
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Print JSON object even if tc_fq_codel_xstats->class_stats.drop_next
is negative.
Cc: Toke Høiland-Jørgensen <toke@toke.dk>
Fixes: 997f2dc19378 ("tc: Add JSON output of fq_codel stats")
Signed-off-by: Leslie Monis <lesliemonis@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit e819d3a03dd19ed3dd0f50bd128f62f972e8240f)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
tc/q_fq_codel.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tc/q_fq_codel.c b/tc/q_fq_codel.c
index 376ac50da1a5d..d002940da6b78 100644
--- a/tc/q_fq_codel.c
+++ b/tc/q_fq_codel.c
@@ -275,12 +275,12 @@ static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f,
sprint_time(st->class_stats.ldelay, b1));
if (st->class_stats.dropping) {
print_bool(PRINT_ANY, "dropping", " dropping", true);
+ print_int(PRINT_JSON, "drop_next", NULL,
+ st->class_stats.drop_next);
if (st->class_stats.drop_next < 0)
print_string(PRINT_FP, NULL, " drop_next -%s",
sprint_time(-st->class_stats.drop_next, b1));
else {
- print_uint(PRINT_JSON, "drop_next", NULL,
- st->class_stats.drop_next);
print_string(PRINT_FP, NULL, " drop_next %s",
sprint_time(st->class_stats.drop_next, b1));
}
--
2.27.0

View file

@ -0,0 +1,59 @@
From 0b58868630b873209f0aed7116470174acdfa3f4 Mon Sep 17 00:00:00 2001
From: Vladis Dronov <vdronov@redhat.com>
Date: Sun, 19 Jan 2020 02:12:51 +0100
Subject: [PATCH] ip: fix link type and vlan oneline output
Move link type printing in print_linkinfo() so multiline output does not
break link options line. Add oneline support for vlan's ingress and egress
qos maps.
Before the fix:
5: veth90.4000@veth90: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 26:9a:05:af:db:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 0 maxmtu 65535
vlan protocol 802.1Q id 4000 <REORDER_HDR> the option line is broken ^^^
ingress-qos-map { 1:2 }
egress-qos-map { 2:1 } addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
5: veth90.4000@veth90: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000\ link/ether 26:9a:05:af:db:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 0 maxmtu 65535 \ vlan protocol 802.1Q id 4000 <REORDER_HDR>
ingress-qos-map { 1:2 } <<< a multiline output despite -oneline
egress-qos-map { 2:1 } addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
After the fix:
5: veth90.4000@veth90: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 26:9a:05:af:db:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 0 maxmtu 65535 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
vlan protocol 802.1Q id 4000 <REORDER_HDR>
ingress-qos-map { 1:2 }
egress-qos-map { 2:1 }
5: veth90.4000@veth90: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000\ link/ether 26:9a:05:af:db:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 0 maxmtu 65535 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 \ vlan protocol 802.1Q id 4000 <REORDER_HDR> \ ingress-qos-map { 1:2 } \ egress-qos-map { 2:1 }
Fixes: 5c302d518f10 ("vlan support")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206241
Reported-by: George Shuklin <george.shuklin@gmail.com>
Signed-off-by: Vladis Dronov <vdronov@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 970db267a0fb5036b28b2d9d4f53cb4be267ffd5)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/iplink_vlan.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ip/iplink_vlan.c b/ip/iplink_vlan.c
index 0dfb4a8d536ca..1e6817f5de3d2 100644
--- a/ip/iplink_vlan.c
+++ b/ip/iplink_vlan.c
@@ -183,7 +183,8 @@ static void vlan_print_map(FILE *f,
int rem;
open_json_array(PRINT_JSON, name_json);
- print_string(PRINT_FP, NULL, "\n %s { ", name_fp);
+ print_nl();
+ print_string(PRINT_FP, NULL, " %s { ", name_fp);
rem = RTA_PAYLOAD(attr);
for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
--
2.27.0

View file

@ -0,0 +1,101 @@
From f3f38b7d189675c37d04876b23ba6d38bbded5e1 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Wed, 29 Jan 2020 15:56:40 +0100
Subject: [PATCH] ip-xfrm: Fix help messages
After commit 8589eb4efdf2a ("treewide: refactor help messages") help
messages for xfrm state and policy are broken, printing many times the
same protocol in UPSPEC section:
$ ip xfrm state help
[...]
UPSPEC := proto { { tcp | tcp | tcp | tcp } [ sport PORT ] [ dport PORT ] |
{ icmp | icmp | icmp } [ type NUMBER ] [ code NUMBER ] |
gre [ key { DOTTED-QUAD | NUMBER } ] | PROTO }
This happens because strxf_proto function is non-reentrant and gets called
multiple times in the same fprintf instruction.
This commit fix the issue avoiding calls to strxf_proto() with a constant
param, just hardcoding strings for protocol names.
Fixes: 8589eb4efdf2a ("treewide: refactor help messages")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 38dd041bfe773e481ebf9c8250e49c665af2e215)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/xfrm_policy.c | 21 +++------------------
ip/xfrm_state.c | 24 +++---------------------
2 files changed, 6 insertions(+), 39 deletions(-)
diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
index 7c0233c182902..d3c706d3225f0 100644
--- a/ip/xfrm_policy.c
+++ b/ip/xfrm_policy.c
@@ -66,24 +66,9 @@ static void usage(void)
"Usage: ip xfrm policy count\n"
"Usage: ip xfrm policy set [ hthresh4 LBITS RBITS ] [ hthresh6 LBITS RBITS ]\n"
"SELECTOR := [ src ADDR[/PLEN] ] [ dst ADDR[/PLEN] ] [ dev DEV ] [ UPSPEC ]\n"
- "UPSPEC := proto { { ");
- fprintf(stderr, "%s | %s | %s | %s } ",
- strxf_proto(IPPROTO_TCP),
- strxf_proto(IPPROTO_UDP),
- strxf_proto(IPPROTO_SCTP),
- strxf_proto(IPPROTO_DCCP));
- fprintf(stderr,
- "[ sport PORT ] [ dport PORT ] |\n"
- " { %s | %s | %s } ",
- strxf_proto(IPPROTO_ICMP),
- strxf_proto(IPPROTO_ICMPV6),
- strxf_proto(IPPROTO_MH));
- fprintf(stderr,
- "[ type NUMBER ] [ code NUMBER ] |\n"
- " %s",
- strxf_proto(IPPROTO_GRE));
- fprintf(stderr,
- " [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
+ "UPSPEC := proto { { tcp | udp | sctp | dccp } [ sport PORT ] [ dport PORT ] |\n"
+ " { icmp | ipv6-icmp | mobility-header } [ type NUMBER ] [ code NUMBER ] |\n"
+ " gre [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
"DIR := in | out | fwd\n"
"PTYPE := main | sub\n"
"ACTION := allow | block\n"
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index b03ccc5807e90..7b413cd9b9a22 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -106,27 +106,9 @@ static void usage(void)
"EXTRA-FLAG-LIST := [ EXTRA-FLAG-LIST ] EXTRA-FLAG\n"
"EXTRA-FLAG := dont-encap-dscp\n"
"SELECTOR := [ src ADDR[/PLEN] ] [ dst ADDR[/PLEN] ] [ dev DEV ] [ UPSPEC ]\n"
- "UPSPEC := proto { { ");
- fprintf(stderr,
- "%s | %s | %s | %s",
- strxf_proto(IPPROTO_TCP),
- strxf_proto(IPPROTO_UDP),
- strxf_proto(IPPROTO_SCTP),
- strxf_proto(IPPROTO_DCCP));
- fprintf(stderr,
- " } [ sport PORT ] [ dport PORT ] |\n"
- " { ");
- fprintf(stderr,
- "%s | %s | %s",
- strxf_proto(IPPROTO_ICMP),
- strxf_proto(IPPROTO_ICMPV6),
- strxf_proto(IPPROTO_MH));
- fprintf(stderr,
- " } [ type NUMBER ] [ code NUMBER ] |\n");
- fprintf(stderr,
- " %s", strxf_proto(IPPROTO_GRE));
- fprintf(stderr,
- " [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
+ "UPSPEC := proto { { tcp | udp | sctp | dccp } [ sport PORT ] [ dport PORT ] |\n"
+ " { icmp | ipv6-icmp | mobility-header } [ type NUMBER ] [ code NUMBER ] |\n"
+ " gre [ key { DOTTED-QUAD | NUMBER } ] | PROTO }\n"
"LIMIT-LIST := [ LIMIT-LIST ] limit LIMIT\n"
"LIMIT := { time-soft | time-hard | time-use-soft | time-use-hard } SECONDS |\n"
" { byte-soft | byte-hard } SIZE | { packet-soft | packet-hard } COUNT\n"
--
2.27.0

View file

@ -0,0 +1,33 @@
From e7b786e573c31a2a2578cb6da37309828a469355 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Wed, 29 Jan 2020 15:31:11 +0100
Subject: [PATCH] ip link: xstats: fix TX IGMP reports string
This restore the string format we have before jsonification, adding a
missing space between v2 and v3 on TX IGMP reports string.
Fixes: a9bc23a79227a ("ip: bridge: add xstats json support")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 5cdeb77cd6ec26f0a7103dfb21494a6a43903206)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/iplink_bridge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
index 06f736d4dc710..868ea6e266ebe 100644
--- a/ip/iplink_bridge.c
+++ b/ip/iplink_bridge.c
@@ -742,7 +742,7 @@ static void bridge_print_stats_attr(struct rtattr *attr, int ifindex)
print_string(PRINT_FP, NULL, "%-16s ", "");
print_u64(PRINT_ANY, "tx_v1", "TX: v1 %llu ",
mstats->igmp_v1reports[BR_MCAST_DIR_TX]);
- print_u64(PRINT_ANY, "tx_v2", "v2 %llu",
+ print_u64(PRINT_ANY, "tx_v2", "v2 %llu ",
mstats->igmp_v2reports[BR_MCAST_DIR_TX]);
print_u64(PRINT_ANY, "tx_v3", "v3 %llu\n",
mstats->igmp_v3reports[BR_MCAST_DIR_TX]);
--
2.27.0

View file

@ -0,0 +1,46 @@
From 245ea7ad77e299a2aee98c6d91678f4243e08f40 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Sun, 2 Feb 2020 04:20:58 -0800
Subject: [PATCH] devlink: fix warning from unchecked write
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Warning seen on Ubuntu
devlink.c: In function cmd_dev_flash:
devlink.c:3071:3: warning: ignoring return value of write, declared with attribute warn_unused_result [-Wunused-result]
3071 | write(pipe_w, &err, sizeof(err));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixes: 9b13cddfe268 ("devlink: implement flash status monitoring")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 8f9f2b9cdfbd1c7988542d81db1db854d48f2b0d)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
devlink/devlink.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 9bbc223c12973..9d6a3cd14bc26 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -3074,11 +3074,13 @@ static int cmd_dev_flash(struct dl *dl)
/* In child, just execute the flash and pass returned
* value through pipe once it is done.
*/
+ int cc;
+
close(pipe_r);
err = _mnlg_socket_send(dl->nlg, nlh);
- write(pipe_w, &err, sizeof(err));
+ cc = write(pipe_w, &err, sizeof(err));
close(pipe_w);
- exit(0);
+ exit(cc != sizeof(err));
}
close(pipe_w);
--
2.27.0

View file

@ -0,0 +1,61 @@
From a17b512a6a706906b559a5b9a1b52507a976862b Mon Sep 17 00:00:00 2001
From: Xin Long <lucien.xin@gmail.com>
Date: Tue, 18 Feb 2020 11:50:20 +0800
Subject: [PATCH] erspan: set erspan_ver to 1 by default
Commit 289763626721 ("erspan: add erspan version II support")
breaks the command:
# ip link add erspan1 type erspan key 1 seq erspan 123 \
local 10.1.0.2 remote 10.1.0.1
as erspan_ver is set to 0 by default, then IFLA_GRE_ERSPAN_INDEX
won't be set in gre_parse_opt().
# ip -d link show erspan1
...
erspan remote 10.1.0.1 local 10.1.0.2 ... erspan_index 0 erspan_ver 1
^^^^^^^^^^^^^^
This patch is to change to set erspan_ver to 1 by default.
Fixes: 289763626721 ("erspan: add erspan version II support")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 83c543af872e38654326671f6b504257d98c4489)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/link_gre.c | 2 +-
ip/link_gre6.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ip/link_gre.c b/ip/link_gre.c
index 15beb737217e8..e42f21ae4556c 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -94,7 +94,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
__u8 metadata = 0;
__u32 fwmark = 0;
__u32 erspan_idx = 0;
- __u8 erspan_ver = 0;
+ __u8 erspan_ver = 1;
__u8 erspan_dir = 0;
__u16 erspan_hwid = 0;
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index 9d1741bff8a16..94a4ee700431c 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -106,7 +106,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
__u8 metadata = 0;
__u32 fwmark = 0;
__u32 erspan_idx = 0;
- __u8 erspan_ver = 0;
+ __u8 erspan_ver = 1;
__u8 erspan_dir = 0;
__u16 erspan_hwid = 0;
--
2.27.0

View file

@ -0,0 +1,48 @@
From 2e0e4bf6638fb7d24da17c4a09fc2a1df79579c5 Mon Sep 17 00:00:00 2001
From: Xin Long <lucien.xin@gmail.com>
Date: Mon, 24 Feb 2020 09:57:01 -0500
Subject: [PATCH] xfrm: not try to delete ipcomp states when using deleteall
In kernel space, ipcomp(sub) states used by main states are not
allowed to be deleted by users, they would be freed only when
all main states are destroyed and no one uses them.
In user space, ip xfrm sta deleteall doesn't filter these ipcomp
states out, and it causes errors:
# ip xfrm state add src 192.168.0.1 dst 192.168.0.2 spi 0x1000 \
proto comp comp deflate mode tunnel sel src 192.168.0.1 dst \
192.168.0.2 proto gre
# ip xfrm sta deleteall
Failed to send delete-all request
: Operation not permitted
This patch is to fix it by filtering ipcomp states with a check
xsinfo->id.proto == IPPROTO_IPIP.
Fixes: c7699875bee0 ("Import patch ipxfrm-20040707_2.diff")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit f9d696cf414c2c475764aa3b29cf288350f1e21f)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/xfrm_state.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index 7b413cd9b9a22..d014444e9af4f 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -1131,6 +1131,9 @@ static int xfrm_state_keep(struct nlmsghdr *n, void *arg)
if (!xfrm_state_filter_match(xsinfo))
return 0;
+ if (xsinfo->id.proto == IPPROTO_IPIP)
+ return 0;
+
if (xb->offset > xb->size) {
fprintf(stderr, "State buffer overflow\n");
return -1;
--
2.27.0

View file

@ -0,0 +1,41 @@
From 81bd99800256801a8cca965ff3689dbcd71a336f Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Tue, 10 Mar 2020 13:15:17 +0100
Subject: [PATCH] nexthop: fix error reporting in filter dump
nh_dump_filter is missing a return value check in two cases.
Fix this simply adding an assignment to the proper variable.
Fixes: 63df8e8543b03 ("Add support for nexthop objects")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit d9b868436a6fce8986560178c6d1a78072e21861)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/ipnexthop.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c
index 9f860c8cea251..99f89630ed189 100644
--- a/ip/ipnexthop.c
+++ b/ip/ipnexthop.c
@@ -59,13 +59,13 @@ static int nh_dump_filter(struct nlmsghdr *nlh, int reqlen)
}
if (filter.groups) {
- addattr_l(nlh, reqlen, NHA_GROUPS, NULL, 0);
+ err = addattr_l(nlh, reqlen, NHA_GROUPS, NULL, 0);
if (err)
return err;
}
if (filter.master) {
- addattr32(nlh, reqlen, NHA_MASTER, filter.master);
+ err = addattr32(nlh, reqlen, NHA_MASTER, filter.master);
if (err)
return err;
}
--
2.27.0

View file

@ -0,0 +1,121 @@
From 2ffe12bb7de9805d4ab2f0c0f9614d00f9f82dc2 Mon Sep 17 00:00:00 2001
From: Petr Machata <petrm@mellanox.com>
Date: Sat, 4 Apr 2020 01:55:34 +0300
Subject: [PATCH] ip: link_gre: Do not send ERSPAN attributes to GRE tunnels
In the commit referenced below, ip link started sending ERSPAN-specific
attributes even for GRE and gretap tunnels. Fix by more carefully
distinguishing between the GRE/tap and ERSPAN modes. Do not show
ERSPAN-related help in GRE/tap mode, likewise do not accept ERSPAN
arguments, or send ERSPAN attributes.
Fixes: 83c543af872e ("erspan: set erspan_ver to 1 by default")
Signed-off-by: Petr Machata <petrm@mellanox.com>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 20927e0525e0cca165cd1252ac18da07cb082c4d)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/link_gre.c | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/ip/link_gre.c b/ip/link_gre.c
index e42f21ae4556c..d616a970e9a28 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -23,8 +23,15 @@
#include "ip_common.h"
#include "tunnel.h"
+static bool gre_is_erspan(struct link_util *lu)
+{
+ return !strcmp(lu->id, "erspan");
+}
+
static void gre_print_help(struct link_util *lu, int argc, char **argv, FILE *f)
{
+ bool is_erspan = gre_is_erspan(lu);
+
fprintf(f,
"Usage: ... %-9s [ remote ADDR ]\n"
" [ local ADDR ]\n"
@@ -44,18 +51,20 @@ static void gre_print_help(struct link_util *lu, int argc, char **argv, FILE *f)
" [ encap-dport PORT ]\n"
" [ [no]encap-csum ]\n"
" [ [no]encap-csum6 ]\n"
- " [ [no]encap-remcsum ]\n"
- " [ erspan_ver version ]\n"
- " [ erspan IDX ]\n"
- " [ erspan_dir { ingress | egress } ]\n"
- " [ erspan_hwid hwid ]\n"
+ " [ [no]encap-remcsum ]\n", lu->id);
+ if (is_erspan)
+ fprintf(f,
+ " [ erspan_ver version ]\n"
+ " [ erspan IDX ]\n"
+ " [ erspan_dir { ingress | egress } ]\n"
+ " [ erspan_hwid hwid ]\n");
+ fprintf(f,
"\n"
"Where: ADDR := { IP_ADDRESS | any }\n"
" TOS := { NUMBER | inherit }\n"
" TTL := { 1..255 | inherit }\n"
" KEY := { DOTTED_QUAD | NUMBER }\n"
- " MARK := { 0x0..0xffffffff }\n",
- lu->id);
+ " MARK := { 0x0..0xffffffff }\n");
}
static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
@@ -93,6 +102,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
__u16 encapdport = 0;
__u8 metadata = 0;
__u32 fwmark = 0;
+ bool is_erspan = gre_is_erspan(lu);
__u32 erspan_idx = 0;
__u8 erspan_ver = 1;
__u8 erspan_dir = 0;
@@ -334,19 +344,19 @@ get_failed:
NEXT_ARG();
if (get_u32(&fwmark, *argv, 0))
invarg("invalid fwmark\n", *argv);
- } else if (strcmp(*argv, "erspan") == 0) {
+ } else if (is_erspan && strcmp(*argv, "erspan") == 0) {
NEXT_ARG();
if (get_u32(&erspan_idx, *argv, 0))
invarg("invalid erspan index\n", *argv);
if (erspan_idx & ~((1<<20) - 1) || erspan_idx == 0)
invarg("erspan index must be > 0 and <= 20-bit\n", *argv);
- } else if (strcmp(*argv, "erspan_ver") == 0) {
+ } else if (is_erspan && strcmp(*argv, "erspan_ver") == 0) {
NEXT_ARG();
if (get_u8(&erspan_ver, *argv, 0))
invarg("invalid erspan version\n", *argv);
if (erspan_ver != 1 && erspan_ver != 2)
invarg("erspan version must be 1 or 2\n", *argv);
- } else if (strcmp(*argv, "erspan_dir") == 0) {
+ } else if (is_erspan && strcmp(*argv, "erspan_dir") == 0) {
NEXT_ARG();
if (matches(*argv, "ingress") == 0)
erspan_dir = 0;
@@ -354,7 +364,7 @@ get_failed:
erspan_dir = 1;
else
invarg("Invalid erspan direction.", *argv);
- } else if (strcmp(*argv, "erspan_hwid") == 0) {
+ } else if (is_erspan && strcmp(*argv, "erspan_hwid") == 0) {
NEXT_ARG();
if (get_u16(&erspan_hwid, *argv, 0))
invarg("invalid erspan hwid\n", *argv);
@@ -402,7 +412,7 @@ get_failed:
addattr32(n, 1024, IFLA_GRE_LINK, link);
addattr_l(n, 1024, IFLA_GRE_TTL, &ttl, 1);
addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
- if (erspan_ver) {
+ if (is_erspan) {
addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
if (erspan_ver == 1 && erspan_idx != 0) {
addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
--
2.27.0

View file

@ -0,0 +1,33 @@
From 67a2a5552508a09f27f4e6206cb91e52fd07ded3 Mon Sep 17 00:00:00 2001
From: Benjamin Lee <ben@b1c1l1.com>
Date: Tue, 14 Apr 2020 21:11:12 -0700
Subject: [PATCH] tc: fq_codel: fix class stat deficit is signed int
The fq_codel class stat deficit is a signed int. This is a regression
from when JSON output was added.
Fixes: 997f2dc19378 ("tc: Add JSON output of fq_codel stats")
Signed-off-by: Benjamin Lee <ben@b1c1l1.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit f03ad792f3cdef5ade92392db6710441b35b47dd)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
tc/q_fq_codel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tc/q_fq_codel.c b/tc/q_fq_codel.c
index d002940da6b78..009eee42d4af9 100644
--- a/tc/q_fq_codel.c
+++ b/tc/q_fq_codel.c
@@ -263,7 +263,7 @@ static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f,
st->qdisc_stats.old_flows_len);
}
if (st->type == TCA_FQ_CODEL_XSTATS_CLASS) {
- print_uint(PRINT_ANY, "deficit", " deficit %u",
+ print_int(PRINT_ANY, "deficit", " deficit %d",
st->class_stats.deficit);
print_uint(PRINT_ANY, "count", " count %u",
st->class_stats.count);
--
2.27.0

View file

@ -0,0 +1,46 @@
From 297a05e145a4e7ab14b5391b369825ce0acd0c01 Mon Sep 17 00:00:00 2001
From: Xin Long <lucien.xin@gmail.com>
Date: Mon, 27 Apr 2020 15:14:24 +0800
Subject: [PATCH] xfrm: also check for ipv6 state in xfrm_state_keep
As commit f9d696cf414c ("xfrm: not try to delete ipcomp states when using
deleteall") does, this patch is to fix the same issue for ip6 state where
xsinfo->id.proto == IPPROTO_IPV6.
# ip xfrm state add src 2000::1 dst 2000::2 spi 0x1000 \
proto comp comp deflate mode tunnel sel src 2000::1 dst \
2000::2 proto gre
# ip xfrm sta deleteall
Failed to send delete-all request
: Operation not permitted
Note that the xsinfo->proto in common states can never be IPPROTO_IPV6.
Fixes: f9d696cf414c ("xfrm: not try to delete ipcomp states when using deleteall")
Reported-by: Xiumei Mu <xmu@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit d27fc6390ce32ecdba6324e22b1c341791c5c63f)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
ip/xfrm_state.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index d014444e9af4f..44f08ceed24dd 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -1131,7 +1131,8 @@ static int xfrm_state_keep(struct nlmsghdr *n, void *arg)
if (!xfrm_state_filter_match(xsinfo))
return 0;
- if (xsinfo->id.proto == IPPROTO_IPIP)
+ if (xsinfo->id.proto == IPPROTO_IPIP ||
+ xsinfo->id.proto == IPPROTO_IPV6)
return 0;
if (xb->offset > xb->size) {
--
2.27.0

View file

@ -0,0 +1,30 @@
From ac24381e460e944064f80999ad76f3e4e0528e08 Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Date: Fri, 1 May 2020 17:47:16 +0900
Subject: [PATCH] bridge: Fix typo
Fixes: 7abf5de677e3 ("bridge: vlan: add support to display per-vlan statistics")
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 91b1b49ed3934eb423308130bb3365a0afebf5af)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
bridge/vlan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bridge/vlan.c b/bridge/vlan.c
index 205851e4f78ec..24dffa1084014 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -546,7 +546,7 @@ static int vlan_show(int argc, char **argv, int subject)
ret = rtnl_dump_filter(&rth, print_vlan, &subject);
if (ret < 0) {
- fprintf(stderr, "Dump ternminated\n");
+ fprintf(stderr, "Dump terminated\n");
exit(1);
}
} else {
--
2.27.0

View file

@ -0,0 +1,210 @@
From 966466bb7b2d54f37516ff4a171fa3e2241b7381 Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Date: Fri, 1 May 2020 17:47:17 +0900
Subject: [PATCH] bridge: Fix output with empty vlan lists
Consider this configuration:
ip link add br0 type bridge
ip link add vx0 type vxlan dstport 4789 external
ip link set dev vx0 master br0
bridge vlan del vid 1 dev vx0
ip link add vx1 type vxlan dstport 4790 external
ip link set dev vx1 master br0
root@vsid:/src/iproute2# ./bridge/bridge vlan
port vlan-id
br0 1 PVID Egress Untagged
vx0 None
vx1 1 PVID Egress Untagged
root@vsid:/src/iproute2#
Note the useless and inconsistent empty lines.
root@vsid:/src/iproute2# ./bridge/bridge vlan tunnelshow
port vlan-id tunnel-id
br0
vx0 None
vx1
What's the difference between "None" and ""?
root@vsid:/src/iproute2# ./bridge/bridge -j -p vlan tunnelshow
[ {
"ifname": "br0",
"tunnels": [ ]
},{
"ifname": "vx1",
"tunnels": [ ]
} ]
Why does vx0 appear in normal output and not json output?
Why output an empty list for br0 and vx1?
Fix these inconsistencies and avoid outputting entries with no values. This
makes the behavior consistent with other iproute2 commands, for example
`ip -6 addr`: if an interface doesn't have any ipv6 addresses, it is not
part of the listing.
Fixes: 8652eeb3ab12 ("bridge: vlan: support for per vlan tunnel info")
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit b262a9becbcb9d0816b7953fd223dd9a7add8e12)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
bridge/vlan.c | 36 +++++++++++++-----------
testsuite/tests/bridge/vlan/show.t | 30 ++++++++++++++++++++
testsuite/tests/bridge/vlan/tunnelshow.t | 2 +-
3 files changed, 50 insertions(+), 18 deletions(-)
create mode 100755 testsuite/tests/bridge/vlan/show.t
diff --git a/bridge/vlan.c b/bridge/vlan.c
index 24dffa1084014..c1e28ba082b9e 100644
--- a/bridge/vlan.c
+++ b/bridge/vlan.c
@@ -290,8 +290,7 @@ static void print_vlan_tunnel_info(struct rtattr *tb, int ifindex)
int rem = RTA_PAYLOAD(list);
__u16 last_vid_start = 0;
__u32 last_tunid_start = 0;
-
- open_vlan_port(ifindex, "%s", VLAN_SHOW_TUNNELINFO);
+ bool opened = false;
for (i = RTA_DATA(list); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
struct rtattr *ttb[IFLA_BRIDGE_VLAN_TUNNEL_MAX+1];
@@ -331,13 +330,20 @@ static void print_vlan_tunnel_info(struct rtattr *tb, int ifindex)
else if (vcheck_ret == 0)
continue;
+ if (!opened) {
+ open_vlan_port(ifindex, "%s", VLAN_SHOW_TUNNELINFO);
+ opened = true;
+ }
+
open_json_object(NULL);
print_range("vlan", last_vid_start, tunnel_vid);
print_range("tunid", last_tunid_start, tunnel_id);
close_json_object();
print_string(PRINT_FP, NULL, "%s", _SL_);
}
- close_vlan_port();
+
+ if (opened)
+ close_vlan_port();
}
static int print_vlan(struct nlmsghdr *n, void *arg)
@@ -366,16 +372,8 @@ static int print_vlan(struct nlmsghdr *n, void *arg)
return 0;
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifm), len);
-
- /* if AF_SPEC isn't there, vlan table is not preset for this port */
- if (!tb[IFLA_AF_SPEC]) {
- if (!filter_vlan && !is_json_context()) {
- color_fprintf(stdout, COLOR_IFNAME, "%s",
- ll_index_to_name(ifm->ifi_index));
- fprintf(stdout, "\tNone\n");
- }
+ if (!tb[IFLA_AF_SPEC])
return 0;
- }
switch (*subject) {
case VLAN_SHOW_VLAN:
@@ -385,9 +383,7 @@ static int print_vlan(struct nlmsghdr *n, void *arg)
print_vlan_tunnel_info(tb[IFLA_AF_SPEC], ifm->ifi_index);
break;
}
- print_string(PRINT_FP, NULL, "%s", _SL_);
- fflush(stdout);
return 0;
}
@@ -588,8 +584,7 @@ void print_vlan_info(struct rtattr *tb, int ifindex)
struct rtattr *i, *list = tb;
int rem = RTA_PAYLOAD(list);
__u16 last_vid_start = 0;
-
- open_vlan_port(ifindex, "%s", VLAN_SHOW_VLAN);
+ bool opened = false;
for (i = RTA_DATA(list); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
struct bridge_vlan_info *vinfo;
@@ -608,6 +603,11 @@ void print_vlan_info(struct rtattr *tb, int ifindex)
else if (vcheck_ret == 0)
continue;
+ if (!opened) {
+ open_vlan_port(ifindex, "%s", VLAN_SHOW_VLAN);
+ opened = true;
+ }
+
open_json_object(NULL);
print_range("vlan", last_vid_start, vinfo->vid);
@@ -615,7 +615,9 @@ void print_vlan_info(struct rtattr *tb, int ifindex)
close_json_object();
print_string(PRINT_FP, NULL, "%s", _SL_);
}
- close_vlan_port();
+
+ if (opened)
+ close_vlan_port();
}
int do_vlan(int argc, char **argv)
diff --git a/testsuite/tests/bridge/vlan/show.t b/testsuite/tests/bridge/vlan/show.t
new file mode 100755
index 0000000000000..3def202226a47
--- /dev/null
+++ b/testsuite/tests/bridge/vlan/show.t
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+. lib/generic.sh
+
+ts_log "[Testing vlan show]"
+
+BR_DEV="$(rand_dev)"
+VX0_DEV="$(rand_dev)"
+VX1_DEV="$(rand_dev)"
+
+ts_ip "$0" "Add $BR_DEV bridge interface" link add $BR_DEV type bridge
+
+ts_ip "$0" "Add $VX0_DEV vxlan interface" \
+ link add $VX0_DEV type vxlan dstport 4789 external
+ts_ip "$0" "Enslave $VX0_DEV under $BR_DEV" \
+ link set dev $VX0_DEV master $BR_DEV
+ts_bridge "$0" "Delete default vlan from $VX0_DEV" \
+ vlan del dev $VX0_DEV vid 1
+ts_ip "$0" "Add $VX1_DEV vxlan interface" \
+ link add $VX1_DEV type vxlan dstport 4790 external
+ts_ip "$0" "Enslave $VX1_DEV under $BR_DEV" \
+ link set dev $VX1_DEV master $BR_DEV
+
+# Test that bridge ports without vlans do not appear in the output
+ts_bridge "$0" "Show vlan" vlan
+test_on_not "$VX0_DEV"
+
+# Test that bridge ports without tunnels do not appear in the output
+ts_bridge "$0" "Show vlan tunnel info" vlan tunnelshow
+test_lines_count 1 # header only
diff --git a/testsuite/tests/bridge/vlan/tunnelshow.t b/testsuite/tests/bridge/vlan/tunnelshow.t
index fd41bfcb32a2b..3e9c12a21a9cc 100755
--- a/testsuite/tests/bridge/vlan/tunnelshow.t
+++ b/testsuite/tests/bridge/vlan/tunnelshow.t
@@ -28,6 +28,6 @@ ts_bridge "$0" "Add tunnel with vni > 16k" \
ts_bridge "$0" "Show tunnel info" vlan tunnelshow dev $VX_DEV
test_on "1030\s+65556"
-test_lines_count 5
+test_lines_count 4
ts_bridge "$0" "Dump tunnel info" -j vlan tunnelshow dev $VX_DEV
--
2.27.0

View file

@ -0,0 +1,60 @@
From 79f92b4d8920686c2ca32431bdb8096bc9921d32 Mon Sep 17 00:00:00 2001
From: Roman Mashak <mrv@mojatatu.com>
Date: Tue, 19 May 2020 20:59:44 -0400
Subject: [PATCH] tc: action: fix time values output in JSON format
Report tcf_t values in seconds, not jiffies, in JSON format as it is now
for stdout.
v2: use PRINT_ANY, drop the useless casts and fix the style (Stephen Hemminger)
Fixes: 2704bd625583 ("tc: jsonify actions core")
Cc: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Roman Mashak <mrv@mojatatu.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit db35e411ec17bf9da67f22f995fe1e8d5edcda98)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
tc/tc_util.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 393721e33bf0e..18cde3ab86df1 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -745,21 +745,17 @@ void print_tm(FILE *f, const struct tcf_t *tm)
{
int hz = get_user_hz();
- if (tm->install != 0) {
- print_uint(PRINT_JSON, "installed", NULL, tm->install);
- print_uint(PRINT_FP, NULL, " installed %u sec",
- (unsigned int)(tm->install/hz));
- }
- if (tm->lastuse != 0) {
- print_uint(PRINT_JSON, "last_used", NULL, tm->lastuse);
- print_uint(PRINT_FP, NULL, " used %u sec",
- (unsigned int)(tm->lastuse/hz));
- }
- if (tm->expires != 0) {
- print_uint(PRINT_JSON, "expires", NULL, tm->expires);
- print_uint(PRINT_FP, NULL, " expires %u sec",
- (unsigned int)(tm->expires/hz));
- }
+ if (tm->install != 0)
+ print_uint(PRINT_ANY, "installed", " installed %u sec",
+ tm->install / hz);
+
+ if (tm->lastuse != 0)
+ print_uint(PRINT_ANY, "last_used", " used %u sec",
+ tm->lastuse / hz);
+
+ if (tm->expires != 0)
+ print_uint(PRINT_ANY, "expires", " expires %u sec",
+ tm->expires / hz);
}
static void print_tcstats_basic_hw(struct rtattr **tbs, char *prefix)
--
2.27.0

View file

@ -0,0 +1,337 @@
From b15ad0affd67e135680c99edc2eb5f178ab2c310 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Tue, 26 May 2020 18:04:10 +0200
Subject: [PATCH] Revert "bpf: replace snprintf with asprintf when dealing with
long buffers"
This reverts commit c0325b06382cb4f7ebfaf80c29c8800d74666fd9.
It introduces a segfault in bpf_make_custom_path() when custom pinning is used.
This happens because asprintf allocates exactly the space needed to hold a
string in the buffer passed as its first argument, but if this buffer is later
used in strcat() or similar we have a buffer overrun.
As the aim of commit c0325b06382c is simply to fix a compiler warning, it
seems safe and reasonable to revert it.
Fixes: c0325b06382c ("bpf: replace snprintf with asprintf when dealing with long buffers")
Reported-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 358abfe004a30bf3ed353c7f5dbc6afaf4212ecf)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
lib/bpf.c | 155 ++++++++++++++----------------------------------------
1 file changed, 39 insertions(+), 116 deletions(-)
diff --git a/lib/bpf.c b/lib/bpf.c
index 10cf9bf44419a..23cb0d96a85ba 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -406,21 +406,13 @@ 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 = NULL;
- char buff[4096];
+ char file[PATH_MAX], buff[4096];
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(map, 0, sizeof(*map));
fp = fopen(file, "r");
- free(file);
if (!fp) {
fprintf(stderr, "No procfs support?!\n");
return -EIO;
@@ -608,9 +600,8 @@ int bpf_trace_pipe(void)
0,
};
int fd_in, fd_out = STDERR_FILENO;
- char *tpipe = NULL;
+ char tpipe[PATH_MAX];
const char *mnt;
- int ret;
mnt = bpf_find_mntpt("tracefs", TRACEFS_MAGIC, tracefs_mnt,
sizeof(tracefs_mnt), tracefs_known_mnts);
@@ -619,15 +610,9 @@ int bpf_trace_pipe(void)
return -1;
}
- ret = asprintf(&tpipe, "%s/trace_pipe", mnt);
- if (ret < 0) {
- fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
- free(tpipe);
- return ret;
- }
+ snprintf(tpipe, sizeof(tpipe), "%s/trace_pipe", mnt);
fd_in = open(tpipe, O_RDONLY);
- free(tpipe);
if (fd_in < 0)
return -1;
@@ -648,50 +633,37 @@ int bpf_trace_pipe(void)
static int bpf_gen_global(const char *bpf_sub_dir)
{
- char *bpf_glo_dir = NULL;
+ char bpf_glo_dir[PATH_MAX];
int ret;
- 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;
- }
+ snprintf(bpf_glo_dir, sizeof(bpf_glo_dir), "%s/%s/",
+ bpf_sub_dir, BPF_DIR_GLOBALS);
ret = mkdir(bpf_glo_dir, S_IRWXU);
if (ret && errno != EEXIST) {
fprintf(stderr, "mkdir %s failed: %s\n", bpf_glo_dir,
strerror(errno));
- goto out;
+ return ret;
}
- ret = 0;
-out:
- free(bpf_glo_dir);
- return ret;
+ return 0;
}
static int bpf_gen_master(const char *base, const char *name)
{
- char *bpf_sub_dir = NULL;
+ char bpf_sub_dir[PATH_MAX + NAME_MAX + 1];
int ret;
- ret = asprintf(&bpf_sub_dir, "%s%s/", base, name);
- if (ret < 0) {
- fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
- goto out;
- }
+ snprintf(bpf_sub_dir, sizeof(bpf_sub_dir), "%s%s/", base, name);
ret = mkdir(bpf_sub_dir, S_IRWXU);
if (ret && errno != EEXIST) {
fprintf(stderr, "mkdir %s failed: %s\n", bpf_sub_dir,
strerror(errno));
- goto out;
+ return ret;
}
- ret = bpf_gen_global(bpf_sub_dir);
-out:
- free(bpf_sub_dir);
- return ret;
+ return bpf_gen_global(bpf_sub_dir);
}
static int bpf_slave_via_bind_mnt(const char *full_name,
@@ -720,22 +692,13 @@ 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 = NULL;
- char *bpf_sub_dir = NULL;
+ char bpf_lnk_dir[PATH_MAX + NAME_MAX + 1];
+ char bpf_sub_dir[PATH_MAX + NAME_MAX];
struct stat sb = {};
int ret;
- 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;
- }
+ 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 = symlink(bpf_lnk_dir, bpf_sub_dir);
if (ret) {
@@ -743,30 +706,25 @@ 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));
- goto out;
+ return ret;
}
- ret = bpf_slave_via_bind_mnt(bpf_sub_dir, bpf_lnk_dir);
- goto out;
+ return bpf_slave_via_bind_mnt(bpf_sub_dir,
+ bpf_lnk_dir);
}
ret = lstat(bpf_sub_dir, &sb);
if (ret) {
fprintf(stderr, "lstat %s failed: %s\n",
bpf_sub_dir, strerror(errno));
- goto out;
+ return ret;
}
- if ((sb.st_mode & S_IFMT) != S_IFLNK) {
- ret = bpf_gen_global(bpf_sub_dir);
- goto out;
- }
+ if ((sb.st_mode & S_IFMT) != S_IFLNK)
+ return bpf_gen_global(bpf_sub_dir);
}
-out:
- free(bpf_lnk_dir);
- free(bpf_sub_dir);
- return ret;
+ return 0;
}
static int bpf_gen_hierarchy(const char *base)
@@ -784,7 +742,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;
+ static char bpf_wrk_dir[PATH_MAX];
static const char *mnt;
static bool bpf_mnt_cached;
const char *mnt_env = getenv(BPF_ENV_MNT);
@@ -823,12 +781,7 @@ static const char *bpf_get_work_dir(enum bpf_prog_type type)
}
}
- ret = asprintf(&bpf_wrk_dir, "%s/", mnt);
- if (ret < 0) {
- fprintf(stderr, "asprintf failed: %s\n", strerror(errno));
- free(bpf_wrk_dir);
- goto out;
- }
+ snprintf(bpf_wrk_dir, sizeof(bpf_wrk_dir), "%s/", mnt);
ret = bpf_gen_hierarchy(bpf_wrk_dir);
if (ret) {
@@ -1485,48 +1438,31 @@ 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 = NULL;
+ char tmp[PATH_MAX];
int ret;
- 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;
- }
+ snprintf(tmp, sizeof(tmp), "%s/%s", bpf_get_work_dir(ctx->type),
+ ctx->obj_uid);
ret = mkdir(tmp, S_IRWXU);
if (ret && errno != EEXIST) {
fprintf(stderr, "mkdir %s failed: %s\n", tmp, strerror(errno));
- goto out;
+ return ret;
}
- ret = 0;
-out:
- free(tmp);
- return ret;
+ return 0;
}
static int bpf_make_custom_path(const struct bpf_elf_ctx *ctx,
const char *todo)
{
- char *tmp = NULL;
- char *rem = NULL;
- char *sub;
+ char tmp[PATH_MAX], rem[PATH_MAX], *sub;
int ret;
- 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;
- }
-
+ snprintf(tmp, sizeof(tmp), "%s/../", bpf_get_work_dir(ctx->type));
+ snprintf(rem, sizeof(rem), "%s/", todo);
sub = strtok(rem, "/");
+
while (sub) {
if (strlen(tmp) + strlen(sub) + 2 > PATH_MAX)
return -EINVAL;
@@ -1538,17 +1474,13 @@ 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));
- goto out;
+ return ret;
}
sub = strtok(NULL, "/");
}
- ret = 0;
-out:
- free(rem);
- free(tmp);
- return ret;
+ return 0;
}
static int bpf_place_pinned(int fd, const char *name,
@@ -2655,23 +2587,14 @@ struct bpf_jited_aux {
static int bpf_derive_prog_from_fdinfo(int fd, struct bpf_prog_data *prog)
{
- char *file = NULL;
- char buff[4096];
+ char file[PATH_MAX], 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.27.0

View file

@ -0,0 +1,49 @@
From 69986423a0df3a5613697b37a2f1fb6c6fd100c0 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Tue, 26 May 2020 18:04:11 +0200
Subject: [PATCH] bpf: Fixes a snprintf truncation warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
gcc v9.3.1 reports:
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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this simply checking snprintf return code and properly handling the error.
Fixes: e42256699cac ("bpf: make tc's bpf loader generic and move into lib")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 354efaec3895f004382414f2df17e7d820e695f6)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
lib/bpf.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/bpf.c b/lib/bpf.c
index 23cb0d96a85ba..c7d45077c14e5 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -781,7 +781,11 @@ static const char *bpf_get_work_dir(enum bpf_prog_type type)
}
}
- snprintf(bpf_wrk_dir, sizeof(bpf_wrk_dir), "%s/", mnt);
+ ret = snprintf(bpf_wrk_dir, sizeof(bpf_wrk_dir), "%s/", mnt);
+ if (ret < 0 || ret >= sizeof(bpf_wrk_dir)) {
+ mnt = NULL;
+ goto out;
+ }
ret = bpf_gen_hierarchy(bpf_wrk_dir);
if (ret) {
--
2.27.0

View file

@ -0,0 +1,41 @@
From f2b6f619af8ebc693c7b0c0abc52b6943800ffe9 Mon Sep 17 00:00:00 2001
From: Brian Vazquez <brianvv@google.com>
Date: Wed, 4 Dec 2019 13:32:28 -0800
Subject: [PATCH] ss: fix end-of-line printing in misc/ss.c
The previous change to ss to show header broke the printing of
end-of-line for the last entry.
Tested:
diff <(./ss.old -nltp) <(misc/ss -nltp)
38c38
< LISTEN 0 128 [::1]:35417 [::]:* users:(("foo",pid=65254,fd=116))
\ No newline at end of file
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
(cherry picked from commit 9eee92a41ae630b2c9e92ae2875ca56801c96b73)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
misc/ss.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/misc/ss.c b/misc/ss.c
index 794c1895c078e..bd55977ef8592 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1289,6 +1289,11 @@ static void render(void)
token = buf_token_next(token);
}
+ /* Deal with final end-of-line when the last non-empty field printed
+ * is not the last field.
+ */
+ if (line_started)
+ printf("\n");
buf_free_all();
current_field = columns;
--
2.27.0

View file

@ -1,20 +1,43 @@
%global cbq_version v0.7.3
Summary: Advanced IP routing and network device configuration tools
Name: iproute
Version: 5.2.0
Version: 5.4.0
Release: 2%{?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-devlink-allow-full-range-of-resource-sizes.patch
Patch2: 0002-tc-fix-warning-in-tc-m_ct.c.patch
Patch3: 0003-tc-fix-warning-in-tc-q_pie.c.patch
Patch4: 0004-json_print-Remove-declaration-without-implementation.patch
Patch5: 0005-testsuite-Fix-line-count-test.patch
Patch6: 0006-bridge-Fix-typo-in-error-messages.patch
Patch7: 0007-bridge-Fix-src_vni-argument-in-man-page.patch
Patch8: 0008-bridge-Fix-BRIDGE_VLAN_TUNNEL-attribute-sizes.patch
Patch9: 0009-bridge-Fix-vni-printing.patch
Patch10: 0010-bridge-Deduplicate-vlan-show-functions.patch
Patch11: 0011-bridge-Fix-tunnelshow-json-output.patch
Patch12: 0012-devlink-Print-health-reporter-s-dump-time-stamp-in-a.patch
Patch13: 0013-devlink-Add-a-new-time-stamp-format-for-health-repor.patch
Patch14: 0014-devlink-Fix-fmsg-nesting-in-non-JSON-output.patch
Patch15: 0015-ip-xfrm-if_id-ve-value-is-error.patch
Patch16: 0016-tc-fq_codel-fix-missing-statistic-in-JSON-output.patch
Patch17: 0017-ip-fix-link-type-and-vlan-oneline-output.patch
Patch18: 0018-ip-xfrm-Fix-help-messages.patch
Patch19: 0019-ip-link-xstats-fix-TX-IGMP-reports-string.patch
Patch20: 0020-devlink-fix-warning-from-unchecked-write.patch
Patch21: 0021-erspan-set-erspan_ver-to-1-by-default.patch
Patch22: 0022-xfrm-not-try-to-delete-ipcomp-states-when-using-dele.patch
Patch23: 0023-nexthop-fix-error-reporting-in-filter-dump.patch
Patch24: 0024-ip-link_gre-Do-not-send-ERSPAN-attributes-to-GRE-tun.patch
Patch25: 0025-tc-fq_codel-fix-class-stat-deficit-is-signed-int.patch
Patch26: 0026-xfrm-also-check-for-ipv6-state-in-xfrm_state_keep.patch
Patch27: 0027-bridge-Fix-typo.patch
Patch28: 0028-bridge-Fix-output-with-empty-vlan-lists.patch
Patch29: 0029-tc-action-fix-time-values-output-in-JSON-format.patch
Patch30: 0030-Revert-bpf-replace-snprintf-with-asprintf-when-deali.patch
Patch31: 0031-bpf-Fixes-a-snprintf-truncation-warning.patch
Patch32: 0032-ss-fix-end-of-line-printing-in-misc-ss.c.patch
License: GPLv2+ and Public Domain
BuildRequires: gcc
@ -34,6 +57,8 @@ BuildRequires: linux-atm-libs-devel
%endif
Provides: /sbin/ip
Recommends: %{name}-tc
Requires: psmisc
Obsoletes: iproute-doc < %{version}-%{release}
%description
The iproute package contains networking utilities (ip and rtmon, for example)
@ -51,15 +76,6 @@ The Traffic Control utility manages queueing disciplines, their classes and
attached filters and actions. It is the standard tool to configure QoS in
Linux.
%if ! 0%{?_module_build}
%package doc
Summary: Documentation for iproute2 utilities with examples
License: GPLv2+
%description doc
The iproute documentation contains howtos and examples of settings.
%endif
%package devel
Summary: iproute development files
License: GPLv2+
@ -96,7 +112,7 @@ install -D -m644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
%dir %{_sysconfdir}/iproute2
%{!?_licensedir:%global license %%doc}
%license COPYING
%doc README README.distribution README.lnstat
%doc README
%{_mandir}/man7/*
%exclude %{_mandir}/man7/tc-*
%{_mandir}/man8/*
@ -108,7 +124,6 @@ install -D -m644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
%files tc
%{!?_licensedir:%global license %%doc}
%license COPYING
%doc README.iproute2+tc
%{_mandir}/man7/tc-*
%{_mandir}/man8/tc*
%dir %{_libdir}/tc/
@ -116,13 +131,6 @@ install -D -m644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
%{_sbindir}/tc
%{_datadir}/bash-completion/completions/tc
%if ! 0%{?_module_build}
%files doc
%{!?_licensedir:%global license %%doc}
%license COPYING
%doc %{_docdir}/examples
%endif
%files devel
%{!?_licensedir:%global license %%doc}
%license COPYING
@ -132,6 +140,19 @@ install -D -m644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
%{_includedir}/iproute2/bpf_elf.h
%changelog
* Thu Aug 20 22:26:17 GMT 2020 Phil Sutter <psutter@redhat.com> - 5.4.0-2
- Add further upstream-suggested backports
- Fix for missing newline in last line of ss output
* Tue Jan 28 2020 Phil Sutter <psutter@redhat.com> - 5.4.0-1
- Rebase package on top of iproute2-5.4.0
- Add psmisc dependency, ifcfg script uses killall
- Drop iproute-doc package, upstream removed all non-manpage documentation
* 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.4.0.tar.xz) = 26d1230e10d9ba4466edd3fe95cb6f595df691eeb27b87ae845ceb9da09fe11c2e0daa8d67187121320413f9ee7131fd426182055eb285be7c4de558d9e47051