tc: Show classes in tree view
Subsystems (2)
RFC 1/1 tc: Show classes in tree view
From: Vadim Kochan <[email protected]>
Added new '-t[ree]' which shows classes dependency in the tree view.
--- include/hlist.h | 6 ++ tc/tc.c | 5 +- tc/tc_class.c | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- tc/tc_common.h | 2 + 4 files changed, 180 insertions(+), 3 deletions(-)
include/hlist.h +6 -0
@@ -53,4 +53,10 @@ static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)pos ; \ pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) +static inline void INIT_HLIST_NODE (struct hlist_node *h) +{ + h->next =NULL ; + h->pprev =NULL ; +} +#endif /* __HLIST_H__ */
tc/tc.c +4 -1
@@ -34,8 +34,9 @@ int show_stats = 0;int show_details =0 ;int show_raw =0 ;int show_pretty =0 ; -int batch_mode =0 ; +int show_tree =0 ; +int batch_mode =0 ;int resolve_hosts =0 ;int use_iec =0 ;int force =0 ;
@@ -278,6 +279,8 @@ int main(int argc, char **argv) ++show_raw; }else if (matches (argv[1 ],"-pretty" ) ==0 ) { ++show_pretty; + }else if (matches (argv[1 ],"-tree" ) ==0 ) { + ++show_tree; }else if (matches (argv[1 ],"-Version" ) ==0 ) {printf ("tc utility, iproute2-ss%s\n" ,SNAPSHOT );return 0 ;
tc/tc_class.c +168 -2
206 lines not on this page · raw message
tc/tc_common.h +2 -0
@@ -19,3 +19,5 @@ extern int parse_estimator(int *p_argc, char ***p_argv, struct tc_estimator *eststruct tc_sizespec ;extern int parse_size_table (int *p_argc,char ***p_argv,struct tc_sizespec *s);extern int check_size_table_opts (struct tc_sizespec *s); + +extern int show_tree;
Signature · 1 line
2.1.3
From: Vadim Kochan
Quoted 2 lines
Added new '-t[ree]' which shows classes dependency in the tree view.
...
tc/tc.c int main(int argc, char **argv) · line 286
Quoted 9 lines
tc/tc.c +2
-0@@ -278,6 +279,8 @@ int main(int argc, char **argv) ++show_raw; }else if (matches (argv[1 ],"-pretty" ) ==0 ) { ++show_pretty; + }else if (matches (argv[1 ],"-tree" ) ==0 ) { + ++show_tree; }else if (matches (argv[1 ],"-Version" ) ==0 ) {printf ("tc utility, iproute2-ss%s\n" ,SNAPSHOT );return 0 ;
Clearly you've followed the old code, but it is much clearer to assign 1 (or true) rather than doing an increment (unless you expect '-tree -tree' to do something extra).
I believe the whole business of using 'foo++' to change a 0 to a 1 harks back to the pdp11 where it was a shorter instruction sequence.
David
Quoted 6 lines · Vadim Kochan
From: Vadim Kochan <[email protected]>
Added new '-t[ree]' which shows classes dependency in the tree view.
Signed-off-by Vadim Kochan <[email protected]>
A sample output would convince people more easily.
Quoted 9 lines · Cong Wang
Quoted 6 lines · Vadim Kochan
From: Vadim Kochan <[email protected]>
Added new '-t[ree]' which shows classes dependency in the tree view.
Signed-off-by Vadim Kochan <[email protected]>A sample output would convince people more easily.
Yeah, good point:
# tc/tc -t class show dev tap0
+---1:2(htb) rate 6Mbit ceil 6Mbit burst 15Kb cburst 1599b
| +---1:40(htb) prio 0 rate 5Mbit ceil 5Mbit burst 15Kb cburst 1600b
| +---1:50(htb) prio 0 rate 3Mbit ceil 6Mbit burst 15Kb cburst 1599b
| +---1:60(htb) prio 0 rate 1Kbit ceil 6Mbit burst 15Kb cburst 1599b
|
+---1:1(htb) rate 6Mbit ceil 6Mbit burst 15Kb cburst 1599b
+---1:10(htb) prio 0 rate 5Mbit ceil 5Mbit burst 15Kb cburst 1600b
+---1:20(htb) prio 0 rate 3Mbit ceil 6Mbit burst 15Kb cburst 1599b
+---1:30(htb) prio 0 rate 1Kbit ceil 6Mbit burst 15Kb cburst 1599b # tc/tc -t -s class show dev tap0
+---1:2(htb) rate 6Mbit ceil 6Mbit burst 15Kb cburst 1599b
| | Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| | rate 0bit 0pps backlog 0b 0p requeues 0
| |
| +---1:40(htb) prio 0 rate 5Mbit ceil 5Mbit burst 15Kb cburst 1600b
| | Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| | rate 0bit 0pps backlog 0b 0p requeues 0
| |
| +---1:50(htb) prio 0 rate 3Mbit ceil 6Mbit burst 15Kb cburst 1599b
| | Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| | rate 0bit 0pps backlog 0b 0p requeues 0
| |
| +---1:60(htb) prio 0 rate 1Kbit ceil 6Mbit burst 15Kb cburst 1599b
| Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| rate 0bit 0pps backlog 0b 0p requeues 0
|
+---1:1(htb) rate 6Mbit ceil 6Mbit burst 15Kb cburst 1599b
| Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| rate 0bit 0pps backlog 0b 0p requeues 0
|
+---1:10(htb) prio 0 rate 5Mbit ceil 5Mbit burst 15Kb cburst 1600b
| Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| rate 0bit 0pps backlog 0b 0p requeues 0
|
+---1:20(htb) prio 0 rate 3Mbit ceil 6Mbit burst 15Kb cburst 1599b
| Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| rate 0bit 0pps backlog 0b 0p requeues 0
|
+---1:30(htb) prio 0 rate 1Kbit ceil 6Mbit burst 15Kb cburst 1599b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0