net: sched: implement action-specific terse dump
Subsystems (3)
PATCH 1/1 net: sched: implement action-specific terse dump
Allow user to request action terse dump with new flag value TCA_FLAG_TERSE_DUMP. Only output essential action info in terse dump (kind, stats and index). This is different from filter terse dump where index is excluded (filter can be identified by its own handle) and cookie is included.
Move tcf_action_dump_terse() function to the beginning of source file in order to call it from tcf_dump_walker().
--- include/uapi/linux/rtnetlink.h | 4 ++ net/sched/act_api.c | 69 ++++++++++++++++++---------------- 2 files changed, 41 insertions(+), 32 deletions(-)
include/uapi/linux/rtnetlink.h +4 -0
@@ -770,8 +770,12 @@ enum {* actions in a dump. All dump responses will contain the number of actions * being dumped stored in for user app's consumption in TCA_ROOT_COUNT * +* TCA_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump that only +* includes essential action info (kind, index, etc.) +* */ #define TCA_FLAG_LARGE_DUMP_ON (1 << 0) +#define TCA_FLAG_TERSE_DUMP (1 << 1)/* New extended info filters for IFLA_EXT_MASK */ #define RTEXT_FILTER_VF (1 << 0)
net/sched/act_api.c +37 -32
105 lines not on this page · raw message
Signature · 1 line
2.29.1
PATCH 1/1 tc: implement support for action terse dump
Implement support for action terse dump using new TCA_FLAG_TERSE_DUMP value of TCA_ROOT_FLAGS tlv. Set the flag when user requested it with following example CLI (-br for 'brief'):
$ tc -s -br actions ls action tunnel_key total acts 2
action order 0: tunnel_key index 1
Action statistics:
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
action order 1: tunnel_key index 2
Action statistics:
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
In terse mode dump only outputs essential data needed to identify the action (kind, index) and stats, if requested by the user.
--- include/uapi/linux/rtnetlink.h | 4 ++++ man/man8/tc.8 | 2 +- tc/m_action.c | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-)
include/uapi/linux/rtnetlink.h +4 -0
@@ -768,8 +768,12 @@ enum {* actions in a dump. All dump responses will contain the number of actions * being dumped stored in for user app's consumption in TCA_ROOT_COUNT * +* TCA_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump that only +* includes essential action info (kind, index, etc.) +* */ #define TCA_FLAG_LARGE_DUMP_ON (1 << 0) +#define TCA_FLAG_TERSE_DUMP (1 << 1)/* New extended info filters for IFLA_EXT_MASK */ #define RTEXT_FILTER_VF (1 << 0)
man/man8/tc.8 +1 -1
@@ -858,7 +858,7 @@ alias. .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. +.BR "tc filter show " and " tc actions ls " commands. .SH "EXAMPLES" .PP
tc/m_action.c +9 -0
@@ -374,6 +374,11 @@ static int tc_print_one_action(FILE *f, struct rtattr *arg)if (err <0 )return err; +if (brief && tb[TCA_ACT_INDEX ]) { +print_uint (PRINT_ANY ,"index" ,"\t index %u" , +rta_getattr_u32 (tb[TCA_ACT_INDEX ])); +print_nl (); + }if (show_stats && tb[TCA_ACT_STATS ]) {print_string (PRINT_FP ,NULL ,"\tAction statistics:" ,NULL );print_nl ();
@@ -737,6 +742,10 @@ static int tc_act_list_or_flush(int *argc_p, char ***argv_p, int event) tail3 =NLMSG_TAIL (&req.n); flag_select.value |=TCA_FLAG_LARGE_DUMP_ON ; flag_select.selector |=TCA_FLAG_LARGE_DUMP_ON ; +if (brief) { + flag_select.value |=TCA_FLAG_TERSE_DUMP ; + flag_select.selector |=TCA_FLAG_TERSE_DUMP ; + }addattr_l (&req.n,MAX_MSG ,TCA_ROOT_FLAGS , &flag_select,sizeof (struct nla_bitfield32 )); tail3->rta_len = (void *)NLMSG_TAIL (&req.n) - (void *) tail3;
Signature · 1 line
2.29.1
Re: [PATCH iproute2-next] tc: implement support for action terse dump
Quoted 5 lines · Vlad Buslov
include/uapi/linux/rtnetlink.h +0
-0
include/uapi/linux/rtnetlink.h enum { · line 777
Quoted 10 lines
include/uapi/linux/rtnetlink.h +4
-0@@ -768,8 +768,12 @@ enum {* actions in a dump. All dump responses will contain the number of actions * being dumped stored in for user app's consumption in TCA_ROOT_COUNT * +* TCA_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump that only +* includes essential action info (kind, index, etc.) +* */ #define TCA_FLAG_LARGE_DUMP_ON (1 << 0) +#define TCA_FLAG_TERSE_DUMP (1 << 1)
there is an existing TCA_DUMP_FLAGS_TERSE. How does this differ and if it really is needed please make it different enough and documented to avoid confusion.
Re: [PATCH iproute2-next] tc: implement support for action terse dump
Quoted 12 lines · David Ahern
Quoted 11 lines · Vlad Buslov
include/uapi/linux/rtnetlink.h +3
-0@@ -768,8 +768,12 @@ enum {* actions in a dump. All dump responses will contain the number of actions * being dumped stored in for user app's consumption in TCA_ROOT_COUNT * +* TCA_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump that only +* includes essential action info (kind, index, etc.) +*
Quoted 8 lines
include/uapi/linux/rtnetlink.h enum { · line 777
Quoted 4 lines
include/uapi/linux/rtnetlink.h +1
-0*/ #define TCA_FLAG_LARGE_DUMP_ON (1 << 0) +#define TCA_FLAG_TERSE_DUMP (1 << 1)there is an existing
TCA_DUMP_FLAGS_TERSE. How does this differ and if it really is needed please make it different enough and documented to avoid confusion.
TCA_FLAG_TERSE_DUMP is a bit in TCA_ROOT_FLAGS tlv which is basically "action flags". TCA_DUMP_FLAGS_TERSE is a bit in TCA_DUMP_FLAGS tlv which is dedicated flags attribute for filter dump. We can't just reuse existing filter dump constant because its value "1" is already taken by TCA_FLAG_LARGE_DUMP_ON. This might look confusing, but what do you suggest? Those are two unrelated tlv's. I can rename the constant name to TCA_FLAG_ACTION_TERSE_DUMP to signify that the flag is action specific, but that would make the naming inconsistent with existing TCA_FLAG_LARGE_DUMP_ON.
Re: [PATCH iproute2-next] tc: implement support for action terse dump
Quoted 23 lines · Vlad Buslov
Quoted 12 lines · David Ahern
Quoted 11 lines · Vlad Buslov
include/uapi/linux/rtnetlink.h +3
-0@@ -768,8 +768,12 @@ enum {* actions in a dump. All dump responses will contain the number of actions * being dumped stored in for user app's consumption in TCA_ROOT_COUNT * +* TCA_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump that only +* includes essential action info (kind, index, etc.) +* Quoted 8 lines
include/uapi/linux/rtnetlink.h enum { · line 777
Quoted 4 lines
include/uapi/linux/rtnetlink.h +1
-0*/ #define TCA_FLAG_LARGE_DUMP_ON (1 << 0) +#define TCA_FLAG_TERSE_DUMP (1 << 1)there is an existing
TCA_DUMP_FLAGS_TERSE. How does this differ and if it really is needed please make it different enough and documented to avoid confusion.
Quoted 10 lines
TCA_FLAG_TERSE_DUMPis a bit inTCA_ROOT_FLAGStlv which is basically "action flags".TCA_DUMP_FLAGS_TERSEis a bit inTCA_DUMP_FLAGStlv which is dedicated flags attribute for filter dump. We can't just reuse existing filter dump constant because its value "1" is already taken byTCA_FLAG_LARGE_DUMP_ON. This might look confusing, but what do you suggest? Those are two unrelated tlv's. I can rename the constant name toTCA_FLAG_ACTION_TERSE_DUMPto signify that the flag is action specific, but that would make the naming inconsistent with existingTCA_FLAG_LARGE_DUMP_ON.
Its unfortunate that the TCA_ prefix ended being used for both filters and actions. Since we only have a couple of flags maybe it is not too late to have a prefix TCAA_ ? For existing flags something like a #define TCAA_FLAG_LARGE_DUMP_ON TCA_FLAG_LARGE_DUMP_ON
in the uapi header will help. Of course that would be a separate patch which will require conversion code in both the kernel and user space.
FWIW, the patch is good for what i tested. So even if you do send an update with a name change please add:
cheers,
jamal
Re: [PATCH iproute2-next] tc: implement support for action terse dump
Quoted 35 lines · Jamal Hadi Salim
Quoted 23 lines · Vlad Buslov
Quoted 12 lines · David Ahern
Quoted 11 lines · Vlad Buslov
include/uapi/linux/rtnetlink.h +3
-0@@ -768,8 +768,12 @@ enum {* actions in a dump. All dump responses will contain the number of actions * being dumped stored in for user app's consumption in TCA_ROOT_COUNT * +* TCA_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump that only +* includes essential action info (kind, index, etc.) +* Quoted 8 lines
include/uapi/linux/rtnetlink.h enum { · line 777
Quoted 4 lines
include/uapi/linux/rtnetlink.h +1
-0*/ #define TCA_FLAG_LARGE_DUMP_ON (1 << 0) +#define TCA_FLAG_TERSE_DUMP (1 << 1)there is an existing
TCA_DUMP_FLAGS_TERSE. How does this differ and if it really is needed please make it different enough and documented to avoid confusion.Quoted 10 lines
TCA_FLAG_TERSE_DUMPis a bit inTCA_ROOT_FLAGStlv which is basically "action flags".TCA_DUMP_FLAGS_TERSEis a bit inTCA_DUMP_FLAGStlv which is dedicated flags attribute for filter dump. We can't just reuse existing filter dump constant because its value "1" is already taken byTCA_FLAG_LARGE_DUMP_ON. This might look confusing, but what do you suggest? Those are two unrelated tlv's. I can rename the constant name toTCA_FLAG_ACTION_TERSE_DUMPto signify that the flag is action specific, but that would make the naming inconsistent with existingTCA_FLAG_LARGE_DUMP_ON.
Quoted 7 lines
Its unfortunate that the
TCA_prefix ended being used for both filters and actions. Since we only have a couple of flags maybe it is not too late to have a prefixTCAA_? For existing flags something like a #defineTCAA_FLAG_LARGE_DUMP_ONTCA_FLAG_LARGE_DUMP_ON
in the uapi header will help. Of course that would be a separate patch which will require conversion code in both the kernel and user space.
I can send a followup patch, assuming David is satisfied with proposed change.
Quoted 8 lines
FWIW, the patch is good for what i tested. So even if you do send an update with a name change please add:
Acked-by Jamal Hadi Salim <[email protected]>cheers,
jamal
Re: [PATCH iproute2-next] tc: implement support for action terse dump
Quoted 10 lines · Vlad Buslov
Quoted 9 lines
Quoted 1 line
Its unfortunate that the
TCA_prefix ended being used for both filters and actions. Since we only have a couple of flags maybe it is not too late to have a prefixTCAA_? For existing flags something like a #defineTCAA_FLAG_LARGE_DUMP_ONTCA_FLAG_LARGE_DUMP_ON
in the uapi header will help. Of course that would be a separate patch which will require conversion code in both the kernel and user space.
Quoted 3 lines
I can send a followup patch, assuming David is satisfied with proposed change.
fine with me.
Jakub Kicinski
maintainerRe: [PATCH iproute2-next] tc: implement support for action terse dump
Quoted 11 lines · On Fri, 6 Nov 2020 13:25:19 -0700 David Ahern wrote:
Quoted 10 lines · Vlad Buslov
Quoted 9 lines
Quoted 1 line
Its unfortunate that the
TCA_prefix ended being used for both filters and actions. Since we only have a couple of flags maybe it is not too late to have a prefixTCAA_? For existing flags something like a #defineTCAA_FLAG_LARGE_DUMP_ONTCA_FLAG_LARGE_DUMP_ON
in the uapi header will help. Of course that would be a separate patch which will require conversion code in both the kernel and user space.
Quoted 4 lines
Quoted 2 lines
I can send a followup patch, assuming David is satisfied with proposed change.
fine with me.
In some ways it helps in some ways it adds to a mix of confusing acronyms in which TC truly excels.
Are we saying that all new action attrs/defines going forward should be prefixed with TCAA, and all new filters with TCFA?
Otherwise, if it's a one off, I'd vote for including _ACT in the name instead.
Jamal Hadi Salim
maintainerThanks Vlad. Ive run the basic test and it looks good. One thing i discovered while testing is that if the cookie is set, we also want it in the dump. Your earlier comment that it only costs if it was set is on point.
So please remove that check below:
net/sched/act_api.c static size_t tcf_action_fill_size(const struct tc_action *act) · line 237
Quoted 5 lines
net/sched/act_api.c +5
-0+if (cookie && !from_act) { +if (nla_put (skb,TCA_ACT_COOKIE , cookie->len, cookie->data)) { +rcu_read_unlock (); + goto nla_put_failure; + }
cheers,
jamal
Quoted 6 lines · Jamal Hadi Salim
Thanks Vlad. Ive run the basic test and it looks good. One thing i discovered while testing is that if the cookie is set, we also want it in the dump. Your earlier comment that it only costs if it was set is on point.
So please remove that check below:
Okay. Will send V2 shortly.
Quoted 11 lines
net/sched/act_api.c static size_t tcf_action_fill_size(const struct tc_action *act) · line 237
Quoted 7 lines
net/sched/act_api.c +5
-0+if (cookie && !from_act) { +if (nla_put (skb,TCA_ACT_COOKIE , cookie->len, cookie->data)) { +rcu_read_unlock (); + goto nla_put_failure; + }cheers,
jamal