Skip to contentSkip to conversation

iproute2 tc: Print qdisc, stats, class, filter info to string rather than FILE

DISCUSSION Vadim Kochan 4 participants 7 messages Jan 7, 2015 – Jan 8, 2015

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

Hi,

I'd like to make possible to generate plot info about class hierarchy with qdisc, filters, stats info, but I see that all this staffs are printed to 'FILE *fp' which makes this hard to implement and seems to me that it should be changed to be printed to 'char *s' (memory safety should be considered by asprintf or similar), so this is a big change but all this is possible and I ready to do it, but before do it I'd like to ask if this could be acceptable as idea.

BUT maybe someone can advise me easier solution ?

Regards,

#1 lore raw
Quoted 9 lines · Vadim Kochan

I'd like to make possible to generate plot info about class hierarchy with qdisc, filters, stats info, but I see that all this staffs are printed to 'FILE *fp' which makes this hard to implement and seems to me that it should be changed to be printed to 'char *s' (memory safety should be considered by asprintf or similar), so this is a big change but all this is possible and I ready to do it, but before do it I'd like to ask if this could be acceptable as idea.

BUT maybe someone can advise me easier solution ?

Would fmemopen/open_memstream(3) do what you want?

#2 lore raw
Quoted 9 lines · Florian Westphal
Quoted 8 lines · Vadim Kochan

I'd like to make possible to generate plot info about class hierarchy with qdisc, filters, stats info, but I see that all this staffs are printed to 'FILE *fp' which makes this hard to implement and seems to me that it should be changed to be printed to 'char *s' (memory safety should be considered by asprintf or similar), so this is a big change but all this is possible and I ready to do it, but before do it I'd like to ask if this could be acceptable as idea.

Quoted 3 lines
Quoted 1 line

BUT maybe someone can advise me easier solution ?

Would fmemopen/open_memstream(3) do what you want?

I briefly looked on it, and it might help, THANKS A LOT!

#3 lore raw
In reply to Vadim Kochan
Quoted 10 lines · On Wed, 7 Jan 2015 23:53:31 +0200 Vadim Kochan <[email protected]> wrote:

Hi,

I'd like to make possible to generate plot info about class hierarchy with qdisc, filters, stats info, but I see that all this staffs are printed to 'FILE *fp' which makes this hard to implement and seems to me that it should be changed to be printed to 'char *s' (memory safety should be considered by asprintf or similar), so this is a big change but all this is possible and I ready to do it, but before do it I'd like to ask if this could be acceptable as idea.

Quoted 7 lines

BUT maybe someone can advise me easier solution ?

Regards,
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Rather than screen scraping tc command, why not use libmnl and get the data you want programmatically.

#4 lore raw
Quoted 15 lines · Stephen Hemminger
Quoted 12 lines · On Wed, 7 Jan 2015 23:53:31 +0200 Vadim Kochan <[email protected]> wrote:

Hi,

I'd like to make possible to generate plot info about class hierarchy with qdisc, filters, stats info, but I see that all this staffs are printed to 'FILE *fp' which makes this hard to implement and seems to me that it should be changed to be printed to 'char *s' (memory safety should be considered by asprintf or similar), so this is a big change but all this is possible and I ready to do it, but before do it I'd like to ask if this could be acceptable as idea.

BUT maybe someone can advise me easier solution ?

Quoted 8 lines
Quoted 5 lines

Regards,
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Rather than screen scraping tc command, why not use libmnl and get the data you want programmatically.

I'd like to have text info from tc on screen and output on the other data format to be the same, just only for this.

#6 lore raw
Quoted 9 lines · Thomas Graf
Quoted 2 lines · Vadim Kochan

I'd like to have text info from tc on screen and output on the other data format to be the same, just only for this.

Look at:
https://github.com/tgraf/libnl/blob/master/src/nl-tctree-list.c

It shows how to use an API to retrieve the information you want and allows to pretty print tc entries.

OK, may be I am not clearly described what I am trying to do ... So I think it might be useful to have an option in TC which would be generate classes graph in plot format but keep the same text info as it is printed on console by default. I just think to re-use the existing code which prints that text info to console but use it for plot generating. Do you think that this not right thing feature to be in TC and it might better to have this separately from TC ?

Thanks,