[PATCH iproute2-next 2/9] dcb: Plug a leaking DCB socket buffer

2020-12-23 Thread Petr Machata
DCB socket buffer is allocated in dcb_init(), but never freed(). Free it in dcb_fini(). Signed-off-by: Petr Machata --- dcb/dcb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dcb/dcb.c b/dcb/dcb.c index f5c62790e27e..0e3c87484f2a 100644 --- a/dcb/dcb.c +++ b/dcb/dcb.c @@ -38,6 +38,7

[PATCH iproute2-next 6/9] dcb: Generalize dcb_get_attribute()

2020-12-23 Thread Petr Machata
() as a thin wrapper for IEEE-nested access, and dcb_get_attribute_bare() for access to attributes that are not nested. Rewrite dcb_get_attribute() in terms of the new dcb_get_attribute_va(). Signed-off-by: Petr Machata --- dcb/dcb.c | 79 --- dcb

[PATCH iproute2-next 7/9] dcb: Support -n to suppress translation to nice names

2020-12-23 Thread Petr Machata
Some DSCP values can be translated to symbolic names. That may not be always desirable. Introduce a command-line option similar to other tools, -n or --no-nice-names, to suppress this translation. Signed-off-by: Petr Machata --- dcb/dcb.c | 9 +++-- dcb/dcb.h | 1 + man/man8/dcb.8

[PATCH net] net: dcb: Validate netlink message in DCB handler

2020-12-22 Thread Petr Machata
o the kernel and ixgbe driver") Signed-off-by: Petr Machata --- net/dcb/dcbnl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c index 084e159a12ba..7d49b6fd6cef 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c @@ -1765,6 +1765,8 @@ static int dcb_d

[PATCH iproute2-next 02/10] dcb: ets: Fix help display for "show" subcommand

2020-12-10 Thread Petr Machata
"dcb ets show dev X help" currently shows full "ets" help instead of just help for the show command. Fix it. Signed-off-by: Petr Machata --- dcb/dcb_ets.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dcb/dcb_ets.c b/dcb/dcb_ets.c index 173588

[PATCH iproute2-next 09/10] dcb: Add a subtool for the DCB buffer object

2020-12-10 Thread Petr Machata
6:6 7:0 buffer-size 0:1 1:0 2:0 3:7 4:0 5:0 6:1 7:0 total-size 221072 Signed-off-by: Petr Machata --- dcb/Makefile | 2 +- dcb/dcb.c | 4 +- dcb/dcb.h | 4 + dcb/dcb_buffer.c | 235 ++ man

[PATCH iproute2-next 03/10] dcb: ets: Change the way show parameters are given in synopsis

2020-12-10 Thread Petr Machata
None, one, or many parameters can be given on the command line, but the current synopsis allows only none or one. Fix it. Signed-off-by: Petr Machata --- dcb/dcb_ets.c | 6 +++--- man/man8/dcb-ets.8 | 13 ++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/dcb

[PATCH iproute2-next 00/10] dcb: Support PFC, buffer, maxrate objects

2020-12-10 Thread Petr Machata
Patches #6 and #7 add support for command line arguments -s and -i. These enable, respectively, display of statistical counters, and ISO/IEC mode of rate units. Patches #8-#10 add the subtools themselves and their man pages. Petr Machata (10): dcb: Remove unsupported command line arguments from g

[PATCH iproute2-next 10/10] dcb: Add a subtool for the DCB maxrate object

2020-12-10 Thread Petr Machata
0:25Gbit 1:25Gbit 2:25Gbit 3:25Gbit 4:25Gbit 5:25Gbit 6:100Gbit 7:25Gbit Signed-off-by: Petr Machata --- dcb/Makefile | 2 +- dcb/dcb.c | 4 +- dcb/dcb.h | 4 + dcb/dcb_maxrate.c | 182 + man/man8/dcb-maxrate

[PATCH iproute2-next 04/10] man: dcb-ets: Remove an unnecessary empty line

2020-12-10 Thread Petr Machata
Signed-off-by: Petr Machata --- man/man8/dcb-ets.8 | 1 - 1 file changed, 1 deletion(-) diff --git a/man/man8/dcb-ets.8 b/man/man8/dcb-ets.8 index 1ef0948fb062..9c64b33e30ff 100644 --- a/man/man8/dcb-ets.8 +++ b/man/man8/dcb-ets.8 @@ -61,7 +61,6 @@ the DCB (Data Center Bridging) subsystem .ti

[PATCH iproute2-next 05/10] dcb: Add dcb_set_u32(), dcb_set_u64()

2020-12-10 Thread Petr Machata
The DCB buffer object has a settable array of 32-bit quantities, and the maxrate object of 64-bit ones. Adjust dcb_parse_mapping() and related helpers to support 64-bit values in mappings, and add appropriate helpers. Signed-off-by: Petr Machata --- dcb/dcb.c | 22 ++ dcb

[PATCH iproute2-next 01/10] dcb: Remove unsupported command line arguments from getopt_long()

2020-12-10 Thread Petr Machata
getopt_long() currently includes "c" and "n" in the short option string. These probably slipped in as a cut'n'paste, and are not actually accepted. Remove them. Signed-off-by: Petr Machata --- dcb/dcb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH iproute2-next 07/10] dcb: Add -i to enable IEC mode

2020-12-10 Thread Petr Machata
Allow switching "dcb" into the ISO/IEC mode of units by passing -i. Signed-off-by: Petr Machata --- dcb/dcb.c | 10 +++--- dcb/dcb.h | 1 + man/man8/dcb.8 | 5 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dcb/dcb.c b/dcb/dcb.c index 93

[PATCH iproute2-next 06/10] dcb: Add -s to enable statistics

2020-12-10 Thread Petr Machata
Allow selective display of statistical counters by passing -s. Signed-off-by: Petr Machata --- dcb/dcb.c | 9 +++-- dcb/dcb.h | 1 + man/man8/dcb.8 | 5 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dcb/dcb.c b/dcb/dcb.c index 7c0beee43686..9332a8b2e3d4

[PATCH iproute2-next 08/10] dcb: Add a subtool for the DCB PFC object

2020-12-10 Thread Petr Machata
-bypass on delay 0 pg-pfc 0:off 1:on 2:off 3:off 4:off 5:off 6:off 7:on requests 0:0 1:217 2:0 3:0 4:0 5:0 6:0 7:28 indications 0:0 1:179 2:0 3:0 4:0 5:0 6:0 7:18 Signed-off-by: Petr Machata --- dcb/Makefile | 2 +- dcb/dcb.c | 27 - dcb/dcb.h | 6 + dcb

[PATCH iproute2-next v2 7/7] lib: Move get_size() from tc here

2020-12-05 Thread Petr Machata
The function get_size() serves for parsing of sizes using a handly notation that supports units and their prefixes, such as 10Kbit. This will be useful for the DCB buffer size parsing. Move the function from TC to the general library, so that it can be reused. Signed-off-by: Petr Machata

[PATCH iproute2-next v2 0/7] Move rate and size parsing and output to lib

2020-12-05 Thread Petr Machata
sprint_size() function. Petr Machata (7): Move the use_iec declaration to the tools lib: Move print_rate() from tc here; modernize lib: Move sprint_size() from tc here, add print_size() lib: sprint_size(): Uncrustify the code a bit lib: print_color_rate(): Fix formatting small rates in IEC

[PATCH iproute2-next v2 3/7] lib: Move sprint_size() from tc here, add print_size()

2020-12-05 Thread Petr Machata
number, without human-readable frills. - q_cake, which relies on the existence of sprint_size() in its macro-based formatting helpers. There might be ways to convert this particular case, but given q_tbf simply cannot be converted, leave it as is. Signed-off-by: Petr Machata --- inclu

[PATCH iproute2-next v2 2/7] lib: Move print_rate() from tc here; modernize

2020-12-05 Thread Petr Machata
just uses print_rate(). Signed-off-by: Petr Machata --- Notes: v2: - Adapt q_mqprio.c patch, the file changed since v1. include/json_print.h | 10 ++ lib/json_print.c | 32 tc/m_police.c| 9 - tc/q_cake.c | 28

[PATCH iproute2-next v2 5/7] lib: print_color_rate(): Fix formatting small rates in IEC mode

2020-12-05 Thread Petr Machata
string, formatting 1Kbit in IEC mode as "1000ibit". Fix by omitting the letter if there is no prefix. Signed-off-by: Petr Machata --- lib/json_print.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/json_print.c b/lib/json_print.c index d28e957c9603..b0861

[PATCH iproute2-next v2 6/7] lib: Move get_rate(), get_rate64() from tc here

2020-12-05 Thread Petr Machata
The functions get_rate() and get_rate64() are useful for parsing rate-like values. The DCB tool will find these useful in the maxrate subtool. Move them over to lib so that they can be easily reused. Signed-off-by: Petr Machata --- include/utils.h | 2 ++ lib/utils.c | 79

[PATCH iproute2-next v2 4/7] lib: sprint_size(): Uncrustify the code a bit

2020-12-05 Thread Petr Machata
Ideally this and the rate printing would both be converted to a common helper, but unfortunately the two format differently and this would break tests and scripts out there. So just make the code look less like a wad of hay. Signed-off-by: Petr Machata --- Notes: v2: - This patch is new

[PATCH iproute2-next v2 1/7] Move the use_iec declaration to the tools

2020-12-05 Thread Petr Machata
"tc", but is nonetheless declared in util.h. Instead, move the declaration to tool-specific headers ip/ip_common.h and tc/tc_common.h. Signed-off-by: Petr Machata --- include/utils.h | 1 - ip/ip_common.h | 2 ++ tc/tc_common.h | 1 + 3 files changed, 3 insertions(+), 1 deletion

Re: [PATCH iproute2-next] Only compile mnl_utils when HAVE_LIBMNL is defined

2020-12-03 Thread Petr Machata
David Ahern writes: > diff --git a/lib/Makefile b/lib/Makefile > index e37585c6..603ea83e 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -13,7 +13,10 @@ UTILOBJ += bpf_libbpf.o > endif > endif > > -NLOBJ=libgenl.o libnetlink.o mnl_utils.o > +NLOBJ=libgenl.o libnetlink.o > +ifeq ($(HA

Re: [PATCH iproute2-next 2/6] lib: Move print_rate() from tc here; modernize

2020-12-01 Thread Petr Machata
Stephen Hemminger writes: >> +int print_color_rate(bool use_iec, enum output_type t, enum color_attr >> color, >> + const char *key, const char *fmt, unsigned long long rate); >> + >> +static inline int print_rate(bool use_iec, enum output_type t, >> + c

Re: [PATCH iproute2-next 3/6] lib: Move sprint_size() from tc here, add print_size()

2020-12-01 Thread Petr Machata
Stephen Hemminger writes: > On Mon, 30 Nov 2020 23:59:39 +0100 > Petr Machata wrote: > >> +char *sprint_size(__u32 sz, char *buf) >> +{ >> +size_t len = SPRINT_BSIZE - 1; >> +double tmp = sz; >> + >> +if (sz >= 1024*1024 &&am

Re: [PATCH 3/5] tc: fix compiler warnings in ip6 pedit

2020-11-30 Thread Petr Machata
irectly. > > Fixes: 2d9a8dc439ee ("tc: p_ip6: Support pedit of IPv6 dsfield") > Cc: pe...@mellanox.com > Signed-off-by: Stephen Hemminger Reviewed-by: Petr Machata

[PATCH iproute2-next 3/6] lib: Move sprint_size() from tc here, add print_size()

2020-11-30 Thread Petr Machata
number, without human-readable frills. - q_cake, which relies on the existence of sprint_size() in its macro-based formatting helpers. There might be ways to convert this particular case, but given q_tbf simply cannot be converted, leave it as is. Signed-off-by: Petr Machata --- inclu

[PATCH iproute2-next 6/6] lib: print_rate(): Fix formatting small rates in IEC mode

2020-11-30 Thread Petr Machata
string, formatting 1Kbit in IEC mode as "1000ibit". Fix by omitting the letter if there is no prefix. Signed-off-by: Petr Machata --- lib/json_print.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/json_print.c b/lib/json_print.c index c1df637642fd..625a9

[PATCH iproute2-next 4/6] lib: Move get_rate(), get_rate64() from tc here

2020-11-30 Thread Petr Machata
The functions get_rate() and get_rate64() are useful for parsing rate-like values. The DCB tool will find these useful in the maxrate subtool. Move them over to lib so that they can be easily reused. Signed-off-by: Petr Machata --- include/utils.h | 2 ++ lib/utils.c | 79

[PATCH iproute2-next 2/6] lib: Move print_rate() from tc here; modernize

2020-11-30 Thread Petr Machata
just uses print_rate(). Signed-off-by: Petr Machata --- include/json_print.h | 10 ++ lib/json_print.c | 32 tc/m_police.c| 9 - tc/q_cake.c | 28 tc/q_cbq.c | 14 -- tc/q_fq.c

[PATCH iproute2-next 1/6] Move the use_iec declaration to the tools

2020-11-30 Thread Petr Machata
"tc", but is nonetheless declared in util.h. Instead, move the declaration to tool-specific headers ip/ip_common.h and tc/tc_common.h. Signed-off-by: Petr Machata --- include/utils.h | 1 - ip/ip_common.h | 2 ++ tc/tc_common.h | 1 + 3 files changed, 3 insertions(+), 1 deletion

[PATCH iproute2-next 0/6] Move rate and size parsing and output to lib

2020-11-30 Thread Petr Machata
objects that will make use of them. Petr Machata (6): Move the use_iec declaration to the tools lib: Move print_rate() from tc here; modernize lib: Move sprint_size() from tc here, add print_size() lib: Move get_rate(), get_rate64() from tc here lib: Move get_size() from tc here lib

[PATCH iproute2-next 5/6] lib: Move get_size() from tc here

2020-11-30 Thread Petr Machata
The function get_size() serves for parsing of sizes using a handly notation that supports units and their prefixes, such as 10Kbit. This will be useful for the DCB buffer size parsing. Move the function from TC to the general library, so that it can be reused. Signed-off-by: Petr Machata

[PATCH iproute2-next 2/7] bridge: link: Convert to use print_on_off()

2020-11-14 Thread Petr Machata
Instead of rolling a custom on-off printer, use the one added to utils.c. Signed-off-by: Petr Machata --- bridge/link.c | 56 ++- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/bridge/link.c b/bridge/link.c index fa6eda849b32

[PATCH iproute2-next 5/7] ip: iplink_bridge_slave: Convert to use print_on_off()

2020-11-14 Thread Petr Machata
Instead of rolling a custom on-off printer, use the one added to utils.c. Note that _print_onoff() has an extra parameter for a JSON-specific flag name. However that argument is not used, and never was. Therefore when moving over to print_on_off(), drop this argument. Signed-off-by: Petr Machata

[PATCH iproute2-next 3/7] ip: iplink: Convert to use parse_on_off()

2020-11-14 Thread Petr Machata
Invoke parse_on_off() instead of rolling a custom function. Signed-off-by: Petr Machata --- ip/iplink.c | 47 +-- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/ip/iplink.c b/ip/iplink.c index d6b766de1fcf..f5766c39507b 100644 --- a

[PATCH iproute2-next 1/7] bridge: link: Port over to parse_on_off()

2020-11-14 Thread Petr Machata
Convert bridge/link.c from a custom on_off parser to the new global one. Signed-off-by: Petr Machata --- bridge/link.c | 79 --- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/bridge/link.c b/bridge/link.c index 3bc7af209b8b

[PATCH iproute2-next 4/7] ip: iplink_bridge_slave: Port over to parse_on_off()

2020-11-14 Thread Petr Machata
Invoke parse_on_off() from bridge_slave_parse_on_off() instead of hand-rolling one. Exit on failure, because the invarg that was ivoked here before would. Signed-off-by: Petr Machata --- ip/iplink_bridge_slave.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ip

[PATCH iproute2-next 7/7] ip: iptuntap: Convert to use print_on_off()

2020-11-14 Thread Petr Machata
Instead of rolling a custom on-off printer, use the one added to utils.c. Signed-off-by: Petr Machata --- ip/iptuntap.c | 18 ++ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/ip/iptuntap.c b/ip/iptuntap.c index 82e384998b1c..e9cc7c0f5f70 100644 --- a/ip

[PATCH iproute2-next 6/7] ip: ipnetconf: Convert to use print_on_off()

2020-11-14 Thread Petr Machata
Instead of rolling a custom on-off printer, use the one added to utils.c. Signed-off-by: Petr Machata --- ip/ipnetconf.c | 28 +++- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/ip/ipnetconf.c b/ip/ipnetconf.c index 0e946ca34b4a..bb0ebe12da93 100644

[PATCH iproute2-next 0/7] Convert a number of use-cases to parse_on_off(), print_on_off()

2020-11-14 Thread Petr Machata
Two helpers, parse_on_off() and print_on_off(), have been recently added to lib/utils.c. Convert a number of instances of the same effective behavior to calls to these helpers. Petr Machata (7): bridge: link: Port over to parse_on_off() bridge: link: Convert to use print_on_off() ip: iplink

[PATCH iproute2-next v5 09/11] lib: parse_mapping: Recognize a keyword "all"

2020-11-12 Thread Petr Machata
allow_all. Signed-off-by: Petr Machata --- include/utils.h | 2 +- ip/iplink_vlan.c | 2 +- lib/utils.c | 6 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/utils.h b/include/utils.h index 2d1a587cb1ef..588fceb72442 100644 --- a/include/utils.h +++ b/inclu

[PATCH iproute2-next v5 08/11] lib: parse_mapping: Update argc, argv on error

2020-11-12 Thread Petr Machata
t; is wrong: invalid egress-qos-map Update argc and argv even in the case of parsing error, so that the right element is indicated. Signed-off-by: Petr Machata --- lib/utils.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/utils.c b/lib/utils.c index 1dfaaf

[PATCH iproute2-next v5 10/11] Add skeleton of a new tool, dcb

2020-11-12 Thread Petr Machata
expand to pre-standard CEE interfaces. Therefore the tool itself is a lean shell that dispatches to subtools each dedicated to one of the objects. Signed-off-by: Petr Machata --- Notes: v5: - Fix handling of all:. max_key is inclusive, not exclusive. Previously, all: didn't se

[PATCH iproute2-next v5 06/11] lib: Extract from devlink/mnlg a helper, mnlu_socket_recv_run()

2020-11-12 Thread Petr Machata
Receiving a message in libmnl is a somewhat involved operation. Devlink's mnlg library has an implementation that is going to be handy for other tools as well. Extract it into a new helper. Signed-off-by: Petr Machata --- devlink/mnlg.c

[PATCH iproute2-next v5 11/11] dcb: Add a subtool for the DCB ETS object

2020-11-12 Thread Petr Machata
5:0 6:0 7:0 reco-tc-bw 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 reco-tc-tsa 0:strict 1:strict 2:strict 3:strict 4:strict 5:strict 6:strict 7:strict reco-prio-tc 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 Signed-off-by: Petr Machata --- Notes: v5: - Man page fix: TC-MAP is actually calle

[PATCH iproute2-next v5 04/11] lib: Extract from devlink/mnlg a helper, mnlu_socket_open()

2020-11-12 Thread Petr Machata
This little dance of mnl_socket_open(), option setting, and bind, is the same regardless of tool. Extract into a new module that should hold helpers for working with libmnl, mnl_util.c. Signed-off-by: Petr Machata --- Notes: v2: - Add SPDX-License-Identifier devlink/Makefile| 2

[PATCH iproute2-next v5 07/11] lib: Extract from iplink_vlan a helper to parse key:value arrays

2020-11-12 Thread Petr Machata
-off-by: Petr Machata --- Notes: v2: - In parse_qos_mapping(), propagate return value from addattr_l() [Roman Mashak] include/utils.h | 4 ip/iplink_vlan.c | 36 +++- lib/utils.c | 28 3 files changed, 47

[PATCH iproute2-next v5 05/11] lib: Extract from devlink/mnlg a helper, mnlu_msg_prepare()

2020-11-12 Thread Petr Machata
Allocation of a new netlink message with the two usual headers is reusable with other netlink netlink message types. Extract it into a helper, mnlu_msg_prepare(). Take the second header as an argument, instead of passing in parameters to initialize it, and copy it in. Signed-off-by: Petr Machata

[PATCH iproute2-next v5 03/11] lib: json_print: Add print_on_off()

2020-11-12 Thread Petr Machata
n in JSON mode. Since there are probably very few if any consumers of this interface at this point, migrate it to the new central print_on_off() as well. Signed-off-by: Petr Machata Reviewed-by: Leon Romanovsky --- Notes: v3: - Rename to print_on_off(). [David Ahern] - Move over

[PATCH iproute2-next v5 01/11] Unify batch processing across tools

2020-11-12 Thread Petr Machata
The code for handling batches is largely the same across iproute2 tools. Extract a helper to handle the batch, and adjust the tools to dispatch to this helper. Sandwitch the invocation between prologue / epilogue code specific for each tool. Signed-off-by: Petr Machata --- bridge/bridge.c

[PATCH iproute2-next v5 00/11] Add a tool for configuration of DCB

2020-11-12 Thread Petr Machata
l access to individual items, e.g.: # dcb ets -j show dev eth0 | jq '.tc_tsa[3]' Instead of: # dcb ets -j show dev eth0 | jq '.["tc-tsa"]["3"]' - Patch #4: - Add SPDX-License-Identifier - Patch #7: - In parse_qos_mapping(), propagate return valu

[PATCH iproute2-next v5 02/11] lib: Add parse_one_of(), parse_on_off()

2020-11-12 Thread Petr Machata
parse_one_of() for parsing specifically the strings "off" and "on". Convert the macsec code to the new helpers. Signed-off-by: Petr Machata --- Notes: v3: - Have parse_on_off() return a boolean. [David Ahern] include/utils.h | 4

[PATCH iproute2-next v4 00/11] Add a tool for configuration of DCB

2020-11-08 Thread Petr Machata
for more natural access to individual items, e.g.: # dcb ets -j show dev eth0 | jq '.tc_tsa[3]' Instead of: # dcb ets -j show dev eth0 | jq '.["tc-tsa"]["3"]' - Patch #4: - Add SPDX-License-Identifier - Patch #7: - In parse_qos_mapping(), p

[PATCH iproute2-next v4 07/11] lib: Extract from iplink_vlan a helper to parse key:value arrays

2020-11-08 Thread Petr Machata
-off-by: Petr Machata --- Notes: v2: - In parse_qos_mapping(), propagate return value from addattr_l() [Roman Mashak] include/utils.h | 4 ip/iplink_vlan.c | 36 +++- lib/utils.c | 28 3 files changed, 47

[PATCH iproute2-next v4 04/11] lib: Extract from devlink/mnlg a helper, mnlu_socket_open()

2020-11-08 Thread Petr Machata
This little dance of mnl_socket_open(), option setting, and bind, is the same regardless of tool. Extract into a new module that should hold helpers for working with libmnl, mnl_util.c. Signed-off-by: Petr Machata --- Notes: v2: - Add SPDX-License-Identifier devlink/Makefile| 2

[PATCH iproute2-next v4 02/11] lib: Add parse_one_of(), parse_on_off()

2020-11-08 Thread Petr Machata
parse_one_of() for parsing specifically the strings "off" and "on". Convert the macsec code to the new helpers. Signed-off-by: Petr Machata --- Notes: v3: - Have parse_on_off() return a boolean. [David Ahern] include/utils.h | 4

[PATCH iproute2-next v4 05/11] lib: Extract from devlink/mnlg a helper, mnlu_msg_prepare()

2020-11-08 Thread Petr Machata
Allocation of a new netlink message with the two usual headers is reusable with other netlink netlink message types. Extract it into a helper, mnlu_msg_prepare(). Take the second header as an argument, instead of passing in parameters to initialize it, and copy it in. Signed-off-by: Petr Machata

[PATCH iproute2-next v4 03/11] lib: json_print: Add print_on_off()

2020-11-08 Thread Petr Machata
n in JSON mode. Since there are probably very few if any consumers of this interface at this point, migrate it to the new central print_on_off() as well. Signed-off-by: Petr Machata --- Notes: v3: - Rename to print_on_off(). [David Ahern] - Move over to json_print.c and make it a var

[PATCH iproute2-next v4 09/11] lib: parse_mapping: Recognize a keyword "all"

2020-11-08 Thread Petr Machata
allow_all. Signed-off-by: Petr Machata --- include/utils.h | 2 +- ip/iplink_vlan.c | 2 +- lib/utils.c | 6 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/utils.h b/include/utils.h index 2d1a587cb1ef..588fceb72442 100644 --- a/include/utils.h +++ b/inclu

[PATCH iproute2-next v4 11/11] dcb: Add a subtool for the DCB ETS object

2020-11-08 Thread Petr Machata
5:0 6:0 7:0 reco-tc-bw 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 reco-tc-tsa 0:strict 1:strict 2:strict 3:strict 4:strict 5:strict 6:strict 7:strict reco-prio-tc 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 Signed-off-by: Petr Machata --- Notes: v4: - Drop all the FILE* arguments that were pas

[PATCH iproute2-next v4 01/11] Unify batch processing across tools

2020-11-08 Thread Petr Machata
The code for handling batches is largely the same across iproute2 tools. Extract a helper to handle the batch, and adjust the tools to dispatch to this helper. Sandwitch the invocation between prologue / epilogue code specific for each tool. Signed-off-by: Petr Machata --- bridge/bridge.c

[PATCH iproute2-next v4 10/11] Add skeleton of a new tool, dcb

2020-11-08 Thread Petr Machata
expand to pre-standard CEE interfaces. Therefore the tool itself is a lean shell that dispatches to subtools each dedicated to one of the objects. Signed-off-by: Petr Machata --- Notes: v4: - Drop all the FILE* arguments that were passed around unnecessarily - Change dcb_parse_mapping

[PATCH iproute2-next v4 06/11] lib: Extract from devlink/mnlg a helper, mnlu_socket_recv_run()

2020-11-08 Thread Petr Machata
Receiving a message in libmnl is a somewhat involved operation. Devlink's mnlg library has an implementation that is going to be handy for other tools as well. Extract it into a new helper. Signed-off-by: Petr Machata --- devlink/mnlg.c

[PATCH iproute2-next v4 08/11] lib: parse_mapping: Update argc, argv on error

2020-11-08 Thread Petr Machata
t; is wrong: invalid egress-qos-map Update argc and argv even in the case of parsing error, so that the right element is indicated. Signed-off-by: Petr Machata --- lib/utils.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/utils.c b/lib/utils.c index 1dfaaf

[PATCH iproute2-next v3 06/11] lib: Extract from devlink/mnlg a helper, mnlu_socket_recv_run()

2020-11-08 Thread Petr Machata
Receiving a message in libmnl is a somewhat involved operation. Devlink's mnlg library has an implementation that is going to be handy for other tools as well. Extract it into a new helper. Signed-off-by: Petr Machata --- devlink/mnlg.c

[PATCH iproute2-next v3 09/11] lib: parse_mapping: Recognize a keyword "all"

2020-11-08 Thread Petr Machata
allow_all. Signed-off-by: Petr Machata --- include/utils.h | 2 +- ip/iplink_vlan.c | 2 +- lib/utils.c | 6 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/utils.h b/include/utils.h index 2d1a587cb1ef..588fceb72442 100644 --- a/include/utils.h +++ b/inclu

[PATCH iproute2-next v3 10/11] Add skeleton of a new tool, dcb

2020-11-08 Thread Petr Machata
expand to pre-standard CEE interfaces. Therefore the tool itself is a lean shell that dispatches to subtools each dedicated to one of the objects. Signed-off-by: Petr Machata --- Notes: v3: - Fix help output and man page to show the arguments as they are, so -p and --pretty, not -[p

[PATCH iproute2-next v3 05/11] lib: Extract from devlink/mnlg a helper, mnlu_msg_prepare()

2020-11-08 Thread Petr Machata
Allocation of a new netlink message with the two usual headers is reusable with other netlink netlink message types. Extract it into a helper, mnlu_msg_prepare(). Take the second header as an argument, instead of passing in parameters to initialize it, and copy it in. Signed-off-by: Petr Machata

[PATCH iproute2-next v3 08/11] lib: parse_mapping: Update argc, argv on error

2020-11-08 Thread Petr Machata
t; is wrong: invalid egress-qos-map Update argc and argv even in the case of parsing error, so that the right element is indicated. Signed-off-by: Petr Machata --- lib/utils.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/utils.c b/lib/utils.c index 1dfaaf

[PATCH iproute2-next v3 11/11] dcb: Add a subtool for the DCB ETS object

2020-11-08 Thread Petr Machata
5:0 6:0 7:0 reco-tc-bw 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 reco-tc-tsa 0:strict 1:strict 2:strict 3:strict 4:strict 5:strict 6:strict 7:strict reco-prio-tc 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 Signed-off-by: Petr Machata --- Notes: v3: - Formatting tweaks in the man page dc

[PATCH iproute2-next v3 04/11] lib: Extract from devlink/mnlg a helper, mnlu_socket_open()

2020-11-08 Thread Petr Machata
This little dance of mnl_socket_open(), option setting, and bind, is the same regardless of tool. Extract into a new module that should hold helpers for working with libmnl, mnl_util.c. Signed-off-by: Petr Machata --- Notes: v2: - Add SPDX-License-Identifier devlink/Makefile| 2

[PATCH iproute2-next v3 01/11] Unify batch processing across tools

2020-11-08 Thread Petr Machata
The code for handling batches is largely the same across iproute2 tools. Extract a helper to handle the batch, and adjust the tools to dispatch to this helper. Sandwitch the invocation between prologue / epilogue code specific for each tool. Signed-off-by: Petr Machata --- bridge/bridge.c

[PATCH iproute2-next v3 00/11] Add a tool for configuration of DCB

2020-11-08 Thread Petr Machata
-j show dev eth0 | jq '.tc_tsa[3]' Instead of: # dcb ets -j show dev eth0 | jq '.["tc-tsa"]["3"]' - Patch #4: - Add SPDX-License-Identifier - Patch #7: - In parse_qos_mapping(), propagate return value from addattr_l() [Roman Mashak] Petr Ma

[PATCH iproute2-next v3 07/11] lib: Extract from iplink_vlan a helper to parse key:value arrays

2020-11-08 Thread Petr Machata
-off-by: Petr Machata --- Notes: v2: - In parse_qos_mapping(), propagate return value from addattr_l() [Roman Mashak] include/utils.h | 4 ip/iplink_vlan.c | 36 +++- lib/utils.c | 28 3 files changed, 47

[PATCH iproute2-next v3 02/11] lib: Add parse_one_of(), parse_on_off()

2020-11-08 Thread Petr Machata
parse_one_of() for parsing specifically the strings "off" and "on". Convert the macsec code to the new helpers. Signed-off-by: Petr Machata --- Notes: v3: - Have parse_on_off() return a boolean. [David Ahern] include/utils.h | 4

[PATCH iproute2-next v3 03/11] lib: json_print: Add print_on_off()

2020-11-08 Thread Petr Machata
n in JSON mode. Since there are probably very few if any consumers of this interface at this point, migrate it to the new central print_on_off() as well. Signed-off-by: Petr Machata --- Notes: v3: - Rename to print_on_off(). [David Ahern] - Move over to json_print.c and make it a var

Re: [PATCH iproute2-next v2 03/11] lib: utils: Add print_on_off_bool()

2020-11-05 Thread Petr Machata
Leon Romanovsky writes: > On Tue, Nov 03, 2020 at 10:01:32PM +0100, Petr Machata wrote: >> >> Leon Romanovsky writes: >> >> > On Tue, Nov 03, 2020 at 12:05:20AM +0100, Petr Machata wrote: >> >> >> >> Leon Romanovsky writes: >> >

Re: [PATCH iproute2-next v2 03/11] lib: utils: Add print_on_off_bool()

2020-11-03 Thread Petr Machata
Leon Romanovsky writes: > On Tue, Nov 03, 2020 at 12:05:20AM +0100, Petr Machata wrote: >> >> Leon Romanovsky writes: >> >> > On Sun, Nov 01, 2020 at 04:55:42PM -0700, David Ahern wrote: >> > >> >> yes, the rdma utils are using generic funct

Re: [PATCH iproute2-next v2 03/11] lib: utils: Add print_on_off_bool()

2020-11-02 Thread Petr Machata
Leon Romanovsky writes: > On Sun, Nov 01, 2020 at 04:55:42PM -0700, David Ahern wrote: >> On 10/31/20 3:23 PM, Petr Machata wrote: >> > >> > David Ahern writes: >> > >> >> On 10/30/20 6:29 AM, Petr Machata wrote: >> >>> d

Re: [PATCH iproute2-next v2 02/11] lib: Add parse_one_of(), parse_on_off()

2020-10-31 Thread Petr Machata
David Ahern writes: > On 10/30/20 6:29 AM, Petr Machata wrote: >> +int parse_on_off(const char *msg, const char *realval, int *p_err) >> +{ >> +static const char * const values_on_off[] = { "off", "on" }; >> + >> +return par

Re: [PATCH iproute2-next v2 03/11] lib: utils: Add print_on_off_bool()

2020-10-31 Thread Petr Machata
Stephen Hemminger writes: > On Fri, 30 Oct 2020 13:29:50 +0100 > Petr Machata wrote: > >> +void print_on_off_bool(FILE *fp, const char *flag, bool val) >> +{ >> +if (is_json_context()) >> +print_bool(PRINT_JSON, flag, NULL, val); >> +

Re: [PATCH iproute2-next v2 03/11] lib: utils: Add print_on_off_bool()

2020-10-31 Thread Petr Machata
David Ahern writes: > On 10/30/20 6:29 AM, Petr Machata wrote: >> diff --git a/lib/utils.c b/lib/utils.c >> index 930877ae0f0d..8deec86ecbcd 100644 >> --- a/lib/utils.c >> +++ b/lib/utils.c >> @@ -1763,3 +1763,11 @@ int parse_on_off(const char *msg, co

[PATCH iproute2-next v2 08/11] lib: parse_mapping: Update argc, argv on error

2020-10-30 Thread Petr Machata
t; is wrong: invalid egress-qos-map Update argc and argv even in the case of parsing error, so that the right element is indicated. Signed-off-by: Petr Machata --- lib/utils.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/utils.c b/lib/utils.c index aba7cc

[PATCH iproute2-next v2 04/11] lib: Extract from devlink/mnlg a helper, mnlu_socket_open()

2020-10-30 Thread Petr Machata
This little dance of mnl_socket_open(), option setting, and bind, is the same regardless of tool. Extract into a new module that should hold helpers for working with libmnl, mnl_util.c. Signed-off-by: Petr Machata --- Notes: v2: - Add SPDX-License-Identifier devlink/Makefile| 2

[PATCH iproute2-next v2 09/11] lib: parse_mapping: Recognize a keyword "all"

2020-10-30 Thread Petr Machata
allow_all. Signed-off-by: Petr Machata --- include/utils.h | 2 +- ip/iplink_vlan.c | 2 +- lib/utils.c | 6 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/utils.h b/include/utils.h index 1c72221ae92c..8ec1b7ab0d8d 100644 --- a/include/utils.h +++ b/inclu

[PATCH iproute2-next v2 10/11] Add skeleton of a new tool, dcb

2020-10-30 Thread Petr Machata
expand to pre-standard CEE interfaces. Therefore the tool itself is a lean shell that dispatches to subtools each dedicated to one of the objects. Signed-off-by: Petr Machata --- Makefile | 2 +- dcb/Makefile | 24 +++ dcb/dcb.c | 401

[PATCH iproute2-next v2 02/11] lib: Add parse_one_of(), parse_on_off()

2020-10-30 Thread Petr Machata
parse_one_of() for parsing specifically the strings "off" and "on". Convert the macsec code to the new helpers. Signed-off-by: Petr Machata --- include/utils.h | 4 ip/ipmacsec.c | 52 +++-- lib/utils.c | 28 +

[PATCH iproute2-next v2 03/11] lib: utils: Add print_on_off_bool()

2020-10-30 Thread Petr Machata
The value of a number of booleans is shown as "on" and "off" in the plain output, and as an actual boolean in JSON mode. Add a function that does that. Signed-off-by: Petr Machata --- include/utils.h | 1 + lib/utils.c | 8 2 files changed, 9 insertions(+)

[PATCH iproute2-next v2 00/11] Add a tool for configuration of DCB

2020-10-30 Thread Petr Machata
#4: - Add SPDX-License-Identifier - Patch #7: - In parse_qos_mapping(), propagate return value from addattr_l() [Roman Mashak] Petr Machata (11): Unify batch processing across tools lib: Add parse_one_of(), parse_on_off() lib: utils: Add print_on_off_bool() lib: Extract from devlink/mn

[PATCH iproute2-next v2 05/11] lib: Extract from devlink/mnlg a helper, mnlu_msg_prepare()

2020-10-30 Thread Petr Machata
Allocation of a new netlink message with the two usual headers is reusable with other netlink netlink message types. Extract it into a helper, mnlu_msg_prepare(). Take the second header as an argument, instead of passing in parameters to initialize it, and copy it in. Signed-off-by: Petr Machata

[PATCH iproute2-next v2 01/11] Unify batch processing across tools

2020-10-30 Thread Petr Machata
The code for handling batches is largely the same across iproute2 tools. Extract a helper to handle the batch, and adjust the tools to dispatch to this helper. Sandwitch the invocation between prologue / epilogue code specific for each tool. Signed-off-by: Petr Machata --- bridge/bridge.c

[PATCH iproute2-next v2 11/11] dcb: Add a subtool for the DCB ETS object

2020-10-30 Thread Petr Machata
5:0 6:0 7:0 reco-tc-bw 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 reco-tc-tsa 0:strict 1:strict 2:strict 3:strict 4:strict 5:strict 6:strict 7:strict reco-prio-tc 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 Signed-off-by: Petr Machata --- dcb/Makefile | 2 +- dcb/dcb.c | 4 +-

[PATCH iproute2-next v2 06/11] lib: Extract from devlink/mnlg a helper, mnlu_socket_recv_run()

2020-10-30 Thread Petr Machata
Receiving a message in libmnl is a somewhat involved operation. Devlink's mnlg library has an implementation that is going to be handy for other tools as well. Extract it into a new helper. Signed-off-by: Petr Machata --- devlink/mnlg.c

[PATCH iproute2-next v2 07/11] lib: Extract from iplink_vlan a helper to parse key:value arrays

2020-10-30 Thread Petr Machata
-off-by: Petr Machata --- Notes: v2: - In parse_qos_mapping(), propagate return value from addattr_l() [Roman Mashak] include/utils.h | 4 ip/iplink_vlan.c | 36 +++- lib/utils.c | 28 3 files changed, 47

Re: [PATCH iproute2-next 15/15] dcb: Add a subtool for the DCB ETS object

2020-10-22 Thread Petr Machata
On October 22, 2020 2:11:01 AM GMT+02:00, Stephen Hemminger wrote: >On Thu, 22 Oct 2020 01:48:58 +0200 >Petr Machata wrote: > >> Stephen Hemminger writes: >> >> > On Tue, 20 Oct 2020 22:43:37 +0200 >> > Petr Machata wrote: >> > >>

Re: [PATCH iproute2-next 15/15] dcb: Add a subtool for the DCB ETS object

2020-10-21 Thread Petr Machata
Stephen Hemminger writes: > On Tue, 20 Oct 2020 22:43:37 +0200 > Petr Machata wrote: > >> Jakub Kicinski writes: >> >> > On Tue, 20 Oct 2020 02:58:23 +0200 Petr Machata wrote: >> >> +static void dcb_ets_print_cbs(FILE *fp, const struct ieee_ets *et

Re: [PATCH iproute2-next 11/15] lib: Extract from iplink_vlan a helper to parse key:value arrays

2020-10-20 Thread Petr Machata
Roman Mashak writes: > Petr Machata writes: > > > [...] > >> +static int parse_qos_mapping(__u32 key, char *value, void *data) >> +{ >> +struct nlmsghdr *n = data; >> +struct ifla_vlan_qos_mapping m = { >> +.from = key, >&g

Re: [PATCH iproute2-next 15/15] dcb: Add a subtool for the DCB ETS object

2020-10-20 Thread Petr Machata
Jakub Kicinski writes: > On Tue, 20 Oct 2020 02:58:23 +0200 Petr Machata wrote: >> +static void dcb_ets_print_cbs(FILE *fp, const struct ieee_ets *ets) >> +{ >> +print_string(PRINT_ANY, "cbs", "cbs %s ", ets->cbs ? "on" : "off&q

<    1   2   3   4   5   6   7   8   9   10   >