Skip to contentSkip to conversation

Add pcp-prio and new APPTRUST subcommand

RFC PATCH In review Daniel Machon 3 participants 6 messages Sep 9, 2022 – Sep 12, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Add pcp-prio and new APPTRUST subcommand

This patch series implements the interfaces of the kernel side patch series:

https://lore.kernel.org/netdev/[email protected]/#t

This is posted RFC as the kernel side is not ready to be merged yet.

- New pcp-prio parameter has been added to existing app subcommand.
- New apptrust subcommand with parameter trust-order has been added.

Patch #1 Introduces a new pcp-prio parameter to the app subcommand. This new parameter uses the array parameter to map a pcp and dei value to priority. The key is the PCP and DEI value in numerical and symbolic form, respectively. Also dcb-app.8 man page has been extended to describe the new parameter.

Example:

Map PCP 1 and DEI 0 to priority 1

$ dcb app add dev eth0 pcp-prio 1:1

Map PCP 1 and DEI 1 to priority 1

$ dcb app add dev eth0 pcp-prio 1de:1

Patch #2 Introduces a new apptrust subcommand. This new subcommand has currently one parameter: trust-order. It lets you specify a list of trusted selectors, in order of precendence. Also a new dcb-apptrust.8 man page has been added, to describe the ned subcommand and its parameter.

Example:

Trust selectors dscp and pcp, in that order:

$ dcb apptrust set dev eth0 dscp pcp

Trust selectors ethertype, stream and pcp, in that order

$ dcb apptrust set dev eth0 eth stream pcp

Show the trust order

$ dcb apptrust show dev eth0
trust-order: eth stream pcp

Both patches makes changes to the uapi dcbnl.h kernel header. Changes to kernel headers is probably not dealt with this way?

Daniel Machon (2):
dcb: add new pcp-prio parameter to dcb app
dcb: add new subcommand for apptrust object

 dcb/Makefile               |   3 +-
 dcb/dcb.c                  |   4 +-
 dcb/dcb.h                  |   4 +
 dcb/dcb_app.c              |  70 ++++++++++++
 dcb/dcb_apptrust.c         | 216 +++++++++++++++++++++++++++++++++++++
 include/uapi/linux/dcbnl.h |  15 +++
 man/man8/dcb-app.8         |  25 +++++
 man/man8/dcb-apptrust.8    | 122 +++++++++++++++++++++
 8 files changed, 457 insertions(+), 2 deletions(-)
 create mode 100644 dcb/dcb_apptrust.c
 create mode 100644 man/man8/dcb-apptrust.8
Signature · 1 line
2.34.1
#1 lore raw

RFC PATCH 1/2 dcb: add new pcp-prio parameter to dcb app

Add new pcp-prio parameter to the app subcommand, to classify traffic based on PCP and DEI.

The pcp-prio parameter makes use of the PCP selector to encode PCP and DEI values in the protocol field of the app struct. Pcp-prio uses a key:value mapping, where the key is a combination of numerical and symbolic form. For example:

Map PCP 1 and DEI 0 to priority 1

$ dcb app add dev eth0 pcp-prio 1:1

Map PCP 1 and DEI 1 to priority 1

$ dcb app add dev eth0 pcp-prio 1de:1
---
 dcb/dcb_app.c              | 70 ++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/dcbnl.h |  1 +
 man/man8/dcb-app.8         | 25 ++++++++++++++
 3 files changed, 96 insertions(+)
dcb/dcb_app.c +70 -0
index dad34554..74195285 100644
@@ -10,6 +10,11 @@
 #include "utils.h"
 #include "rt_names.h"
 
+static const char *const pcp_names[16] = {
+	"0",   "1",   "2",   "3",   "4",   "5",   "6",   "7",
+	"0de", "1de", "2de", "3de", "4de", "5de", "6de", "7de"
+};
+
 static void dcb_app_help_add(void)
 {
 	fprintf(stderr,
@@ -20,11 +25,13 @@ static void dcb_app_help_add(void)
 		"           [ dgram-port-prio PORT:PRIO ]\n"
 		"           [ port-prio PORT:PRIO ]\n"
 		"           [ dscp-prio INTEGER:PRIO ]\n"
+		"           [ pcp-prio INTEGER:PRIO ]\n"
 		"\n"
 		" where PRIO := { 0 .. 7 }\n"
 		"       ET := { 0x600 .. 0xffff }\n"
 		"       PORT := { 1 .. 65535 }\n"
 		"       DSCP := { 0 .. 63 }\n"
+		"       PCP := { 0(de) .. 7(de) }\n"
 		"\n"
 	);
 }
@@ -39,6 +46,7 @@ static void dcb_app_help_show_flush(void)
 		"           [ dgram-port-prio ]\n"
 		"           [ port-prio ]\n"
 		"           [ dscp-prio ]\n"
+		"           [ pcp-prio ]\n"
 		"\n"
 	);
 }
@@ -213,6 +221,32 @@ static int dcb_app_parse_mapping_ethtype_prio(__u32 key, char *value, void *data
 				 dcb_app_parse_mapping_cb, data);
 }
 
+static int dcb_app_parse_pcp(__u32 *key, const char *arg)
+{
+	int ret, res;
+
+	res = parse_one_of("pcp-names", arg, pcp_names,
+			   ARRAY_SIZE(pcp_names), &ret);
+	if (ret < 0)
+		return ret;
+
+	*key = res;
+
+	return 0;
+}
+
+static int dcb_app_parse_mapping_pcp_prio(__u32 key, char *value, void *data)
+{
+	__u8 prio;
+
+	if (get_u8(&prio, value, 0))
+		return -EINVAL;
+
+	return dcb_parse_mapping("PCP", key, 15,
+				 "PRIO", prio, IEEE_8021QAZ_MAX_TCS - 1,
+				 dcb_app_parse_mapping_cb, data);
+}
+
 static int dcb_app_parse_dscp(__u32 *key, const char *arg)
 {
 	if (parse_mapping_num_all(key, arg) == 0)
@@ -309,6 +343,11 @@ static bool dcb_app_is_dscp(const struct dcb_app *app)
 	return app->selector == IEEE_8021QAZ_APP_SEL_DSCP;
 }
 
+static bool dcb_app_is_pcp(const struct dcb_app *app)
+{
+	return app->selector == IEEE_8021QAZ_APP_SEL_PCP;
+}
+
 static bool dcb_app_is_stream_port(const struct dcb_app *app)
 {
 	return app->selector == IEEE_8021QAZ_APP_SEL_STREAM;
@@ -344,6 +383,14 @@ static int dcb_app_print_key_dscp(__u16 protocol)
 	return print_uint(PRINT_ANY, NULL, "%d:", protocol);
 }
 
+static int dcb_app_print_key_pcp(__u16 protocol)
+{
+	if (protocol > 15)
+		return -1;
+
+	return print_string(PRINT_ANY, NULL, "%s:", pcp_names[protocol]);
+}
+
 static void dcb_app_print_filtered(const struct dcb_app_table *tab,
 				   bool (*filter)(const struct dcb_app *),
 				   int (*print_key)(__u16 protocol),
@@ -382,6 +429,15 @@ static void dcb_app_print_ethtype_prio(const struct dcb_app_table *tab)
 			       "ethtype_prio", "ethtype-prio");
 }
 
+static void dcb_app_print_pcp_prio(const struct dcb *dcb,
+				   const struct dcb_app_table *tab)
+{
+	dcb_app_print_filtered(tab, dcb_app_is_pcp,
+			       dcb->numeric ? dcb_app_print_key_dec
+					    : dcb_app_print_key_pcp,
+			       "pcp_prio", "pcp-prio");
+}
+
 static void dcb_app_print_dscp_prio(const struct dcb *dcb,
 				    const struct dcb_app_table *tab)
 {
@@ -439,6 +495,7 @@ static void dcb_app_print(const struct dcb *dcb, const struct dcb_app_table *tab
 	dcb_app_print_stream_port_prio(tab);
 	dcb_app_print_dgram_port_prio(tab);
 	dcb_app_print_port_prio(tab);
+	dcb_app_print_pcp_prio(dcb, tab);
 }
 
 static int dcb_app_get_table_attr_cb(const struct nlattr *attr, void *data)
@@ -577,6 +634,12 @@ static int dcb_cmd_app_parse_add_del(struct dcb *dcb, const char *dev,
 			ret = parse_mapping(&argc, &argv, false,
 					    &dcb_app_parse_mapping_port_prio,
 					    &pm);
+		} else if (matches(*argv, "pcp-prio") == 0) {
+			NEXT_ARG();
+			pm.selector = IEEE_8021QAZ_APP_SEL_PCP;
+			ret = parse_mapping_gen(&argc, &argv, &dcb_app_parse_pcp,
+						&dcb_app_parse_mapping_pcp_prio,
+						&pm);
 		} else {
 			fprintf(stderr, "What is \"%s\"?\n", *argv);
 			dcb_app_help_add();
@@ -656,6 +719,8 @@ static int dcb_cmd_app_show(struct dcb *dcb, const char *dev, int argc, char **a
 			dcb_app_print_port_prio(&tab);
 		} else if (matches(*argv, "default-prio") == 0) {
 			dcb_app_print_default_prio(&tab);
+		} else if (matches(*argv, "pcp-prio") == 0) {
+			dcb_app_print_pcp_prio(dcb, &tab);
 		} else {
 			fprintf(stderr, "What is \"%s\"?\n", *argv);
 			dcb_app_help_show_flush();
@@ -705,6 +770,11 @@ static int dcb_cmd_app_flush(struct dcb *dcb, const char *dev, int argc, char **
 					      &dcb_app_is_dscp);
 			if (ret != 0)
 				goto out;
+		} else if (matches(*argv, "pcp-prio") == 0) {
+			ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &tab,
+					      &dcb_app_is_pcp);
+			if (ret != 0)
+				goto out;
 		} else {
 			fprintf(stderr, "What is \"%s\"?\n", *argv);
 			dcb_app_help_show_flush();
include/uapi/linux/dcbnl.h +1 -0
index a791a940..8eab16e5 100644
@@ -217,6 +217,7 @@ struct cee_pfc {
 #define IEEE_8021QAZ_APP_SEL_DGRAM	3
 #define IEEE_8021QAZ_APP_SEL_ANY	4
 #define IEEE_8021QAZ_APP_SEL_DSCP       5
+#define IEEE_8021QAZ_APP_SEL_PCP	255
 
 /* This structure contains the IEEE 802.1Qaz APP managed object. This
  * object is also used for the CEE std as well.
man/man8/dcb-app.8 +25 -0
index 9780fe4b..1b3bc307 100644
@@ -23,6 +23,7 @@ the DCB (Data Center Bridging) subsystem
 .RB "[ " dgram-port-prio " ]"
 .RB "[ " port-prio " ]"
 .RB "[ " dscp-prio " ]"
+.RB "[ " pcp-prio " ]"
 
 .ti -8
 .B dcb ets " { " add " | " del " | " replace " } " dev
@@ -33,6 +34,7 @@ the DCB (Data Center Bridging) subsystem
 .RB "[ " dgram-port-prio " " \fIPORT-MAP\fB " ]"
 .RB "[ " port-prio " " \fIPORT-MAP\fB " ]"
 .RB "[ " dscp-prio " " \fIDSCP-MAP\fB " ]"
+.RB "[ " pcp-prio " " \fIPCP-MAP\fB " ]"
 
 .ti -8
 .IR PRIO-LIST " := [ " PRIO-LIST " ] " PRIO
@@ -64,6 +66,9 @@ the DCB (Data Center Bridging) subsystem
 .ti -8
 .IR DSCP " := { " \fB0\fR " .. " \fB63\fR " }"
 
+.ti -8
+.IR PCP " := { " \fB0\fR " .. " \fB7\fR " }"
+
 .ti -8
 .IR PRIO " := { " \fB0\fR " .. " \fB7\fR " }"
 
@@ -182,6 +187,16 @@ command line option
 .B -N
 turns the show translation off.
 
+.TP
+.B pcp-prio \fIPCP-MAP
+\fIPCP-MAP\fR uses the array parameter syntax, see
+.BR dcb (8)
+for details. Keys are PCP/DEI values. Values are priorities assigned to traffic
+with matching PCP and DEI. PCP/DEI values are written as a combination of numeric- and
+symbolic values, to accommodate for both PCP and DEI. PCP always in numerical form e.g
+1 .. 7 and DEI in symbolic form e.g 'de' indicating that the DEI bit is 1.
+In combination 2de:1 translates to a mapping of PCP 2 and DEI 1 to priority 1.
+
 .SH EXAMPLE & USAGE
 
 Prioritize traffic with DSCP 0 to priority 0, 24 to 3 and 48 to 6:
@@ -221,6 +236,16 @@ Flush all DSCP rules:
 .br
 (nothing)
 
+Add a rule to prioritize traffic with PCP 1 and DEI 0 to priority 1 and PCP 2
+and DEI 1 to priority 2:
+
+.P
+# dcb app add dev eth0 pcp-prio 1:1 2de:2
+.br
+# dcb app show dev eth0 pcp-prio
+.br
+pcp-prio 1:1 2de:2
+
 .SH EXIT STATUS
 Exit status is 0 if command was successful or a positive integer upon failure.
 
Signature · 1 line
2.34.1
#2 lore raw

RFC PATCH 2/2 dcb: add new subcommand for apptrust object

In reply to Daniel Machon

Add new apptrust subcommand for the apptrust extension object.

The apptrust command lets you specify a consecutive trust order of app selectors, which can be used by drivers to determine if DSCP, PCP or any other standard selector is trusted, and in which order.

---
 dcb/Makefile               |   3 +-
 dcb/dcb.c                  |   4 +-
 dcb/dcb.h                  |   4 +
 dcb/dcb_apptrust.c         | 216 +++++++++++++++++++++++++++++++++++++
 include/uapi/linux/dcbnl.h |  14 +++
 man/man8/dcb-apptrust.8    | 122 +++++++++++++++++++++
 6 files changed, 361 insertions(+), 2 deletions(-)
 create mode 100644 dcb/dcb_apptrust.c
 create mode 100644 man/man8/dcb-apptrust.8
dcb/Makefile +2 -1
index ca65d467..dd41a559 100644
@@ -7,7 +7,8 @@ DCBOBJ = dcb.o \
          dcb_dcbx.o \
          dcb_ets.o \
          dcb_maxrate.o \
-         dcb_pfc.o
+         dcb_pfc.o \
+         dcb_apptrust.o
 TARGETS += dcb
 LDLIBS += -lm
 
dcb/dcb.c +3 -1
index 8d75ab0a..35acb237 100644
@@ -469,7 +469,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 | dcbx | ets | maxrate | pfc }\n"
+		"where  OBJECT := { app | apptrust | buffer | dcbx | ets | maxrate | pfc }\n"
 		"       OPTIONS := [ -V | --Version | -i | --iec | -j | --json\n"
 		"                  | -N | --Numeric | -p | --pretty\n"
 		"                  | -s | --statistics | -v | --verbose]\n");
@@ -482,6 +482,8 @@ static int dcb_cmd(struct dcb *dcb, int argc, char **argv)
 		return 0;
 	} else if (matches(*argv, "app") == 0) {
 		return dcb_cmd_app(dcb, argc - 1, argv + 1);
+	} else if (matches(*argv, "apptrust") == 0) {
+		return dcb_cmd_apptrust(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) {
dcb/dcb.h +4 -0
index 244c3d3c..e800b0f4 100644
@@ -58,6 +58,10 @@ void dcb_print_array_kw(const __u8 *array, size_t array_size,
 
 int dcb_cmd_app(struct dcb *dcb, int argc, char **argv);
 
+/* dcb_apptrust.c */
+
+int dcb_cmd_apptrust(struct dcb *dcb, int argc, char **argv);
+
 /* dcb_buffer.c */
 
 int dcb_cmd_buffer(struct dcb *dcb, int argc, char **argv);
dcb/dcb_apptrust.c new file +216 -0

216 lines not on this page · raw message

include/uapi/linux/dcbnl.h +14 -0
index 8eab16e5..833466de 100644
@@ -248,6 +248,19 @@ struct dcb_app {
 	__u16	protocol;
 };
 
+#define IEEE_8021QAZ_APP_SEL_MAX 255
+
+/* This structure contains trust order extension to the IEEE 802.1Qaz APP
+ * managed object.
+ *
+ * @order: contains trust ordering of selector values for the IEEE 802.1Qaz
+ *               APP managed object. Lower indexes has higher trust.
+ */
+struct ieee_apptrust {
+	__u8 num;
+	__u8 order[IEEE_8021QAZ_APP_SEL_MAX];
+};
+
 /**
  * struct dcb_peer_app_info - APP feature information sent by the peer
  *
@@ -419,6 +432,7 @@ enum ieee_attrs {
 	DCB_ATTR_IEEE_QCN,
 	DCB_ATTR_IEEE_QCN_STATS,
 	DCB_ATTR_DCB_BUFFER,
+	DCB_ATTR_IEEE_APP_TRUST,
 	__DCB_ATTR_IEEE_MAX
 };
 #define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1)
man/man8/dcb-apptrust.8 new file +122 -0

122 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw

Re: [RFC PATCH iproute2-next 2/2] dcb: add new subcommand for apptrust object

dcb/dcb.c static int dcb_cmd(struct dcb *dcb, int argc, char **argv) · line 487

Quoted 5 lines · On Fri, 9 Sep 2022 12:37:01 +0200 Daniel Machon <[email protected]>…
dcb/dcb.c +2 -0
 	} else if (matches(*argv, "app") == 0) {
 		return dcb_cmd_app(dcb, argc - 1, argv + 1);
+	} else if (matches(*argv, "apptrust") == 0) {
+		return dcb_cmd_apptrust(dcb, argc - 1, argv + 1);
 	} else if (matches(*argv, "buffer") == 0) {

Yet another example of why matches() is bad.

Perhaps this should be named trust instead of apptrust.

#4 lore raw

Re: [RFC PATCH iproute2-next 2/2] dcb: add new subcommand for apptrust object

Den Fri, Sep 09, 2022 at 08:06:31AM -0700 skrev Stephen Hemminger:

Quoted 13 lines

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

dcb/dcb.c static int dcb_cmd(struct dcb *dcb, int argc, char **argv) · line 487

Quoted 5 lines · On Fri, 9 Sep 2022 12:37:01 +0200 Daniel Machon <[email protected]>…
      } else if (matches(*argv, "app") == 0) {
              return dcb_cmd_app(dcb, argc - 1, argv + 1);
dcb/dcb.c +2 -0
+     } else if (matches(*argv, "apptrust") == 0) {
+             return dcb_cmd_apptrust(dcb, argc - 1, argv + 1);
      } else if (matches(*argv, "buffer") == 0) {
Quoted 3 lines

Yet another example of why matches() is bad.

Perhaps this should be named trust instead of apptrust.

Hah, that slipped my mind.

Obviously this wont do. Will have to come up with some different naming in an eventual non-RFC patch.

#5 lore raw

Re: [RFC PATCH iproute2-next 2/2] dcb: add new subcommand for apptrust object

Quoted 14 lines · <[email protected]> writes:

Den Fri, Sep 09, 2022 at 08:06:31AM -0700 skrev Stephen Hemminger:

Quoted 13 lines

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 5 lines · On Fri, 9 Sep 2022 12:37:01 +0200 Daniel Machon <[email protected]>…
      } else if (matches(*argv, "app") == 0) {
              return dcb_cmd_app(dcb, argc - 1, argv + 1);
dcb/dcb.c +2 -0
+     } else if (matches(*argv, "apptrust") == 0) {
+             return dcb_cmd_apptrust(dcb, argc - 1, argv + 1);
      } else if (matches(*argv, "buffer") == 0) {
Quoted 8 lines
Quoted 3 lines

Yet another example of why matches() is bad.

Perhaps this should be named trust instead of apptrust.

Hah, that slipped my mind.

Obviously this wont do. Will have to come up with some different naming in an eventual non-RFC patch.

Wait, this doesn't change anything, does it? "a", "ap" and "app" previously referred to dcb_cmd_app, which they still do with the patch. "appt" etc. were previously rejected, now refer to apptrust.

I've been known to miss issues in this area in the past, and for that reason agree with the sentiment on matches(). But what problem does this patch introduce?

And yeah, +1 for "trust".