net/sched: fix parsing of TCA_EXT_WARN_MSG for tc action
Subsystems (3)
cover net/sched: fix parsing of TCA_EXT_WARN_MSG for tc action
In my previous commit 0349b8779cc9 ("sched: add new attr TCA_EXT_WARN_MSG to report tc extact message") I didn't notice the tc action use different enum with filter. So we can't use TCA_EXT_WARN_MSG directly for tc action.
Let's rever the previous fix 923b2e30dc9c ("net/sched: act_api: move TCA_EXT_WARN_MSG to the correct hierarchy") and add a new TCA_ACT_EXT_WARN_MSG for tc action specifically.
Here is the tdc test result:
1..1119
ok 1 d959 - Add cBPF action with valid bytecode ok 2 f84a - Add cBPF action with invalid bytecode ok 3 e939 - Add eBPF action with valid object-file ok 4 282d - Add eBPF action with invalid object-file ok 5 d819 - Replace cBPF bytecode and action control ok 6 6ae3 - Delete cBPF action
ok 7 3e0d - List cBPF actions
ok 8 55ce - Flush BPF actions
ok 9 ccc3 - Add cBPF action with duplicate index ok 10 89c7 - Add cBPF action with invalid index [...]
ok 1115 2348 - Show TBF class
ok 1116 84a0 - Create TEQL with default setting ok 1117 7734 - Create TEQL with multiple device ok 1118 34a9 - Delete TEQL with valid handle ok 1119 6289 - Show TEQL stats
Hangbin Liu (2):
Revert "net/sched: act_api: move TCA_EXT_WARN_MSG to the correct
hierarchy"
net/sched: act_api: add specific EXT_WARN_MSG for tc action
include/uapi/linux/rtnetlink.h | 1 + net/sched/act_api.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.38.1
PATCH 1/2 Revert "net/sched: act_api: move TCA_EXT_WARN_MSG to the correct hierarchy"
This reverts commit 923b2e30dc9cd05931da0f64e2e23d040865c035.
This is not a correct fix as TCA_EXT_WARN_MSG is not a hierarchy to TCA_ACT_TAB. I didn't notice the TC actions use different enum when adding TCA_EXT_WARN_MSG. To fix the difference I will add a new WARN enum in TCA_ROOT_MAX as Jamal suggested.
--- net/sched/act_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/act_api.c +2 -2
@@ -1596,12 +1596,12 @@ static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[],if (tcf_action_dump (skb, actions, bind, ref, false) <0 ) goto out_nlmsg_trim; +nla_nest_end (skb, nest); +if (extack && extack->_msg &&nla_put_string (skb,TCA_EXT_WARN_MSG , extack->_msg)) goto out_nlmsg_trim; -nla_nest_end (skb, nest); - nlh->nlmsg_len =skb_tail_pointer (skb) - b;return skb->len;
Signature · 1 line
2.38.1
Re: [PATCH net 1/2] Revert "net/sched: act_api: move TCA_EXT_WARN_MSG to the correct hierarchy"
Quoted 9 lines · Hangbin Liu
This reverts commit
923b2e30dc9cd05931da0f64e2e23d040865c035.This is not a correct fix as
TCA_EXT_WARN_MSGis not a hierarchy toTCA_ACT_TAB. I didn't notice the TC actions use different enum when addingTCA_EXT_WARN_MSG. To fix the difference I will add a new WARN enum inTCA_ROOT_MAXas Jamal suggested.Signed-off-by Hangbin Liu <[email protected]>
cheers,
jamal
Quoted 26 lines
--- net/sched/act_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/sched/act_api.c +2
-3@@ -1596,12 +1596,12 @@ static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[],if (tcf_action_dump (skb, actions, bind, ref, false) <0 ) goto out_nlmsg_trim; +nla_nest_end (skb, nest); +if (extack && extack->_msg &&nla_put_string (skb,TCA_EXT_WARN_MSG , extack->_msg)) goto out_nlmsg_trim; -nla_nest_end (skb, nest); - nlh->nlmsg_len =skb_tail_pointer (skb) - b;return skb->len; --2.38.1
PATCH 1/2 Revert "tc: m_action: fix parsing of TCA_EXT_WARN_MSG"
In reply to Hangbin LiuThis reverts commit 70b9ebae63ce7e6f9911bdfbcf47a6d18f24159a.
The TCA_EXT_WARN_MSG is not sit within the TCA_ACT_TAB hierarchy. It's belong to the TCA_MAX namespace. I will fix the issue in another patch.
--- tc/m_action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tc/m_action.c +1 -1
@@ -586,7 +586,7 @@ int print_action(struct nlmsghdr *n, void *arg)open_json_object (NULL );tc_dump_action (fp, tb[TCA_ACT_TAB ], tot_acts ? *tot_acts:0 , false); -print_ext_msg (&tb[TCA_ACT_TAB ]); +print_ext_msg (tb);close_json_object ();return 0 ;
Signature · 1 line
2.38.1
Re: [PATCH iproute2 1/2] Revert "tc: m_action: fix parsing of TCA_EXT_WARN_MSG"
Quoted 26 lines · Hangbin Liu
This reverts commit
70b9ebae63ce7e6f9911bdfbcf47a6d18f24159a.The
TCA_EXT_WARN_MSGis not sit within theTCA_ACT_TABhierarchy. It's belong to theTCA_MAXnamespace. I will fix the issue in another patch.Signed-off-by Hangbin Liu <[email protected]>--- tc/m_action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tc/m_action.c +1
-1@@ -586,7 +586,7 @@ int print_action(struct nlmsghdr *n, void *arg)open_json_object (NULL );tc_dump_action (fp, tb[TCA_ACT_TAB ], tot_acts ? *tot_acts:0 , false); -print_ext_msg (&tb[TCA_ACT_TAB ]); +print_ext_msg (tb);close_json_object ();return 0 ;Signature · 1 line
2.38.1
As this patchset misses the cover letter, this covers patch 2/2 as well.
Jakub Kicinski
maintainerRe: [PATCH iproute2 1/2] Revert "tc: m_action: fix parsing of TCA_EXT_WARN_MSG"
In reply to Hangbin LiuQuoted 6 lines · On Tue, 14 Mar 2023 15:04:49 +0800 Hangbin Liu wrote:
This reverts commit
70b9ebae63ce7e6f9911bdfbcf47a6d18f24159a.The
TCA_EXT_WARN_MSGis not sit within theTCA_ACT_TABhierarchy. It's belong to theTCA_MAXnamespace. I will fix the issue in another patch.Signed-off-by Hangbin Liu <[email protected]>
Double check the posting format if it's not just a slip up:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#co-posting-changes-to-user-space-components
Re: [PATCH iproute2 1/2] Revert "tc: m_action: fix parsing of TCA_EXT_WARN_MSG"
Quoted 10 lines · Jakub Kicinski
Quoted 6 lines · On Tue, 14 Mar 2023 15:04:49 +0800 Hangbin Liu wrote:
This reverts commit
70b9ebae63ce7e6f9911bdfbcf47a6d18f24159a.The
TCA_EXT_WARN_MSGis not sit within theTCA_ACT_TABhierarchy. It's belong to theTCA_MAXnamespace. I will fix the issue in another patch.Signed-off-by Hangbin Liu <[email protected]>Double check the posting format if it's not just a slip up:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#co-posting-changes-to-user-space-components
Thanks, I will take care of this in the future.
Hangbin
PATCH 2/2 net/sched: act_api: add specific EXT_WARN_MSG for tc action
In reply to Hangbin LiuIn my previous commit 0349b8779cc9 ("sched: add new attr TCA_EXT_WARN_MSG to report tc extact message") I didn't notice the tc action use different enum with filter. So we can't use TCA_EXT_WARN_MSG directly for tc action. Let's add a TCA_ACT_EXT_WARN_MSG for tc action specifically and put this param before going to the TCA_ACT_TAB nest.
--- include/uapi/linux/rtnetlink.h | 1 + net/sched/act_api.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-)
include/uapi/linux/rtnetlink.h +1 -0
@@ -789,6 +789,7 @@ enum {TCA_ROOT_FLAGS ,TCA_ROOT_COUNT ,TCA_ROOT_TIME_DELTA ,/* in msecs */ +TCA_ACT_EXT_WARN_MSG , __TCA_ROOT_MAX, #define TCA_ROOT_MAX (__TCA_ROOT_MAX - 1) };
net/sched/act_api.c +4 -4
@@ -1589,6 +1589,10 @@ static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[], t->tca__pad1 =0 ; t->tca__pad2 =0 ; +if (extack && extack->_msg && +nla_put_string (skb,TCA_ACT_EXT_WARN_MSG , extack->_msg)) + goto out_nlmsg_trim; + nest =nla_nest_start_noflag (skb,TCA_ACT_TAB );if (!nest) goto out_nlmsg_trim;
@@ -1598,10 +1602,6 @@ static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[],nla_nest_end (skb, nest); -if (extack && extack->_msg && -nla_put_string (skb,TCA_EXT_WARN_MSG , extack->_msg)) - goto out_nlmsg_trim; - nlh->nlmsg_len =skb_tail_pointer (skb) - b;return skb->len;
Signature · 1 line
2.38.1
Jamal Hadi Salim
maintainerRe: [PATCH net 2/2] net/sched: act_api: add specific EXT_WARN_MSG for tc action
Quoted 42 lines · Hangbin Liu
In my previous commit
0349b8779cc9("sched: add new attrTCA_EXT_WARN_MSGto report tc extact message") I didn't notice the tc action use different enum with filter. So we can't useTCA_EXT_WARN_MSGdirectly for tc action. Let's add aTCA_ACT_EXT_WARN_MSGfor tc action specifically and put this param before going to theTCA_ACT_TABnest.Fixes 0349b8779cc9 ("sched: add new attr TCA_EXT_WARN_MSG to report tc extact message")Signed-off-by Hangbin Liu <[email protected]>--- include/uapi/linux/rtnetlink.h | 1 + net/sched/act_api.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-)include/uapi/linux/rtnetlink.h +1
-0@@ -789,6 +789,7 @@ enum {TCA_ROOT_FLAGS ,TCA_ROOT_COUNT ,TCA_ROOT_TIME_DELTA ,/* in msecs */ +TCA_ACT_EXT_WARN_MSG , __TCA_ROOT_MAX, #define TCA_ROOT_MAX (__TCA_ROOT_MAX - 1) };net/sched/act_api.c +4
-0@@ -1589,6 +1589,10 @@ static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[], t->tca__pad1 =0 ; t->tca__pad2 =0 ; +if (extack && extack->_msg && +nla_put_string (skb,TCA_ACT_EXT_WARN_MSG , extack->_msg)) + goto out_nlmsg_trim; + nest =nla_nest_start_noflag (skb,TCA_ACT_TAB );if (!nest) goto out_nlmsg_trim;
net/sched/act_api.c static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[], · line 1607
Quoted 10 lines
net/sched/act_api.c +0
-4@@ -1598,10 +1602,6 @@ static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[],nla_nest_end (skb, nest); -if (extack && extack->_msg && -nla_put_string (skb,TCA_EXT_WARN_MSG , extack->_msg)) - goto out_nlmsg_trim; - nlh->nlmsg_len =skb_tail_pointer (skb) - b;return skb->len;
Sorry, only thing i should have mentioned earlier - not clear from here:
Do you get two ext warns now in the same netlink message? One for the action and one for the cls?
Something to check:
on terminal1 > tc monitor
on terminal2 > run a command which will get the offload to fail and see what response you get
My concern is you may be getting two warnings in one message.
cheers,
jamal
Quoted 3 lines
--
2.38.1
Re: [PATCH net 2/2] net/sched: act_api: add specific EXT_WARN_MSG for tc action
Quoted 9 lines · Jamal Hadi Salim
Sorry, only thing i should have mentioned earlier - not clear from here:
Do you get two ext warns now in the same netlink message? One for the action and one for the cls?
Something to check:
on terminal1 > tc monitor
on terminal2 > run a command which will get the offload to fail and see what response you getMy concern is you may be getting two warnings in one message.
From the result we only got 1 warning message.
# tc qdisc add dev enp4s0f0np0 ingress # tc filter add dev enp4s0f0np0 ingress flower verbose ct_state +trk+new action drop Warning: mlx5_core: matching on ct_state +new isn't supported.
# tc monitor
qdisc ingress ffff: dev enp4s0f0np0 parent ffff:fff1 ----------------
added chain dev enp4s0f0np0 parent ffff: chain 0
added filter dev enp4s0f0np0 ingress protocol all pref 49152 flower chain 0 handle 0x1
ct_state +trk+new
not_in_hw
action order 1: gact action drop
random type none pass val 0
index 1 ref 1 bind 1mlx5_core: matching on ct_state +new isn't supported ^C
Thanks
Hangbin
Jamal Hadi Salim
maintainerRe: [PATCH net 2/2] net/sched: act_api: add specific EXT_WARN_MSG for tc action
Quoted 28 lines · Hangbin Liu
Quoted 9 lines · Jamal Hadi Salim
Sorry, only thing i should have mentioned earlier - not clear from here:
Do you get two ext warns now in the same netlink message? One for the action and one for the cls?
Something to check:
on terminal1 > tc monitor
on terminal2 > run a command which will get the offload to fail and see what response you getMy concern is you may be getting two warnings in one message.
From the result we only got 1 warning message.
# tc qdisc add dev enp4s0f0np0 ingress # tc filter add dev enp4s0f0np0 ingress flower verbose ct_state +trk+new action drop Warning: mlx5_core: matching on ct_state +new isn't supported.# tc monitor qdisc ingress ffff: dev enp4s0f0np0 parent ffff:fff1 ---------------- added chain dev enp4s0f0np0 parent ffff: chain 0 added filter dev enp4s0f0np0 ingress protocol all pref 49152 flower chain 0 handle 0x1 ct_state +trk+new not_in_hw action order 1: gact action drop random type none pass val 0 index 1 ref 1 bind 1
Quoted 2 lines
mlx5_core: matching onct_state+new isn't supported ^C
Thanks for checking. I was worried from the quick glance that you will end up calling the action code with extack from cls and that the warning will be duplicated.
cheers,
jamal
Re: [PATCH net 2/2] net/sched: act_api: add specific EXT_WARN_MSG for tc action
Quoted 29 lines · Jamal Hadi Salim
Quoted 28 lines · Hangbin Liu
Quoted 9 lines · Jamal Hadi Salim
Sorry, only thing i should have mentioned earlier - not clear from here:
Do you get two ext warns now in the same netlink message? One for the action and one for the cls?
Something to check:
on terminal1 > tc monitor
on terminal2 > run a command which will get the offload to fail and see what response you getMy concern is you may be getting two warnings in one message.
From the result we only got 1 warning message.
# tc qdisc add dev enp4s0f0np0 ingress # tc filter add dev enp4s0f0np0 ingress flower verbose ct_state +trk+new action drop Warning: mlx5_core: matching on ct_state +new isn't supported.# tc monitor qdisc ingress ffff: dev enp4s0f0np0 parent ffff:fff1 ---------------- added chain dev enp4s0f0np0 parent ffff: chain 0 added filter dev enp4s0f0np0 ingress protocol all pref 49152 flower chain 0 handle 0x1 ct_state +trk+new not_in_hw action order 1: gact action drop random type none pass val 0 index 1 ref 1 bind 1
Quoted 6 lines
Quoted 2 lines
mlx5_core: matching onct_state+new isn't supported ^CThanks for checking. I was worried from the quick glance that you will end up calling the action code with extack from cls and that the warning will be duplicated.
The action info should be filled via dump function, which will not call tca_get_fill(). So I think it should be safe. Please correct me if I missed anything.
Thanks
Hangbin
Jamal Hadi Salim
maintainerRe: [PATCH net 2/2] net/sched: act_api: add specific EXT_WARN_MSG for tc action
Quoted 34 lines · Hangbin Liu
Quoted 32 lines · Jamal Hadi Salim
Quoted 30 lines · Hangbin Liu
Quoted 9 lines · Jamal Hadi Salim
Sorry, only thing i should have mentioned earlier - not clear from here:
Do you get two ext warns now in the same netlink message? One for the action and one for the cls?
Something to check:
on terminal1 > tc monitor
on terminal2 > run a command which will get the offload to fail and see what response you getMy concern is you may be getting two warnings in one message.
From the result we only got 1 warning message.
# tc qdisc add dev enp4s0f0np0 ingress # tc filter add dev enp4s0f0np0 ingress flower verbose ct_state +trk+new action drop Warning: mlx5_core: matching on ct_state +new isn't supported.# tc monitor qdisc ingress ffff: dev enp4s0f0np0 parent ffff:fff1 ---------------- added chain dev enp4s0f0np0 parent ffff: chain 0 added filter dev enp4s0f0np0 ingress protocol all pref 49152 flower chain 0 handle 0x1 ct_state +trk+new not_in_hw action order 1: gact action drop random type none pass val 0 index 1 ref 1 bind 1
mlx5_core: matching onct_state+new isn't supported ^C
Quoted 7 lines
Quoted 3 lines
Thanks for checking. I was worried from the quick glance that you will end up calling the action code with extack from cls and that the warning will be duplicated.
The action info should be filled via dump function, which will not call
tca_get_fill(). So I think it should be safe. Please correct me if I missed anything.
Right - for a similar scenario, it will only be called when you offload an action independent of the filter.
cheers,
jamal
Jakub Kicinski
maintainerRe: [PATCH net 2/2] net/sched: act_api: add specific EXT_WARN_MSG for tc action
In reply to Hangbin Liuinclude/uapi/linux/rtnetlink.h enum { · line 792
Quoted 7 lines · On Tue, 14 Mar 2023 14:58:02 +0800 Hangbin Liu wrote:
include/uapi/linux/rtnetlink.h +1
-0@@ -789,6 +789,7 @@ enum {TCA_ROOT_FLAGS ,TCA_ROOT_COUNT ,TCA_ROOT_TIME_DELTA ,/* in msecs */ + TCA_ACT_EXT_WARN_MSG,
Not TCA_ROOT_EXT_... ?
All other attrs in this set are called TCA_ROOT_x
Quoted 2 lines
include/uapi/linux/rtnetlink.h +0
-0__TCA_ROOT_MAX, #define TCA_ROOT_MAX (__TCA_ROOT_MAX - 1)
Re: [PATCH net 2/2] net/sched: act_api: add specific EXT_WARN_MSG for tc action
Quoted 11 lines · Jakub Kicinski
include/uapi/linux/rtnetlink.h enum { · line 792
Quoted 7 lines · On Tue, 14 Mar 2023 14:58:02 +0800 Hangbin Liu wrote:
include/uapi/linux/rtnetlink.h +1
-0@@ -789,6 +789,7 @@ enum {TCA_ROOT_FLAGS ,TCA_ROOT_COUNT ,TCA_ROOT_TIME_DELTA ,/* in msecs */ + TCA_ACT_EXT_WARN_MSG,Not
TCA_ROOT_EXT_... ?
All other attrs in this set are calledTCA_ROOT_x
Hmm, when we discussed this issue, Jamal suggested to use TCAA_EXT_WARN_MSG. I expand it to TCA_ACT_EXT_WARN_MSG to correspond with the format of TCA_*. But your suggest TCA_ROOT_EXT_ also makes sense. I'm OK to change it.
Jamal, what do you think?
Thanks
Hangbin
Jamal Hadi Salim
maintainerRe: [PATCH net 2/2] net/sched: act_api: add specific EXT_WARN_MSG for tc action
Quoted 14 lines · Hangbin Liu
Quoted 11 lines · Jakub Kicinski
include/uapi/linux/rtnetlink.h enum { · line 792
Quoted 7 lines · On Tue, 14 Mar 2023 14:58:02 +0800 Hangbin Liu wrote:
include/uapi/linux/rtnetlink.h +1
-0@@ -789,6 +789,7 @@ enum {TCA_ROOT_FLAGS ,TCA_ROOT_COUNT ,TCA_ROOT_TIME_DELTA ,/* in msecs */ + TCA_ACT_EXT_WARN_MSG,Not
TCA_ROOT_EXT_... ?
All other attrs in this set are calledTCA_ROOT_x
Quoted 5 lines
Hmm, when we discussed this issue, Jamal suggested to use
TCAA_EXT_WARN_MSG. I expand it toTCA_ACT_EXT_WARN_MSGto correspond with the format of TCA_*. But your suggestTCA_ROOT_EXT_also makes sense. I'm OK to change it.Jamal, what do you think?
Yeah, sticking to the TCA_ROOT_ prefixes makes it neater. TCA_ROOT_EXT_WARN_MSG?
cheers,
jamal
PATCH 2/2 tc: m_action: fix parsing of TCA_EXT_WARN_MSG by using different enum
In reply to Hangbin LiuWe can't use TCA_EXT_WARN_MSG directly in tc action as it's using different enum with filter. Let's use a new TCA_ACT_EXT_WARN_MSG for tc action specifically.
--- include/uapi/linux/rtnetlink.h | 1 + tc/m_action.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-)
include/uapi/linux/rtnetlink.h +1 -0
@@ -787,6 +787,7 @@ enum {TCA_ROOT_FLAGS ,TCA_ROOT_COUNT ,TCA_ROOT_TIME_DELTA ,/* in msecs */ +TCA_ACT_EXT_WARN_MSG , __TCA_ROOT_MAX, #define TCA_ROOT_MAX (__TCA_ROOT_MAX - 1) };
tc/m_action.c +6 -1
@@ -586,7 +586,12 @@ int print_action(struct nlmsghdr *n, void *arg)open_json_object (NULL );tc_dump_action (fp, tb[TCA_ACT_TAB ], tot_acts ? *tot_acts:0 , false); -print_ext_msg (tb); + +if (tb[TCA_ACT_EXT_WARN_MSG ]) { +print_string (PRINT_ANY ,"warn" ,"%s" ,rta_getattr_str (tb[TCA_ACT_EXT_WARN_MSG ])); +print_nl (); + } +close_json_object ();return 0 ;
Signature · 1 line
2.38.1
Re: [PATCH iproute2 2/2] tc: m_action: fix parsing of TCA_EXT_WARN_MSG by using different enum
Quoted 6 lines · Hangbin Liu
We can't use
TCA_EXT_WARN_MSGdirectly in tc action as it's using different enum with filter. Let's use a newTCA_ACT_EXT_WARN_MSGfor tc action specifically.Fixes 6035995665b7 ("tc: add new attr TCA_EXT_WARN_MSG")Signed-off-by Hangbin Liu <[email protected]>
thanks!
Signature · 1 line
davide
Quoted 3 lines · Hangbin Liu
In my previous commit
0349b8779cc9("sched: add new attrTCA_EXT_WARN_MSGto report tc extact message") I didn't notice the tc action use different enum with filter. So we can't useTCA_EXT_WARN_MSGdirectly for tc action.
thanks!
Signature · 1 line
davide
Quoted 6 lines · Davide Caratti
Quoted 3 lines · Hangbin Liu
In my previous commit
0349b8779cc9("sched: add new attrTCA_EXT_WARN_MSGto report tc extact message") I didn't notice the tc action use different enum with filter. So we can't useTCA_EXT_WARN_MSGdirectly for tc action.Reported-and-tested-by Davide Caratti <[email protected]>
Thanks Davide, I forgot to add the Reported-by flag.
Hangbin