dcb: Support APP, DCBX objects
Subsystems (3)
cover dcb: Support APP, DCBX objects
Add support to the dcb tool for the following two DCB objects:
- APP, which allows configuration of traffic prioritization rules based on several possible packet headers.
- DCBX, which is a 1-byte bitfield of flags that configure whether the DCBX protocol is implemented in the device or in the host, and which version of the protocol should be used.
Patches #1 and #2 fix issues in the current DCB code.
Patch #3 adds a new helper for finding a name of a given dsfield value. This is useful for APP DSCP-to-priority rules, which can use human-readable DSCP names.
Patches #4, #5 and #6 extend existing interfaces for, respectively, parsing of the X:Y mappings, for setting a DCB object, and for getting a DCB object.
In patch #7, support for the command line argument -n / --no-nice-names is added. The APP tool later uses it to decide whether to format DSCP values as human-readable strings or as plain numbers.
Patches #8 and #9 add the subtools themselves and their man pages.
Petr Machata (9):
dcb: Set values with RTM_SETDCB type
dcb: Plug a leaking DCB socket buffer
lib: rt_names: Add rtnl_dsfield_get_name()
lib: Generalize parse_mapping()
dcb: Generalize dcb_set_attribute()
dcb: Generalize dcb_get_attribute()
dcb: Support -n to suppress translation to nice names
dcb: Add a subtool for the DCB APP object
dcb: Add a subtool for the DCBX object
dcb/Makefile | 8 +- dcb/dcb.c | 194 +++++++++-- dcb/dcb.h | 20 ++ dcb/dcb_app.c | 796 ++++++++++++++++++++++++++++++++++++++++++++ dcb/dcb_dcbx.c | 192 +++++++++++ include/rt_names.h | 1 + include/utils.h | 5 + lib/rt_names.c | 20 +- lib/utils.c | 37 +- man/man8/dcb-app.8 | 237 +++++++++++++ man/man8/dcb-dcbx.8 | 108 ++++++ man/man8/dcb.8 | 12 +- 12 files changed, 1592 insertions(+), 38 deletions(-) create mode 100644 dcb/dcb_app.c create mode 100644 dcb/dcb_dcbx.c create mode 100644 man/man8/dcb-app.8 create mode 100644 man/man8/dcb-dcbx.8
Signature · 1 line
2.25.1
PATCH 1/9 dcb: Set values with RTM_SETDCB type
dcb currently sends all netlink messages with a type RTM_GETDCB, even the set ones. Change to the appropriate type.
--- dcb/dcb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
dcb/dcb.c +1 -1
@@ -177,7 +177,7 @@ int dcb_set_attribute(struct dcb *dcb, const char *dev, int attr, const void *dastruct nlattr *nest;int ret; - nlh =dcb_prepare (dcb, dev,RTM_GETDCB ,DCB_CMD_IEEE_SET ); + nlh =dcb_prepare (dcb, dev,RTM_SETDCB ,DCB_CMD_IEEE_SET ); nest =mnl_attr_nest_start (nlh,DCB_ATTR_IEEE );mnl_attr_put (nlh, attr, data_len, data);
Signature · 1 line
2.25.1
PATCH 2/9 dcb: Plug a leaking DCB socket buffer
In reply to Petr MachataDCB socket buffer is allocated in dcb_init(), but never freed(). Free it in dcb_fini().
--- dcb/dcb.c | 1 + 1 file changed, 1 insertion(+)
dcb/dcb.c +1 -0
@@ -38,6 +38,7 @@ static void dcb_fini(struct dcb *dcb) {delete_json_obj_plain ();mnl_socket_close (dcb->nl); +free (dcb->buf); }static struct dcb *dcb_alloc (void )
Signature · 1 line
2.25.1
PATCH 3/9 lib: rt_names: Add rtnl_dsfield_get_name()
In reply to Petr MachataFor formatting DSCP (not full dsfield), it would be handy to be able to just get the name from the name table, and not get any of the remaining cruft related to formatting. Add a new entry point to just fetch the name table string uninterpreted. Use it from rtnl_dsfield_n2a().
--- include/rt_names.h | 1 + lib/rt_names.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-)
include/rt_names.h +1 -0
@@ -9,6 +9,7 @@ const char *rtnl_rtscope_n2a(int id, char *buf, int len);const char *rtnl_rttable_n2a (__u32 id,char *buf,int len);const char *rtnl_rtrealm_n2a (int id,char *buf,int len);const char *rtnl_dsfield_n2a (int id,char *buf,int len); +const char *rtnl_dsfield_get_name (int id);const char *rtnl_group_n2a (int id,char *buf,int len);int rtnl_rtprot_a2n (__u32 *id,const char *arg);
lib/rt_names.c +16 -4
@@ -479,18 +479,30 @@ static void rtnl_rtdsfield_initialize(void)const char *rtnl_dsfield_n2a (int id,char *buf,int len) { +const char *name; +if (id <0 || id >=256 ) {snprintf (buf, len,"%d" , id);return buf; } +if (!numeric) { + name =rtnl_dsfield_get_name (id); +if (name !=NULL ) +return name; + } +snprintf (buf, len,"0x%02x" , id); +return buf; +} + +const char *rtnl_dsfield_get_name (int id) +{ +if (id <0 || id >=256 ) +return NULL ;if (!rtnl_rtdsfield_tab[id]) {if (!rtnl_rtdsfield_init)rtnl_rtdsfield_initialize (); } -if (!numeric && rtnl_rtdsfield_tab[id]) -return rtnl_rtdsfield_tab[id]; -snprintf (buf, len,"0x%02x" , id); -return buf; +return rtnl_rtdsfield_tab[id]; }
Signature · 1 line
2.25.1
PATCH 4/9 lib: Generalize parse_mapping()
In reply to Petr MachataThe function parse_mapping() assumes the key is a number, with a single configurable exception, which is using "all" to mean "all possible keys". If a caller wishes to use symbolic names instead of numbers, they cannot reuse this function.
To facilitate reuse in these situations, convert parse_mapping() into a helper, parse_mapping_gen(), which instead of an allow-all boolean takes a generic key-parsing callback. Rewrite parse_mapping() in terms of this newly-added helper and add a pair of key parsers, one for just numbers, another for numbers and the keyword "all". Publish the latter as well.
--- include/utils.h | 5 +++++ lib/utils.c | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 6 deletions(-)
include/utils.h +5 -0
@@ -331,6 +331,11 @@ int parse_one_of(const char *msg, const char *realval, const char * const *list, size_t len, int *p_err);bool parse_on_off (const char *msg,const char *realval,int *p_err); +int parse_mapping_num_all (__u32 *keyp,const char *key); +int parse_mapping_gen (int *argcp,char ***argvp, +int (*key_cb)(__u32 *keyp,const char *key), +int (*mapping_cb)(__u32 key,char *value,void *data), +void *mapping_cb_data);int parse_mapping (int *argcp,char ***argvp,bool allow_all,int (*mapping_cb)(__u32 key,char *value,void *data),void *mapping_cb_data);
lib/utils.c +31 -6
@@ -1878,9 +1878,10 @@ bool parse_on_off(const char *msg, const char *realval, int *p_err)return parse_one_of (msg, realval, values_on_off,ARRAY_SIZE (values_on_off), p_err); } -int parse_mapping (int *argcp,char ***argvp,bool allow_all, -int (*mapping_cb)(__u32 key,char *value,void *data), -void *mapping_cb_data) +int parse_mapping_gen (int *argcp,char ***argvp, +int (*key_cb)(__u32 *keyp,const char *key), +int (*mapping_cb)(__u32 key,char *value,void *data), +void *mapping_cb_data) {int argc = *argcp;char **argv = *argvp;
@@ -1894,9 +1895,7 @@ int parse_mapping(int *argcp, char ***argvp, bool allow_all,break ; *colon ='\0' ; -if (allow_all &&matches (*argv,"all" ) ==0 ) { - key = (__u32) -1 ; - }else if (get_u32 (&key, *argv,0 )) { +if (key_cb (&key, *argv)) { ret =1 ;break ; }
@@ -1912,3 +1911,29 @@ int parse_mapping(int *argcp, char ***argvp, bool allow_all, *argvp = argv;return ret; } + +static int parse_mapping_num (__u32 *keyp,const char *key) +{ +return get_u32 (keyp, key,0 ); +} + +int parse_mapping_num_all (__u32 *keyp,const char *key) +{ +if (matches (key,"all" ) ==0 ) { + *keyp = (__u32) -1 ; +return 0 ; + } +return parse_mapping_num (keyp, key); +} + +int parse_mapping (int *argcp,char ***argvp,bool allow_all, +int (*mapping_cb)(__u32 key,char *value,void *data), +void *mapping_cb_data) +{ +if (allow_all) +return parse_mapping_gen (argcp, argvp, parse_mapping_num_all, + mapping_cb, mapping_cb_data); +else +return parse_mapping_gen (argcp, argvp, parse_mapping_num, + mapping_cb, mapping_cb_data); +}
Signature · 1 line
2.25.1
PATCH 5/9 dcb: Generalize dcb_set_attribute()
In reply to Petr MachataThe function dcb_set_attribute() takes a fully-formed payload as an argument. For callers that need to build a nested attribute, such as is the case for DCB APP table, this is not great, because with libmnl, they would need to construct a separate netlink message just to pluck out the payload and hand it over to this function.
Currently, dcb_set_attribute() also always wraps the payload in an DCB_ATTR_IEEE container, because that is what all the dcb subtools so far needed. But that is not appropriate for DCBX in particular, and in fact a handful other attributes, as well as any CEE payloads.
Instead, generalize this code by adding parameters for constructing a custom payload and for fetching the response from a custom response attribute. Then add dcb_set_attribute_va(), which takes a callback to invoke in the right place for the nest to be built, and dcb_set_attribute_bare(), which is similar to dcb_set_attribute(), but does not encapsulate the payload in an IEEE container. Rewrite dcb_set_attribute() compatibly in terms of the new functions.
--- dcb/dcb.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++----- dcb/dcb.h | 7 ++++ 2 files changed, 98 insertions(+), 8 deletions(-)
dcb/dcb.c +91 -8
@@ -94,12 +94,17 @@ static int dcb_get_attribute_cb(const struct nlmsghdr *nlh, void *data)return mnl_attr_parse (nlh,sizeof (struct dcbmsg ), dcb_get_attribute_attr_cb, data); } +struct dcb_set_attribute_response { +int response_attr; +}; +static int dcb_set_attribute_attr_cb (const struct nlattr *attr,void *data) { +struct dcb_set_attribute_response *resp = data;uint16_t len;uint8_t err; -if (mnl_attr_get_type (attr) !=DCB_ATTR_IEEE ) +if (mnl_attr_get_type (attr) != resp->response_attr)return MNL_CB_OK ; len =mnl_attr_get_payload_len (attr);
@@ -172,19 +177,23 @@ int dcb_get_attribute(struct dcb *dcb, const char *dev, int attr, void *data, sireturn 0 ; } -int dcb_set_attribute (struct dcb *dcb,const char *dev,int attr,const void *data,size_t data_len) +static int __dcb_set_attribute (struct dcb *dcb,int command,const char *dev, +int (*cb)(struct dcb *,struct nlmsghdr *,void *), +void *data,int response_attr) { +struct dcb_set_attribute_response resp = { + .response_attr = response_attr, + };struct nlmsghdr *nlh; -struct nlattr *nest;int ret; - nlh =dcb_prepare (dcb, dev,RTM_SETDCB ,DCB_CMD_IEEE_SET ); + nlh =dcb_prepare (dcb, dev,RTM_SETDCB , command); - nest =mnl_attr_nest_start (nlh,DCB_ATTR_IEEE ); -mnl_attr_put (nlh, attr, data_len, data); -mnl_attr_nest_end (nlh, nest); + ret =cb (dcb, nlh, data); +if (ret) +return ret; - ret =dcb_talk (dcb, nlh, dcb_set_attribute_cb,NULL ); + ret =dcb_talk (dcb, nlh, dcb_set_attribute_cb, &resp);if (ret) {perror ("Attribute write" );return ret;
@@ -192,6 +201,80 @@ int dcb_set_attribute(struct dcb *dcb, const char *dev, int attr, const void *dareturn 0 ; } +struct dcb_set_attribute_ieee_cb { +int (*cb)(struct dcb *dcb,struct nlmsghdr *nlh,void *data); +void *data; +}; + +static int dcb_set_attribute_ieee_cb (struct dcb *dcb,struct nlmsghdr *nlh,void *data) +{ +struct dcb_set_attribute_ieee_cb *ieee_data = data; +struct nlattr *nest; +int ret; + + nest =mnl_attr_nest_start (nlh,DCB_ATTR_IEEE ); + ret = ieee_data->cb (dcb, nlh, ieee_data->data); +if (ret) +return ret; +mnl_attr_nest_end (nlh, nest); + +return 0 ; +} + +int dcb_set_attribute_va (struct dcb *dcb,int command,const char *dev, +int (*cb)(struct dcb *dcb,struct nlmsghdr *nlh,void *data), +void *data) +{ +struct dcb_set_attribute_ieee_cb ieee_data = { + .cb = cb, + .data = data, + }; + +return __dcb_set_attribute (dcb, command, dev, + &dcb_set_attribute_ieee_cb, &ieee_data, +DCB_ATTR_IEEE ); +} + +struct dcb_set_attribute { +int attr; +const void *data; +size_t data_len; +}; + +static int dcb_set_attribute_put (struct dcb *dcb,struct nlmsghdr *nlh,void *data) +{ +struct dcb_set_attribute *dsa = data; + +mnl_attr_put (nlh, dsa->attr, dsa->data_len, dsa->data); +return 0 ; +} + +int dcb_set_attribute (struct dcb *dcb,const char *dev,int attr,const void *data,size_t data_len) +{ +struct dcb_set_attribute dsa = { + .attr = attr, + .data = data, + .data_len = data_len, + }; + +return dcb_set_attribute_va (dcb,DCB_CMD_IEEE_SET , dev, + &dcb_set_attribute_put, &dsa); +} + +int dcb_set_attribute_bare (struct dcb *dcb,int command,const char *dev, +int attr,const void *data,size_t data_len, +int response_attr) +{ +struct dcb_set_attribute dsa = { + .attr = attr, + .data = data, + .data_len = data_len, + }; + +return __dcb_set_attribute (dcb, command, dev, + &dcb_set_attribute_put, &dsa, response_attr); +} +void dcb_print_array_u8 (const __u8 *array,size_t size) {SPRINT_BUF (b);
dcb/dcb.h +7 -0
@@ -2,6 +2,7 @@#ifndef __DCB_H__#define __DCB_H__ 1 +#include <libmnl/libmnl.h> #include <stdbool.h> #include <stddef.h>
@@ -32,6 +33,12 @@ int dcb_get_attribute(struct dcb *dcb, const char *dev, int attr, void *data, size_t data_len);int dcb_set_attribute (struct dcb *dcb,const char *dev,int attr,const void *data,size_t data_len); +int dcb_set_attribute_va (struct dcb *dcb,int command,const char *dev, +int (*cb)(struct dcb *dcb,struct nlmsghdr *nlh,void *data), +void *data); +int dcb_set_attribute_bare (struct dcb *dcb,int command,const char *dev, +int attr,const void *data,size_t data_len, +int response_attr); void dcb_print_named_array(const char *json_name, const char *fp_name, const __u8 *array, size_t size,
Signature · 1 line
2.25.1
PATCH 6/9 dcb: Generalize dcb_get_attribute()
In reply to Petr MachataThe function dcb_get_attribute() assumes that the caller knows the exact size of the looked-for payload. It also assumes that the response comes wrapped in an DCB_ATTR_IEEE nest. The former assumption does not hold for the IEEE APP table, which has variable size. The latter one does not hold for DCBX, which is not IEEE-nested, and also for any CEE attributes, which would come CEE-nested.
Factor out the payload extractor from the current dcb_get_attribute() code, and put into a helper. Then rewrite dcb_get_attribute() compatibly in terms of the new function. Introduce dcb_get_attribute_va() 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().
--- dcb/dcb.c | 79 ++++++++++++++++++++++++++++++++++++++++++++----------- dcb/dcb.h | 4 +++ 2 files changed, 68 insertions(+), 15 deletions(-)
dcb/dcb.c +64 -15
@@ -59,25 +59,19 @@ static void dcb_free(struct dcb *dcb)struct dcb_get_attribute {struct dcb *dcb;int attr; -void *data; -size_t data_len; +void *payload; +__u16 payload_len; };static int dcb_get_attribute_attr_ieee_cb (const struct nlattr *attr,void *data) {struct dcb_get_attribute *ga = data; -uint16_t len;if (mnl_attr_get_type (attr) != ga->attr)return MNL_CB_OK ; - len =mnl_attr_get_payload_len (attr); -if (len != ga->data_len) { -fprintf (stderr,"Wrong len %d, expected %zd\n" , len, ga->data_len); -return MNL_CB_ERROR ; - } - -memcpy (ga->data,mnl_attr_get_payload (attr), ga->data_len); + ga->payload =mnl_attr_get_payload (attr); + ga->payload_len =mnl_attr_get_payload_len (attr);return MNL_CB_STOP ; }
@@ -94,6 +88,16 @@ static int dcb_get_attribute_cb(const struct nlmsghdr *nlh, void *data)return mnl_attr_parse (nlh,sizeof (struct dcbmsg ), dcb_get_attribute_attr_cb, data); } +static int dcb_get_attribute_bare_cb (const struct nlmsghdr *nlh,void *data) +{ +/* Bare attributes (e.g. DCB_ATTR_DCBX) are not wrapped inside an IEEE +* container, so this does not have to go through unpacking in +* dcb_get_attribute_attr_cb(). +*/ +return mnl_attr_parse (nlh,sizeof (struct dcbmsg ), + dcb_get_attribute_attr_ieee_cb, data); +} +struct dcb_set_attribute_response {int response_attr; };
@@ -155,25 +159,70 @@ static struct nlmsghdr *dcb_prepare(struct dcb *dcb, const char *dev,return nlh; } -int dcb_get_attribute (struct dcb *dcb,const char *dev,int attr,void *data,size_t data_len) +static int __dcb_get_attribute (struct dcb *dcb,int command, +const char *dev,int attr, +void **payload_p,__u16 *payload_len_p, +int (*get_attribute_cb)(const struct nlmsghdr *nlh, +void *data)) {struct dcb_get_attribute ga;struct nlmsghdr *nlh;int ret; - nlh =dcb_prepare (dcb, dev,RTM_GETDCB ,DCB_CMD_IEEE_GET ); + nlh =dcb_prepare (dcb, dev,RTM_GETDCB , command); ga = (struct dcb_get_attribute ) { .dcb = dcb, .attr = attr, - .data = data, - .data_len = data_len, + .payload =NULL , }; - ret =dcb_talk (dcb, nlh, dcb_get_attribute_cb, &ga); + ret =dcb_talk (dcb, nlh, get_attribute_cb, &ga);if (ret) {perror ("Attribute read" );return ret; } +if (ga.payload ==NULL ) { +perror ("Attribute not found" ); +return -ENOENT ; + } + + *payload_p = ga.payload; + *payload_len_p = ga.payload_len; +return 0 ; +} + +int dcb_get_attribute_va (struct dcb *dcb,const char *dev,int attr, +void **payload_p,__u16 *payload_len_p) +{ +return __dcb_get_attribute (dcb,DCB_CMD_IEEE_GET , dev, attr, + payload_p, payload_len_p, + dcb_get_attribute_cb); +} + +int dcb_get_attribute_bare (struct dcb *dcb,int cmd,const char *dev,int attr, +void **payload_p,__u16 *payload_len_p) +{ +return __dcb_get_attribute (dcb, cmd, dev, attr, + payload_p, payload_len_p, + dcb_get_attribute_bare_cb); +} + +int dcb_get_attribute (struct dcb *dcb,const char *dev,int attr,void *data,size_t data_len) +{ +__u16 payload_len; +void *payload; +int ret; + + ret =dcb_get_attribute_va (dcb, dev, attr, &payload, &payload_len); +if (ret) +return ret; + +if (payload_len != data_len) { +fprintf (stderr,"Wrong len %d, expected %zd\n" , payload_len, data_len); +return -EINVAL ; + } + +memcpy (data, payload, data_len);return 0 ; }
dcb/dcb.h +4 -0
@@ -33,9 +33,13 @@ int dcb_get_attribute(struct dcb *dcb, const char *dev, int attr, void *data, size_t data_len);int dcb_set_attribute (struct dcb *dcb,const char *dev,int attr,const void *data,size_t data_len); +int dcb_get_attribute_va (struct dcb *dcb,const char *dev,int attr, +void **payload_p,__u16 *payload_len_p);int dcb_set_attribute_va (struct dcb *dcb,int command,const char *dev,int (*cb)(struct dcb *dcb,struct nlmsghdr *nlh,void *data),void *data); +int dcb_get_attribute_bare (struct dcb *dcb,int cmd,const char *dev,int attr, +void **payload_p,__u16 *payload_len_p);int dcb_set_attribute_bare (struct dcb *dcb,int command,const char *dev,int attr,const void *data,size_t data_len,int response_attr);
Signature · 1 line
2.25.1
PATCH 7/9 dcb: Support -n to suppress translation to nice names
In reply to Petr MachataSome 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.
--- dcb/dcb.c | 9 +++++++-- dcb/dcb.h | 1 + man/man8/dcb.8 | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-)
dcb/dcb.c +7 -2
@@ -467,7 +467,8 @@ static void dcb_help(void)" dcb [ -f | --force ] { -b | --batch } filename [ -N | --Netns ] netnsname\n" "where OBJECT := { buffer | ets | maxrate | pfc }\n" " OPTIONS := [ -V | --Version | -i | --iec | -j | --json\n" - " | -p | --pretty | -s | --statistics | -v | --verbose]\n"); +" | -n | --no-nice-names | -p | --pretty\n" + " | -s | --statistics | -v | --verbose]\n"); }static int dcb_cmd (struct dcb *dcb,int argc,char **argv)
@@ -509,6 +510,7 @@ int main(int argc, char **argv) { "batch", required_argument, NULL, 'b' }, { "iec", no_argument, NULL, 'i' }, { "json", no_argument, NULL, 'j' }, + { "no-nice-names", no_argument, NULL, 'n' }, { "pretty", no_argument, NULL, 'p' }, { "statistics", no_argument, NULL, 's' }, { "Netns", required_argument, NULL, 'N' },
@@ -528,7 +530,7 @@ int main(int argc, char **argv)return EXIT_FAILURE ; } -while ((opt =getopt_long (argc, argv,"b:fhijpsvN:V" , +while ((opt =getopt_long (argc, argv,"b:fhijnpsvN:V" , long_options,NULL )) >=0 ) {switch (opt) {
@@ -545,6 +547,9 @@ int main(int argc, char **argv)case 'j' : dcb->json_output = true;break ; +case 'n' : + dcb->no_nice_names = true; +break ;case 'p' : pretty = true;break ;
dcb/dcb.h +1 -0
@@ -14,6 +14,7 @@ struct dcb {bool json_output;bool stats;bool use_iec; +bool no_nice_names; }; int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key,
man/man8/dcb.8 +5 -0
@@ -52,6 +52,11 @@ the 1000-based ones (K, M, B). .BR "\-j" , " --json" Generate JSON output. +.TP +.BR "\-n" , " --no-nice-names" +If the subtool in question translates numbers to symbolic names in some way, +suppress this translation. + .TP .BR "\-p" , " --pretty" When combined with -j generate a pretty JSON output.
Signature · 1 line
2.25.1
Re: [PATCH iproute2-next 7/9] dcb: Support -n to suppress translation to nice names
dcb/dcb.c static void dcb_help(void) · line 470
Quoted 10 lines · Petr Machata
dcb/dcb.c +1
-1@@ -467,7 +467,8 @@ static void dcb_help(void)" dcb [ -f | --force ] { -b | --batch } filename [ -N | --Netns ] netnsname\n" "where OBJECT := { buffer | ets | maxrate | pfc }\n" " OPTIONS := [ -V | --Version | -i | --iec | -j | --json\n" - " | -p | --pretty | -s | --statistics | -v | --verbose]\n"); +" | -n | --no-nice-names | -p | --pretty\n"
iproute2 commands really should have a consistent user interface. Unfortunately -N and -n are inconsistent with the newer commands like devlink. dcb has not been released yet so time to fix this.
devlink is the only one using the horribly named 'no-nice-names', and we should avoid propagating that to dcb. At a minimum it should be 'numeric' which is consistent with the others.
My preference is also to have dcb follow ip and tc (vs ss) with '-n' to mean -netns and -N' to mean numeric.
Re: [PATCH iproute2-next 7/9] dcb: Support -n to suppress translation to nice names
Quoted 17 lines · David Ahern
dcb/dcb.c static void dcb_help(void) · line 470
Quoted 10 lines · Petr Machata
dcb/dcb.c +1
-1@@ -467,7 +467,8 @@ static void dcb_help(void)" dcb [ -f | --force ] { -b | --batch } filename [ -N | --Netns ] netnsname\n" "where OBJECT := { buffer | ets | maxrate | pfc }\n" " OPTIONS := [ -V | --Version | -i | --iec | -j | --json\n" - " | -p | --pretty | -s | --statistics | -v | --verbose]\n"); +" | -n | --no-nice-names | -p | --pretty\n" iproute2 commands really should have a consistent user interface. Unfortunately -N and -n are inconsistent with the newer commands like devlink. dcb has not been released yet so time to fix this.
Quoted 6 lines
devlink is the only one using the horribly named 'no-nice-names', and we should avoid propagating that to dcb. At a minimum it should be 'numeric' which is consistent with the others.
My preference is also to have dcb follow ip and tc (vs ss) with '-n' to mean -netns and -N' to mean numeric.
Agreed on all counts.
PATCH 8/9 dcb: Add a subtool for the DCB APP object
In reply to Petr MachataDCB APP interfaces are standardized in 802.1q-2018, and allow configuration of traffic prioritization rules based on several possible headers.
Add a dcb subtool for maintenance and display of the APP table. For example:
# dcb app add dev eni1np1 dscp-prio 0:0 CS3:3 CS6:6
# dcb app show dev eni1np1
dscp-prio 0:0 CS3:3 CS6:6
# dcb app add dev eni1np1 dscp-prio CS3:4
# dcb app show dev eni1np1
dscp-prio 0:0 CS3:3 CS3:4 CS6:6
# dcb app replace dev eni1np1 dscp-prio CS3:5
# dcb app show dev eni1np1
dscp-prio 0:0 CS3:5 CS6:6--- dcb/Makefile | 7 +- dcb/dcb.c | 4 +- dcb/dcb.h | 4 + dcb/dcb_app.c | 796 +++++++++++++++++++++++++++++++++++++++++++++ man/man8/dcb-app.8 | 237 ++++++++++++++ man/man8/dcb.8 | 7 +- 6 files changed, 1052 insertions(+), 3 deletions(-) create mode 100644 dcb/dcb_app.c create mode 100644 man/man8/dcb-app.8
dcb/Makefile +6 -1
@@ -5,7 +5,12 @@ TARGETS := ifeq ($(HAVE_MNL),y) -DCBOBJ = dcb.o dcb_buffer.o dcb_ets.o dcb_maxrate.o dcb_pfc.o +DCBOBJ = dcb.o \ + dcb_app.o \ + dcb_buffer.o \ + dcb_ets.o \ + dcb_maxrate.o \ + dcb_pfc.o TARGETS += dcb endif
dcb/dcb.c +3 -1
@@ -465,7 +465,7 @@ static void dcb_help(void)fprintf (stderr,"Usage: dcb [ OPTIONS ] OBJECT { COMMAND | help }\n" " dcb [ -f | --force ] { -b | --batch } filename [ -N | --Netns ] netnsname\n" -"where OBJECT := { buffer | ets | maxrate | pfc }\n" +"where OBJECT := { app | buffer | ets | maxrate | pfc }\n" " OPTIONS := [ -V | --Version | -i | --iec | -j | --json\n" " | -n | --no-nice-names | -p | --pretty\n" " | -s | --statistics | -v | --verbose]\n" );
@@ -476,6 +476,8 @@ static int dcb_cmd(struct dcb *dcb, int argc, char **argv)if (!argc ||matches (*argv,"help" ) ==0 ) {dcb_help ();return 0 ; + }else if (matches (*argv,"app" ) ==0 ) { +return dcb_cmd_app (dcb, argc -1 , argv +1 ); }else if (matches (*argv,"buffer" ) ==0 ) {return dcb_cmd_buffer (dcb, argc -1 , argv +1 ); }else if (matches (*argv,"ets" ) ==0 ) {
dcb/dcb.h +4 -0
@@ -54,6 +54,10 @@ void dcb_print_array_on_off(const __u8 *array, size_t size);void dcb_print_array_kw (const __u8 *array,size_t array_size,const char *const kw[],size_t kw_size); +/* dcb_app.c */ + +int dcb_cmd_app (struct dcb *dcb,int argc,char **argv); +/* dcb_buffer.c */ int dcb_cmd_buffer (struct dcb *dcb,int argc,char **argv);
dcb/dcb_app.c new file +796 -0
796 lines not on this page · raw message
man/man8/dcb-app.8 new file +237 -0
237 lines not on this page · raw message
man/man8/dcb.8 +6 -1
@@ -9,7 +9,7 @@ dcb \- show / manipulate DCB (Data Center Bridging) settings .ti -8 .B dcb .RI "[ " OPTIONS " ] " -.RB "{ " buffer " | " ets " | " maxrate " | " pfc " }" +.RB "{ " app " | " buffer " | " ets " | " maxrate " | " pfc " }" .RI "{ " COMMAND " | " help " }" .sp
@@ -68,6 +68,10 @@ part of the "show" output. .SH OBJECTS +.TP +.B app +- Configuration of application priority table + .TP .B buffer - Configuration of port buffers
@@ -128,6 +132,7 @@ other values: Exit status is 0 if command was successful or a positive integer upon failure. .SH SEE ALSO +.BR dcb-app (8), .BR dcb-buffer (8), .BR dcb-ets (8), .BR dcb-maxrate (8),
Signature · 1 line
2.25.1
PATCH 9/9 dcb: Add a subtool for the DCBX object
In reply to Petr MachataThe Linux DCBX object is a 1-byte bitfield of flags that configure whether the DCBX protocol is implemented in the device or in the host, and which version of the protocol should be used. Add a tool to access the per-port Linux DCBX object.
For example:
# dcb dcbx set dev eni1np1 host ieee # dcb dcbx show dev eni1np1 host ieee
--- dcb/Makefile | 1 + dcb/dcb.c | 4 +- dcb/dcb.h | 4 + dcb/dcb_dcbx.c | 192 ++++++++++++++++++++++++++++++++++++++++++++ man/man8/dcb-dcbx.8 | 108 +++++++++++++++++++++++++ 5 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 dcb/dcb_dcbx.c create mode 100644 man/man8/dcb-dcbx.8
dcb/Makefile +1 -0
@@ -8,6 +8,7 @@ ifeq ($(HAVE_MNL),y) DCBOBJ = dcb.o \ dcb_app.o \ dcb_buffer.o \ + dcb_dcbx.o \ dcb_ets.o \ dcb_maxrate.o \ dcb_pfc.o
dcb/dcb.c +3 -1
@@ -465,7 +465,7 @@ static void dcb_help(void)fprintf (stderr,"Usage: dcb [ OPTIONS ] OBJECT { COMMAND | help }\n" " dcb [ -f | --force ] { -b | --batch } filename [ -N | --Netns ] netnsname\n" -"where OBJECT := { app | buffer | ets | maxrate | pfc }\n" +"where OBJECT := { app | buffer | dcbx | ets | maxrate | pfc }\n" " OPTIONS := [ -V | --Version | -i | --iec | -j | --json\n" " | -n | --no-nice-names | -p | --pretty\n" " | -s | --statistics | -v | --verbose]\n" );
@@ -480,6 +480,8 @@ static int dcb_cmd(struct dcb *dcb, int argc, char **argv)return dcb_cmd_app (dcb, argc -1 , argv +1 ); }else if (matches (*argv,"buffer" ) ==0 ) {return dcb_cmd_buffer (dcb, argc -1 , argv +1 ); + }else if (matches (*argv,"dcbx" ) ==0 ) { +return dcb_cmd_dcbx (dcb, argc -1 , argv +1 ); }else if (matches (*argv,"ets" ) ==0 ) {return dcb_cmd_ets (dcb, argc -1 , argv +1 ); }else if (matches (*argv,"maxrate" ) ==0 ) {
dcb/dcb.h +4 -0
@@ -62,6 +62,10 @@ int dcb_cmd_app(struct dcb *dcb, int argc, char **argv);int dcb_cmd_buffer (struct dcb *dcb,int argc,char **argv); +/* dcb_dcbx.c */ + +int dcb_cmd_dcbx (struct dcb *dcb,int argc,char **argv); +/* dcb_ets.c */ int dcb_cmd_ets (struct dcb *dcb,int argc,char **argv);
dcb/dcb_dcbx.c new file +192 -0
192 lines not on this page · raw message
man/man8/dcb-dcbx.8 new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.25.1