[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <e865ef2f656e836662c0cd307c17250f072d3d1b.1604059429.git.me@pmachata.org>
Date: Fri, 30 Oct 2020 13:29:56 +0100
From: Petr Machata <me@...chata.org>
To: netdev@...r.kernel.org, dsahern@...il.com,
stephen@...workplumber.org
Cc: john.fastabend@...il.com, jiri@...dia.com, idosch@...dia.com,
Jakub Kicinski <kuba@...nel.org>,
Roman Mashak <mrv@...atatu.com>, Petr Machata <me@...chata.org>
Subject: [PATCH iproute2-next v2 09/11] lib: parse_mapping: Recognize a keyword "all"
The DCB tool will have to provide an interface to a number of fixed-size
arrays. Unlike the egress- and ingress-qos-map, it makes good sense to have
an interface to set all members to the same value. For example to set
strict priority on all TCs besides select few, or to reset allocated
bandwidth to all zeroes, again besides several explicitly-given ones.
To support this usage, extend the parse_mapping() with a boolean that
determines whether this special use is supported. If "all" is given and
recognized, mapping_cb is called with the key of -1.
Have iplink_vlan pass false for allow_all.
Signed-off-by: Petr Machata <me@...chata.org>
---
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/include/utils.h
@@ -330,7 +330,7 @@ int parse_one_of(const char *msg, const char *realval, const char * const *list,
int parse_on_off(const char *msg, const char *realval, int *p_err);
void print_on_off_bool(FILE *fp, const char *flag, bool val);
-int parse_mapping(int *argcp, char ***argvp,
+int parse_mapping(int *argcp, char ***argvp, bool allow_all,
int (*mapping_cb)(__u32 key, char *value, void *data),
void *mapping_cb_data);
diff --git a/ip/iplink_vlan.c b/ip/iplink_vlan.c
index dadc349db16c..1426f2afca23 100644
--- a/ip/iplink_vlan.c
+++ b/ip/iplink_vlan.c
@@ -69,7 +69,7 @@ static int vlan_parse_qos_map(int *argcp, char ***argvp, struct nlmsghdr *n,
tail = addattr_nest(n, 1024, attrtype);
- if (parse_mapping(argcp, argvp, &parse_qos_mapping, n))
+ if (parse_mapping(argcp, argvp, false, &parse_qos_mapping, n))
return 1;
addattr_nest_end(n, tail);
diff --git a/lib/utils.c b/lib/utils.c
index 089bbde715da..3b3b42b15013 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -1772,7 +1772,7 @@ void print_on_off_bool(FILE *fp, const char *flag, bool val)
fprintf(fp, "%s %s ", flag, val ? "on" : "off");
}
-int parse_mapping(int *argcp, char ***argvp,
+int parse_mapping(int *argcp, char ***argvp, bool allow_all,
int (*mapping_cb)(__u32 key, char *value, void *data),
void *mapping_cb_data)
{
@@ -1788,7 +1788,9 @@ int parse_mapping(int *argcp, char ***argvp,
break;
*colon = '\0';
- if (get_u32(&key, *argv, 0)) {
+ if (allow_all && matches(*argv, "all") == 0) {
+ key = (__u32) -1;
+ } else if (get_u32(&key, *argv, 0)) {
ret = 1;
break;
}
--
2.25.1
Powered by blists - more mailing lists