diff mbox series

[iproute2-next,v2,2/2] tc: q_red: Implement has_block for RED

Message ID 18f80c432a0d278d32711bdafdd9d2376028ad50.1594914405.git.petrm@mellanox.com
State Superseded
Delegated to: David Ahern
Headers show
Series Support showing a block bound by qevent | expand

Commit Message

Petr Machata July 16, 2020, 3:49 p.m. UTC
In order for "tc filter show block X" to find a given block, implement the
has_block callback.

Signed-off-by: Petr Machata <petrm@mellanox.com>
---
 tc/q_red.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Jiri Pirko July 16, 2020, 4:07 p.m. UTC | #1
Thu, Jul 16, 2020 at 05:49:46PM CEST, petrm@mellanox.com wrote:
>In order for "tc filter show block X" to find a given block, implement the
>has_block callback.
>
>Signed-off-by: Petr Machata <petrm@mellanox.com>

Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Petr Machata July 16, 2020, 4:37 p.m. UTC | #2
Jiri Pirko <jiri@resnulli.us> writes:

> Thu, Jul 16, 2020 at 05:49:46PM CEST, petrm@mellanox.com wrote:
>>In order for "tc filter show block X" to find a given block, implement the
>>has_block callback.
>>
>>Signed-off-by: Petr Machata <petrm@mellanox.com>
>
> Reviewed-by: Jiri Pirko <jiri@mellanox.com>

Actually it's broken. When there are several qdiscs, the latter one's
result overwrites the previous one.
Jiri Pirko July 16, 2020, 4:52 p.m. UTC | #3
Thu, Jul 16, 2020 at 06:37:22PM CEST, petrm@mellanox.com wrote:
>
>Jiri Pirko <jiri@resnulli.us> writes:
>
>> Thu, Jul 16, 2020 at 05:49:46PM CEST, petrm@mellanox.com wrote:
>>>In order for "tc filter show block X" to find a given block, implement the
>>>has_block callback.
>>>
>>>Signed-off-by: Petr Machata <petrm@mellanox.com>
>>
>> Reviewed-by: Jiri Pirko <jiri@mellanox.com>
>
>Actually it's broken. When there are several qdiscs, the latter one's
>result overwrites the previous one.

:/
diff mbox series

Patch

diff --git a/tc/q_red.c b/tc/q_red.c
index 97856f03..dfef1bf8 100644
--- a/tc/q_red.c
+++ b/tc/q_red.c
@@ -264,10 +264,27 @@  static int red_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstat
 	return 0;
 }
 
+static int red_has_block(struct qdisc_util *qu, struct rtattr *opt, __u32 block_idx, bool *p_has)
+{
+	struct rtattr *tb[TCA_RED_MAX + 1];
+
+	if (opt == NULL)
+		return 0;
+
+	parse_rtattr_nested(tb, TCA_RED_MAX, opt);
+
+	qevents_init(qevents);
+	if (qevents_read(qevents, tb))
+		return -1;
+
+	*p_has = qevents_have_block(qevents, block_idx);
+	return 0;
+}
 
 struct qdisc_util red_qdisc_util = {
 	.id		= "red",
 	.parse_qopt	= red_parse_opt,
 	.print_qopt	= red_print_opt,
 	.print_xstats	= red_print_xstats,
+	.has_block	= red_has_block,
 };