naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/0146-tc-implement-ingress-egress-block-index-attributes-f.patch

36cfb7
From f38f33f8693ed7a4f883b18862e47f822ff8a62d Mon Sep 17 00:00:00 2001
36cfb7
From: Andrea Claudi <aclaudi@redhat.com>
36cfb7
Date: Tue, 18 Jun 2019 20:04:42 +0200
36cfb7
Subject: [PATCH] tc: implement ingress/egress block index attributes for
36cfb7
 qdiscs
36cfb7
36cfb7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1721291
36cfb7
Upstream Status: iproute2.git commit 063463efd7f0d
36cfb7
Conflicts: adjust the code to make it compile due to missing
36cfb7
           commit c91d262f414d2 ("tc: jsonify qdisc core")
36cfb7
36cfb7
commit 063463efd7f0d91b7372b089a7b7aff7fc9ac0f6
36cfb7
Author: Jiri Pirko <jiri@mellanox.com>
36cfb7
Date:   Sat Jan 20 11:00:29 2018 +0100
36cfb7
36cfb7
    tc: implement ingress/egress block index attributes for qdiscs
36cfb7
36cfb7
    During qdisc creation it is possible to specify shared block for bot
36cfb7
    ingress and egress. Pass this values to kernel according to the command
36cfb7
    line options.
36cfb7
36cfb7
    Signed-off-by: Jiri Pirko <jiri@mellanox.com>
36cfb7
    Signed-off-by: David Ahern <dsahern@gmail.com>
36cfb7
---
36cfb7
 man/man8/tc.8 |  6 +++++-
36cfb7
 tc/tc_qdisc.c | 34 ++++++++++++++++++++++++++++++++++
36cfb7
 2 files changed, 39 insertions(+), 1 deletion(-)
36cfb7
36cfb7
diff --git a/man/man8/tc.8 b/man/man8/tc.8
36cfb7
index c493ccfa7c900..c89a7a8ecf83b 100644
36cfb7
--- a/man/man8/tc.8
36cfb7
+++ b/man/man8/tc.8
36cfb7
@@ -11,7 +11,11 @@ tc \- show / manipulate traffic control settings
36cfb7
 \fIqdisc-id\fR
36cfb7
 .B | root ]
36cfb7
 .B [ handle
36cfb7
-\fIqdisc-id\fR ] qdisc
36cfb7
+\fIqdisc-id\fR ]
36cfb7
+.B [ ingress_block
36cfb7
+\fIBLOCK_INDEX\fR ]
36cfb7
+.B [ egress_block
36cfb7
+\fIBLOCK_INDEX\fR ] qdisc
36cfb7
 [ qdisc specific parameters ]
36cfb7
 .P
36cfb7
 
36cfb7
diff --git a/tc/tc_qdisc.c b/tc/tc_qdisc.c
36cfb7
index f8e06ccf205a0..26d23f43007ae 100644
36cfb7
--- a/tc/tc_qdisc.c
36cfb7
+++ b/tc/tc_qdisc.c
36cfb7
@@ -32,6 +32,7 @@ static int usage(void)
36cfb7
 	fprintf(stderr, "       [ handle QHANDLE ] [ root | ingress | clsact | parent CLASSID ]\n");
36cfb7
 	fprintf(stderr, "       [ estimator INTERVAL TIME_CONSTANT ]\n");
36cfb7
 	fprintf(stderr, "       [ stab [ help | STAB_OPTIONS] ]\n");
36cfb7
+	fprintf(stderr, "       [ ingress_block BLOCK_INDEX ] [ egress_block BLOCK_INDEX ]\n");
36cfb7
 	fprintf(stderr, "       [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n");
36cfb7
 	fprintf(stderr, "\n");
36cfb7
 	fprintf(stderr, "       tc qdisc show [ dev STRING ] [ ingress | clsact ]\n");
36cfb7
@@ -62,6 +63,8 @@ static int tc_qdisc_modify(int cmd, unsigned int flags, int argc, char **argv)
36cfb7
 		.n.nlmsg_type = cmd,
36cfb7
 		.t.tcm_family = AF_UNSPEC,
36cfb7
 	};
36cfb7
+	__u32 ingress_block = 0;
36cfb7
+	__u32 egress_block = 0;
36cfb7
 
36cfb7
 	while (argc > 0) {
36cfb7
 		if (strcmp(*argv, "dev") == 0) {
36cfb7
@@ -122,6 +125,14 @@ static int tc_qdisc_modify(int cmd, unsigned int flags, int argc, char **argv)
36cfb7
 			if (parse_size_table(&argc, &argv, &stab.szopts) < 0)
36cfb7
 				return -1;
36cfb7
 			continue;
36cfb7
+		} else if (matches(*argv, "ingress_block") == 0) {
36cfb7
+			NEXT_ARG();
36cfb7
+			if (get_u32(&ingress_block, *argv, 0) || !ingress_block)
36cfb7
+				invarg("invalid ingress block index value", *argv);
36cfb7
+		} else if (matches(*argv, "egress_block") == 0) {
36cfb7
+			NEXT_ARG();
36cfb7
+			if (get_u32(&egress_block, *argv, 0) || !egress_block)
36cfb7
+				invarg("invalid egress block index value", *argv);
36cfb7
 		} else if (matches(*argv, "help") == 0) {
36cfb7
 			usage();
36cfb7
 		} else {
36cfb7
@@ -139,6 +150,13 @@ static int tc_qdisc_modify(int cmd, unsigned int flags, int argc, char **argv)
36cfb7
 	if (est.ewma_log)
36cfb7
 		addattr_l(&req.n, sizeof(req), TCA_RATE, &est, sizeof(est));
36cfb7
 
36cfb7
+	if (ingress_block)
36cfb7
+		addattr32(&req.n, sizeof(req),
36cfb7
+			  TCA_INGRESS_BLOCK, ingress_block);
36cfb7
+	if (egress_block)
36cfb7
+		addattr32(&req.n, sizeof(req),
36cfb7
+			  TCA_EGRESS_BLOCK, egress_block);
36cfb7
+
36cfb7
 	if (q) {
36cfb7
 		if (q->parse_qopt) {
36cfb7
 			if (q->parse_qopt(q, argc, argv, &req.n))
36cfb7
@@ -252,6 +270,22 @@ int print_qdisc(const struct sockaddr_nl *who,
36cfb7
 	if (t->tcm_info != 1)
36cfb7
 		fprintf(fp, "refcnt %d ", t->tcm_info);
36cfb7
 
36cfb7
+	if (tb[TCA_INGRESS_BLOCK] &&
36cfb7
+	    RTA_PAYLOAD(tb[TCA_INGRESS_BLOCK]) >= sizeof(__u32)) {
36cfb7
+		__u32 block = rta_getattr_u32(tb[TCA_INGRESS_BLOCK]);
36cfb7
+
36cfb7
+		if (block)
36cfb7
+			fprintf(fp, "ingress_block %u ", block);
36cfb7
+	}
36cfb7
+
36cfb7
+	if (tb[TCA_EGRESS_BLOCK] &&
36cfb7
+	    RTA_PAYLOAD(tb[TCA_EGRESS_BLOCK]) >= sizeof(__u32)) {
36cfb7
+		__u32 block = rta_getattr_u32(tb[TCA_EGRESS_BLOCK]);
36cfb7
+
36cfb7
+		if (block)
36cfb7
+			fprintf(fp, "egress_block %u ", block);
36cfb7
+	}
36cfb7
+
36cfb7
 	/* pfifo_fast is generic enough to warrant the hardcoding --JHS */
36cfb7
 	if (strcmp("pfifo_fast", RTA_DATA(tb[TCA_KIND])) == 0)
36cfb7
 		q = get_qdisc_kind("prio");
36cfb7
-- 
e138d9
2.21.0
36cfb7