naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

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

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