Implement filter terse dump mode support
Subsystems (2)
v2 cover Implement filter terse dump mode support
Implement support for terse dump mode which provides only essential classifier/action info (handle, stats, cookie, etc.). Use new TCA_DUMP_FLAGS_TERSE flag to prevent copying of unnecessary data from kernel.
Vlad Buslov (2):
tc: skip actions that don't have options attribute when printing
tc: implement support for terse dump
man/man8/tc.8 | 6 ++++++ tc/m_bpf.c | 2 +- tc/m_connmark.c | 2 +- tc/m_csum.c | 2 +- tc/m_ct.c | 2 +- tc/m_ctinfo.c | 2 +- tc/m_gact.c | 2 +- tc/m_ife.c | 2 +- tc/m_ipt.c | 2 +- tc/m_mirred.c | 2 +- tc/m_mpls.c | 2 +- tc/m_nat.c | 2 +- tc/m_pedit.c | 2 +- tc/m_sample.c | 2 +- tc/m_simple.c | 2 +- tc/m_skbedit.c | 2 +- tc/m_skbmod.c | 2 +- tc/m_tunnel_key.c | 2 +- tc/m_vlan.c | 2 +- tc/m_xt.c | 2 +- tc/m_xt_old.c | 2 +- tc/tc.c | 6 +++++- tc/tc_filter.c | 9 +++++++++ 23 files changed, 40 insertions(+), 21 deletions(-)
Signature · 1 line
2.21.0
PATCH v2 1/2 tc: skip actions that don't have options attribute when printing
From: Vlad Buslov <[email protected]>
Modify implementations that return error from action_until->print_aopt() callback to silently skip actions that don't have their corresponding TCA_ACT_OPTIONS attribute set (some actions already behave like this). This is necessary to support terse dump mode in following patch in the series.
--- tc/m_bpf.c | 2 +- tc/m_connmark.c | 2 +- tc/m_csum.c | 2 +- tc/m_ct.c | 2 +- tc/m_ctinfo.c | 2 +- tc/m_gact.c | 2 +- tc/m_ife.c | 2 +- tc/m_ipt.c | 2 +- tc/m_mirred.c | 2 +- tc/m_mpls.c | 2 +- tc/m_nat.c | 2 +- tc/m_pedit.c | 2 +- tc/m_sample.c | 2 +- tc/m_simple.c | 2 +- tc/m_skbedit.c | 2 +- tc/m_skbmod.c | 2 +- tc/m_tunnel_key.c | 2 +- tc/m_vlan.c | 2 +- tc/m_xt.c | 2 +- tc/m_xt_old.c | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-)
tc/m_bpf.c +1 -1
@@ -162,7 +162,7 @@ static int bpf_print_opt(struct action_util *au, FILE *f, struct rtattr *arg)int d_ok =0 ;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_ACT_BPF_MAX , arg);
tc/m_connmark.c +1 -1
@@ -111,7 +111,7 @@ static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)struct tc_connmark *ci;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_CONNMARK_MAX , arg);if (tb[TCA_CONNMARK_PARMS ] ==NULL ) {
tc/m_csum.c +1 -1
@@ -167,7 +167,7 @@ print_csum(struct action_util *au, FILE *f, struct rtattr *arg)int uflag_count =0 ;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_CSUM_MAX , arg);
tc/m_ct.c +1 -1
@@ -444,7 +444,7 @@ static int print_ct(struct action_util *au, FILE *f, struct rtattr *arg)int ct_action =0 ;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_CT_MAX , arg);if (tb[TCA_CT_PARMS ] ==NULL ) {
tc/m_ctinfo.c +1 -1
@@ -189,7 +189,7 @@ static int print_ctinfo(struct action_util *au, FILE *f, struct rtattr *arg)struct tc_ctinfo *ci;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_CTINFO_MAX , arg);if (!tb[TCA_CTINFO_ACT ]) {
tc/m_gact.c +1 -1
@@ -172,7 +172,7 @@ print_gact(struct action_util *au, FILE *f, struct rtattr *arg)struct rtattr *tb[TCA_GACT_MAX +1 ];if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_GACT_MAX , arg);
tc/m_ife.c +1 -1
@@ -228,7 +228,7 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)SPRINT_BUF (b2);if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_IFE_MAX , arg);
tc/m_ipt.c +1 -1
@@ -433,7 +433,7 @@ print_ipt(struct action_util *au, FILE * f, struct rtattr *arg)__u32 hook;if (arg ==NULL ) -return -1 ; +return 0 ; lib_dir =getenv ("IPTABLES_LIB_DIR" );if (!lib_dir)
tc/m_mirred.c +1 -1
@@ -282,7 +282,7 @@ print_mirred(struct action_util *au, FILE *f, struct rtattr *arg)const char *dev;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_MIRRED_MAX , arg);
tc/m_mpls.c +1 -1
@@ -198,7 +198,7 @@ static int print_mpls(struct action_util *au, FILE *f, struct rtattr *arg)__u32 val;if (!arg) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_MPLS_MAX , arg);
tc/m_nat.c +1 -1
@@ -147,7 +147,7 @@ print_nat(struct action_util *au, FILE * f, struct rtattr *arg)int len;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_NAT_MAX , arg);
tc/m_pedit.c +1 -1
@@ -746,7 +746,7 @@ static int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)int err;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_PEDIT_MAX , arg);
tc/m_sample.c +1 -1
@@ -144,7 +144,7 @@ static int print_sample(struct action_util *au, FILE *f, struct rtattr *arg)struct tc_sample *p;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_SAMPLE_MAX , arg);
tc/m_simple.c +1 -1
@@ -166,7 +166,7 @@ static int print_simple(struct action_util *au, FILE *f, struct rtattr *arg)char *simpdata;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_DEF_MAX , arg);
tc/m_skbedit.c +1 -1
@@ -199,7 +199,7 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)struct tc_skbedit *p;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_SKBEDIT_MAX , arg);
tc/m_skbmod.c +1 -1
@@ -169,7 +169,7 @@ static int print_skbmod(struct action_util *au, FILE *f, struct rtattr *arg)SPRINT_BUF (b2);if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_SKBMOD_MAX , arg);
tc/m_tunnel_key.c +1 -1
@@ -671,7 +671,7 @@ static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)struct tc_tunnel_key *parm;if (!arg) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_TUNNEL_KEY_MAX , arg);
tc/m_vlan.c +1 -1
@@ -183,7 +183,7 @@ static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg)struct tc_vlan *parm;if (arg ==NULL ) -return -1 ; +return 0 ;parse_rtattr_nested (tb,TCA_VLAN_MAX , arg);
tc/m_xt.c +1 -1
@@ -320,7 +320,7 @@ print_ipt(struct action_util *au, FILE *f, struct rtattr *arg)__u32 hook;if (arg ==NULL ) -return -1 ; +return 0 ;/* copy tcipt_globals because .opts will be modified by iptables */ struct xtables_globals tmp_tcipt_globals = tcipt_globals;
tc/m_xt_old.c +1 -1
@@ -358,7 +358,7 @@ print_ipt(struct action_util *au, FILE * f, struct rtattr *arg)__u32 hook;if (arg ==NULL ) -return -1 ; +return 0 ;set_lib_dir ();
Signature · 1 line
2.21.0
PATCH v2 2/2 tc: implement support for terse dump
In reply to Vlad BuslovFrom: Vlad Buslov <[email protected]>
Implement support for classifier/action terse dump using new TCA_DUMP_FLAGS tlv with only available flag value TCA_DUMP_FLAGS_TERSE. Set the flag when user requested it with following example CLI (-br for 'brief'):
Quoted 1 line
tc -s -br filter show dev ens1f0 ingress
In terse mode dump only outputs essential data needed to identify the filter and action (handle, cookie, etc.) and stats, if requested by the user. The intention is to significantly improve rule dump rate by omitting all static data that do not change after rule is created.
---
Notes:
Changes V1 -> V2:
- Invoke terse dump with tc command '-brief' option instead of filter-specific 'terse' flag.
- Extend tc man and usage string with new option.
man/man8/tc.8 | 6 ++++++ tc/tc.c | 6 +++++- tc/tc_filter.c | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-)
man/man8/tc.8 +6 -0
@@ -854,6 +854,12 @@ option for creating alias. .RE +.TP +.BR "\-br" , " \-brief" +Print only essential data needed to identify the filter and action (handle, +cookie, etc.) and stats. This option is currently only supported by +.BR "tc filter show " command. + .SH "EXAMPLES" .PP tc -g class show dev eth0
tc/tc.c +5 -1
@@ -44,6 +44,7 @@ bool use_names;int json;int color;int oneline; +int brief;static char *conf_file;
@@ -202,7 +203,8 @@ static void usage(void)" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[aw] |\n" " -o[neline] | -j[son] | -p[retty] | -c[olor]\n" " -b[atch] [filename] | -n[etns] name | -N[umeric] |\n" - " -nm | -nam[es] | { -cf | -conf } path }\n"); +" -nm | -nam[es] | { -cf | -conf } path\n" + " -br[ief] }\n"); }static int do_cmd (int argc,char **argv)
@@ -336,6 +338,8 @@ int main(int argc, char **argv) ++json; }else if (matches (argv[1 ],"-oneline" ) ==0 ) { ++oneline; + }else if (matches (argv[1 ],"-brief" ) ==0 ) { + ++brief; }else { fprintf(stderr, "Option \"%s\" is unknown, try \"tc -help\".\n",
tc/tc_filter.c +9 -0
@@ -721,6 +721,15 @@ static int tc_filter_list(int cmd, int argc, char **argv)if (filter_chain_index_set)addattr32 (&req.n,sizeof (req),TCA_CHAIN , chain_index); +if (brief) { +struct nla_bitfield32 flags = { + .value =TCA_DUMP_FLAGS_TERSE , + .selector =TCA_DUMP_FLAGS_TERSE + }; + +addattr_l (&req.n,MAX_MSG ,TCA_DUMP_FLAGS , &flags,sizeof (flags)); + } +if (rtnl_dump_request_n (&rth, &req.n) <0 ) {perror ("Cannot send dump request" );return 1 ;
Signature · 1 line
2.21.0
Re: [PATCH iproute2-next v2 2/2] tc: implement support for terse dump
Quoted 6 lines · Vlad Buslov
From: Vlad Buslov <[email protected]>
Implement support for classifier/action terse dump using new
TCA_DUMP_FLAGStlv with only available flag valueTCA_DUMP_FLAGS_TERSE. Set the flag when user requested it with following example CLI (-br for 'brief'):
Quoted 7 lines
Quoted 1 line
tc -s -br filter show dev ens1f0 ingress
In terse mode dump only outputs essential data needed to identify the filter and action (handle, cookie, etc.) and stats, if requested by the user. The intention is to significantly improve rule dump rate by omitting all static data that do not change after rule is created.
I really want to get agreement from other heavy tc users about what the right information is for a brief mode.
Re: [PATCH iproute2-next v2 2/2] tc: implement support for terse dump
Quoted 9 lines · David Ahern
Quoted 8 lines · Vlad Buslov
From: Vlad Buslov <[email protected]>
Implement support for classifier/action terse dump using new
TCA_DUMP_FLAGStlv with only available flag valueTCA_DUMP_FLAGS_TERSE. Set the flag when user requested it with following example CLI (-br for 'brief'):Quoted 1 line
tc -s -br filter show dev ens1f0 ingress
Quoted 8 lines
Quoted 5 lines
In terse mode dump only outputs essential data needed to identify the filter and action (handle, cookie, etc.) and stats, if requested by the user. The intention is to significantly improve rule dump rate by omitting all static data that do not change after rule is created.
I really want to get agreement from other heavy tc users about what the right information is for a brief mode.
Vlad, would have been helpful in your commit log to show both terse vs no terse (or at least the terse output). Cant tell short of patching and testing. Having said that:
The differentiation via TCA_DUMP_FLAGS_TERSE in the request is in my opinion sufficient to accept the patch.
Also, assuming you have tested with outstanding tc tests for the first patch i think it looks reasoan
cheers,
jamal
Re: [PATCH iproute2-next v2 2/2] tc: implement support for terse dump
Quoted 19 lines · Jamal Hadi Salim
Quoted 9 lines · David Ahern
Quoted 8 lines · Vlad Buslov
From: Vlad Buslov <[email protected]>
Implement support for classifier/action terse dump using new
TCA_DUMP_FLAGStlv with only available flag valueTCA_DUMP_FLAGS_TERSE. Set the flag when user requested it with following example CLI (-br for 'brief'):Quoted 1 line
tc -s -br filter show dev ens1f0 ingress
Quoted 8 lines
Quoted 5 lines
In terse mode dump only outputs essential data needed to identify the filter and action (handle, cookie, etc.) and stats, if requested by the user. The intention is to significantly improve rule dump rate by omitting all static data that do not change after rule is created.
I really want to get agreement from other heavy tc users about what the right information is for a brief mode.
Quoted 7 lines
Vlad, would have been helpful in your commit log to show both terse vs no terse (or at least the terse output). Cant tell short of patching and testing. Having said that:
The differentiation viaTCA_DUMP_FLAGS_TERSEin the request is in my opinion sufficient to accept the patch.
Also, assuming you have tested with outstanding tc tests for the first patch i think it looks reasoan
Hi Jamal,
The existing terse dump tdc tests will have to be changed according with new iproute2 tc syntax for brief(terse) output.
Regards,
Vlad
Re: [PATCH iproute2-next v2 2/2] tc: implement support for terse dump
Quoted 9 lines · Vlad Buslov
On Thu 08 Oct 2020 at 15:58, Jamal Hadi Salim <[email protected]> wrote:
Hi Jamal,
The existing terse dump tdc tests will have to be changed according with new iproute2 tc syntax for brief(terse) output.
Which test(s)?
I see for example d45e mentioning terse but i dont see corresponding code in the iproute2 tree i just pulled.
I feel like changing the tests this early may not be a big issue if they havent propagated in the wild.
cheers,
jamal
Re: [PATCH iproute2-next v2 2/2] tc: implement support for terse dump
Quoted 7 lines · Jamal Hadi Salim
Quoted 6 lines · Vlad Buslov
On Thu 08 Oct 2020 at 15:58, Jamal Hadi Salim <[email protected]> wrote:
Hi Jamal,
Quoted 7 lines
Quoted 3 lines
The existing terse dump tdc tests will have to be changed according with new iproute2 tc syntax for brief(terse) output.
Which test(s)?
I see for example d45e mentioning terse but i dont see corresponding code in the iproute2 tree i just pulled.
Yes. The tests d45e and 7c65 were added as a part of kernel series, but corresponding iproute2 patches were never merged. Tests expect original "terse flag" syntax of V1 iproute2 series and will have to be changed to use -brief option instead.
Quoted 6 lines
I feel like changing the tests this early may not be a big issue if they havent propagated in the wild.
cheers,
jamal
Re: [PATCH iproute2-next v2 2/2] tc: implement support for terse dump
Quoted 11 lines · Vlad Buslov
Quoted 3 lines · Jamal Hadi Salim
Which test(s)?
I see for example d45e mentioning terse but i dont see corresponding code in the iproute2 tree i just pulled.Yes. The tests d45e and 7c65 were added as a part of kernel series, but corresponding iproute2 patches were never merged. Tests expect original "terse flag" syntax of V1 iproute2 series and will have to be changed to use -brief option instead.
Then i dont see a problem in changing the tests.
If you are going to send a v3 please include my acked-by. Would have been nice to see what terse output would have looked like.
cheers,
jamal
Re: [PATCH iproute2-next v2 2/2] tc: implement support for terse dump
Quoted 13 lines · Jamal Hadi Salim
Quoted 11 lines · Vlad Buslov
Quoted 3 lines · Jamal Hadi Salim
Which test(s)?
I see for example d45e mentioning terse but i dont see corresponding code in the iproute2 tree i just pulled.Yes. The tests d45e and 7c65 were added as a part of kernel series, but corresponding iproute2 patches were never merged. Tests expect original "terse flag" syntax of V1 iproute2 series and will have to be changed to use -brief option instead.
Quoted 6 lines
Then i dont see a problem in changing the tests.
If you are going to send a v3 please include my acked-by. Would have been nice to see what terse output would have looked like.cheers,
jamal
Sure. Just waiting for everyone to voice their opinion regarding the output format before proceeding with any changes.
Re: [PATCH iproute2-next v2 2/2] tc: implement support for terse dump
Quoted 19 lines · Vlad Buslov
Quoted 17 lines · Jamal Hadi Salim
Quoted 11 lines · Vlad Buslov
Quoted 3 lines · Jamal Hadi Salim
Which test(s)?
I see for example d45e mentioning terse but i dont see corresponding code in the iproute2 tree i just pulled.Yes. The tests d45e and 7c65 were added as a part of kernel series, but corresponding iproute2 patches were never merged. Tests expect original "terse flag" syntax of V1 iproute2 series and will have to be changed to use -brief option instead.
Then i dont see a problem in changing the tests.
If you are going to send a v3 please include my acked-by. Would have been nice to see what terse output would have looked like.
Quoted 6 lines
Quoted 2 lines
cheers,
jamalSure. Just waiting for everyone to voice their opinion regarding the output format before proceeding with any changes.
go ahead and send a v3 with example output. cc Jamal and Cong