Skip to contentSkip to conversation

tc: qdisc: filter qdisc's by parent/handle specification

PATCH In review Anton Danilov 2 participants 5 messages Jun 16, 2020 – Jul 6, 2020

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

PATCH v2 1/1 tc: qdisc: filter qdisc's by parent/handle specification

There wasn't a way to get a qdisc info by handle or parent, only full dump of qdisc's with following grep/sed usage.

The 'qdisc get' command have been added.

tc qdisc { show | get } [ dev STRING ] [ QDISC_ID ] [ invisible ]
QDISC_ID := { root | ingress | handle QHANDLE | parent CLASSID }

This change doesn't require any changes in the kernel.

---

changes since v1:
coding style fixes

---
 man/man8/tc.8 |   8 +++-
 tc/tc_qdisc.c | 111 +++++++++++++++++++++++++++++++++++---------------
 2 files changed, 84 insertions(+), 35 deletions(-)
man/man8/tc.8 +6 -2
index e8e0cd0f..8753088f 100644
@@ -77,9 +77,13 @@ tc \- show / manipulate traffic control settings
 .B tc
 .RI "[ " OPTIONS " ]"
 .RI "[ " FORMAT " ]"
-.B qdisc show [ dev
+.B qdisc { show | get } [ dev
 \fIDEV\fR
-.B ]
+.B ] [ root | ingress | handle
+\fIQHANDLE\fR
+.B | parent
+\fICLASSID\fR
+.B ] [ invisible ]
 .P
 .B tc
 .RI "[ " OPTIONS " ]"
tc/tc_qdisc.c +78 -33

169 lines not on this page · raw message

Signature · 1 line
2.26.2
#1 lore raw

tc/tc_qdisc.c int print_qdisc(struct nlmsghdr *n, void *arg) · line 380

Quoted 4 lines · On Tue, 16 Jun 2020 09:39:02 +0300 Anton Danilov…
tc/tc_qdisc.c +4 -0
+				fprintf(stderr,
+					"only one of parent/handle/root/ingress can be specified\n");
+				arg_error = true;
+				break;

The concept is good, but it could be simplified.

You are repeating same error message several places and it is not necessary to continue parsing after one bad argument.

See what invarg() does.

#2 lore raw

Hello, Stephen. Thanks for feedback.

I'm stuck in the error description. I can use just
invarg("mutually exclusive options", *argv)

But from the user's point of view it isn't completely clear. I think it's better to return a little bit more detailed error message. Something like this:
if (filter_parent)

      invarg("parent is already specified", *argv);
  else if (filter_handle)
      invarg("handle is already specified", *argv);

Also I have declined the idea about adding the get command. Think the show command is enough, and usage of the one more alias is unnecessary.

What do you think about this?

Signature · 1 line
Anton Danilov.
#3 lore raw

PATCH v3 1/1 tc: improve the qdisc show command

In reply to Stephen Hemminger

Before can be possible show only all qeueue disciplines on an interface. There wasn't a way to get the qdisc info by handle or parent, only full dump of the disciplines with a following grep/sed usage.

Now new and old options work as expected to filter a qdisc by handle or parent.

Full syntax of the qdisc show command:

tc qdisc { show | list } [ dev STRING ] [ QDISC_ID ] [ invisible ]
QDISC_ID := { root | ingress | handle QHANDLE | parent CLASSID }

This change doesn't require any changes in the kernel.

---
v2:
- Fix the coding style
v3:
- Make the parameters checking more simple

---
 man/man8/tc.8 |  8 +++--
 tc/tc_qdisc.c | 91 ++++++++++++++++++++++++++++++++-------------------
 2 files changed, 64 insertions(+), 35 deletions(-)
man/man8/tc.8 +6 -2
index 235216b6..305bc569 100644
@@ -77,9 +77,13 @@ tc \- show / manipulate traffic control settings
 .B tc
 .RI "[ " OPTIONS " ]"
 .RI "[ " FORMAT " ]"
-.B qdisc show [ dev
+.B qdisc { show | list } [ dev
 \fIDEV\fR
-.B ]
+.B ] [ root | ingress | handle
+\fIQHANDLE\fR
+.B | parent
+\fICLASSID\fR
+.B ] [ invisible ]
 .P
 .B tc
 .RI "[ " OPTIONS " ]"
tc/tc_qdisc.c +58 -33

144 lines not on this page · raw message

Signature · 1 line
2.26.2
#4 lore raw

Re: [PATCH iproute2 v3] tc: improve the qdisc show command

Quoted 12 lines · On Fri, 3 Jul 2020 18:39:22 +0300 Anton Danilov…

Before can be possible show only all qeueue disciplines on an interface. There wasn't a way to get the qdisc info by handle or parent, only full dump of the disciplines with a following grep/sed usage.

Now new and old options work as expected to filter a qdisc by handle or parent.

Full syntax of the qdisc show command:

tc qdisc { show | list } [ dev STRING ] [ QDISC_ID ] [ invisible ]
QDISC_ID := { root | ingress | handle QHANDLE | parent CLASSID }

Quoted 8 lines

This change doesn't require any changes in the kernel.

---
v2:
- Fix the coding style
v3:
- Make the parameters checking more simple

Applied, thanks