net/sched: cls_api: Fix flow action initialization
Subsystems (3)
PATCH 1/1 net/sched: cls_api: Fix flow action initialization
The cited commit refactored the flow action initialization sequence to use an interface method when translating tc action instances to flow offload objects. The refactored version skips the initialization of the generic flow action attributes for tc actions, such as pedit, that allocate more than one offload entry. This can cause potential issues for drivers mapping flow action ids.
Populate the generic flow action fields for all the flow action entries.
--- net/sched/cls_api.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
net/sched/cls_api.c +13 -4
@@ -3533,7 +3533,7 @@ int tc_setup_action(struct flow_action *flow_action,struct tc_action *actions[], struct netlink_ext_ack *extack) { - int i, j, index, err = 0; + int i, j, k, index, err = 0;struct tc_action *act;BUILD_BUG_ON (TCA_ACT_HW_STATS_ANY !=FLOW_ACTION_HW_STATS_ANY );
@@ -3557,10 +3557,19 @@ int tc_setup_action(struct flow_action *flow_action, entry->hw_index = act->tcfa_index; index =0 ; err =tc_setup_offload_act (act, entry, &index, extack); -if (!err) - j += index; -else +if (err) goto err_out_locked; + +/* initialize the generic parameters for actions that +* allocate more than one offload entry per tc action +*/ +for (k =1 ; k < index ; k++) { + entry[k].hw_stats =tc_act_hw_stats (act->hw_stats); + entry[k].hw_index = act->tcfa_index; + } + + j += index; +spin_unlock_bh (&act->tcfa_lock); }
Signature · 1 line
1.8.3.1
Quoted 41 lines · Oz Shlomo
Subject: [PATCH net] net/sched:
cls_api: Fix flow action initializationThe cited commit refactored the flow action initialization sequence to use an interface method when translating tc action instances to flow offload objects. The refactored version skips the initialization of the generic flow action attributes for tc actions, such as pedit, that allocate more than one offload entry. This can cause potential issues for drivers mapping flow action ids.
Populate the generic flow action fields for all the flow action entries.
Fixes c54e1d920f04 ("flow_offload: add ops to tc_action_ops for flow actionsetup")
Signed-off-by Oz Shlomo <[email protected]>Reviewed-by Roi Dayan <[email protected]>---
net/sched/cls_api.c| 17 +++++++++++++----1 file changed, 13 insertions(+), 4 deletions(-)net/sched/cls_api.c index renamed from net/sched/cls_api.c +0
-0
9bb4d3dcc994..d07c04096560100644net/sched/cls_api.c +1
-1@@ -3533,7 +3533,7 @@ int tc_setup_action(struct flow_action *flow_action,struct tc_action *actions[], struct netlink_ext_ack *extack) { - int i, j, index, err = 0; + int i, j, k, index, err = 0;struct tc_action *act; BUILD_BUG_ON(TCA_ACT_HW_STATS_ANY !=
FLOW_ACTION_HW_STATS_ANY); @@ -3557,10 +3557,19 @@ int tc_setup_action(structflow_action*flow_action,entry->hw_index = act->tcfa_index; index = 0; err = tc_setup_offload_act(act, entry, &index, extack);net/sched/cls_api.c +1
-3-if (!err) - j += index; -else +if (err)goto err_out_locked;
net/sched/cls_api.c int tc_setup_action(struct flow_action *flow_action, · line 3568
Quoted 7 lines
net/sched/cls_api.c +7
-0+ +/* initialize the generic parameters for actions that +* allocate more than one offload entry per tc action +*/ +for (k =1 ; k < index ; k++) { + entry[k].hw_stats =tc_act_hw_stats (act->hw_stats); + entry[k].hw_index = act->tcfa_index;
Thanks Oz for bringing this change to us, I think it makes sense for us when the pedit action is offloaded as a single action.
Just a tiny advice for your reference, maybe we can start assignment from k = 0 and delete the first entry assignment above, then we will put all the general assignment in this loop, it will be more clean, WDYT?
Quoted 9 lines
net/sched/cls_api.c +4
-0+ } + + j += index; +spin_unlock_bh(&act->tcfa_lock); }--
1.8.3.1
Hi Baoweng,
Quoted 43 lines · Baowen Zheng
Quoted 42 lines · Oz Shlomo
Subject: [PATCH net] net/sched:
cls_api: Fix flow action initializationThe cited commit refactored the flow action initialization sequence to use an interface method when translating tc action instances to flow offload objects. The refactored version skips the initialization of the generic flow action attributes for tc actions, such as pedit, that allocate more than one offload entry. This can cause potential issues for drivers mapping flow action ids.
Populate the generic flow action fields for all the flow action entries.
Fixes c54e1d920f04 ("flow_offload: add ops to tc_action_ops for flow actionsetup")
Signed-off-by Oz Shlomo <[email protected]>Reviewed-by Roi Dayan <[email protected]>---
net/sched/cls_api.c| 17 +++++++++++++----1 file changed, 13 insertions(+), 4 deletions(-)net/sched/cls_api.c index renamed from net/sched/cls_api.c +0
-0
9bb4d3dcc994..d07c04096560100644net/sched/cls_api.c +1
-1@@ -3533,7 +3533,7 @@ int tc_setup_action(struct flow_action *flow_action,struct tc_action *actions[], struct netlink_ext_ack *extack) { - int i, j, index, err = 0; + int i, j, k, index, err = 0;struct tc_action *act; BUILD_BUG_ON(TCA_ACT_HW_STATS_ANY !=
FLOW_ACTION_HW_STATS_ANY); @@ -3557,10 +3557,19 @@ int tc_setup_action(structflow_action*flow_action,entry->hw_index = act->tcfa_index; index = 0; err = tc_setup_offload_act(act, entry, &index, extack);net/sched/cls_api.c +1
-3-if (!err) - j += index; -else +if (err)goto err_out_locked;+
Quoted 8 lines
net/sched/cls_api.c int tc_setup_action(struct flow_action *flow_action, · line 3568
Quoted 6 lines
net/sched/cls_api.c +6
-0+/* initialize the generic parameters for actions that +* allocate more than one offload entry per tc action +*/ +for (k =1 ; k < index ; k++) { + entry[k].hw_stats =tc_act_hw_stats (act->hw_stats); + entry[k].hw_index = act->tcfa_index;Thanks Oz for bringing this change to us, I think it makes sense for us when the pedit action is offloaded as a single action.
Just a tiny advice for your reference, maybe we can start assignment from k = 0 and delete the first entry assignment above, then we will put all the general assignment in this loop, it will be more clean, WDYT?
If we do that then the hw_stats and hw_index parameters will not be available to the offload_act_setup method. AFAIU no tc action actually uses these values (so possibly no regression) but perhaps it is better to leave them initialized.
Quoted 10 lines
Quoted 9 lines
net/sched/cls_api.c +4
-0+ } + + j += index; +spin_unlock_bh(&act->tcfa_lock); }--
1.8.3.1
Hi Oz:
Quoted 57 lines · Oz Shlomo
Quoted 6 lines · Baowen Zheng
Quoted 5 lines · Oz Shlomo
Subject: [PATCH net] net/sched:
cls_api: Fix flow action initializationThe cited commit refactored the flow action initialization sequence to use an interface method when translating tc action instances to flow
offload objects.
Quoted 3 lines
Quoted 3 lines
The refactored version skips the initialization of the generic flow action attributes for tc actions, such as pedit, that allocate more than one offload entry. This can cause potential issues for drivers mapping
flow action ids.
Quoted 12 lines
Quoted 12 lines
Populate the generic flow action fields for all the flow action entries.
Fixes c54e1d920f04 ("flow_offload: add ops to tc_action_ops for flowaction
setup")Signed-off-by Oz Shlomo <[email protected]>Reviewed-by Roi Dayan <[email protected]>---
net/sched/cls_api.c| 17 +++++++++++++----1 file changed, 13 insertions(+), 4 deletions(-)Quoted 5 lines
net/sched/cls_api.c int tc_setup_action(struct flow_action
Quoted 5 lines
net/sched/cls_api.c index renamed from net/sched/cls_api.c +0
-0
9bb4d3dcc994..d07c04096560100644net/sched/cls_api.c +0
-0@@ -3533,7 +3533,7 @@ int tc_setup_action(struct flow_action
*flow_action,Quoted 7 lines
net/sched/cls_api.c int tc_setup_action(struct flow_action *flow_action,
Quoted 7 lines
net/sched/cls_api.c +1
-1struct tc_action *actions[], struct netlink_ext_ack *extack) { - int i, j, index, err = 0; + int i, j, k, index, err = 0;struct tc_action *act; BUILD_BUG_ON(TCA_ACT_HW_STATS_ANY !=
FLOW_ACTION_HW_STATS_ANY); @@Quoted 10 lines
Quoted 10 lines
net/sched/cls_api.c +0
-1-3557,10 +3557,19 @@ int tc_setup_action(struct flow_action
*flow_action,entry->hw_index = act->tcfa_index; index = 0; err = tc_setup_offload_act(act, entry, &index, extack);net/sched/cls_api.c +1
-3-if (!err) - j += index; -else +if (err)goto err_out_locked;Quoted 8 lines
net/sched/cls_api.c int tc_setup_action(struct flow_action *flow_action, · line 3568
Quoted 7 lines
net/sched/cls_api.c +7
-0+ +/* initialize the generic parameters for actions that +* allocate more than one offload entry per tc action +*/ +for (k =1 ; k < index ; k++) { + entry[k].hw_stats =tc_act_hw_stats (act->hw_stats); + entry[k].hw_index = act->tcfa_index;Thanks Oz for bringing this change to us, I think it makes sense for us when
the pedit action is offloaded as a single action.
Quoted 8 lines
Quoted 1 line
Just a tiny advice for your reference, maybe we can start assignment from k
= 0 and delete the first entry assignment above, then we will put all the general assignment in this loop, it will be more clean, WDYT?
If we do that then the
hw_statsandhw_indexparameters will not be available to theoffload_act_setupmethod.
AFAIU no tc action actually uses these values (so possibly no regression) but perhaps it is better to leave them initialized.
thanks for clarify about this, for the use of hw_index and hw_stats in tc_setup_offload_act, since we pass the act to function, I think we can get parameters from act if they are needed. What is your opinion?
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
net/sched/cls_api.c +4
-0+ } + + j += index; +spin_unlock_bh(&act->tcfa_lock); }--
1.8.3.1
Hi Baowen,
Quoted 63 lines · Baowen Zheng
Hi Oz:
Quoted 61 lines · Oz Shlomo
Quoted 6 lines · Baowen Zheng
Quoted 5 lines · Oz Shlomo
Subject: [PATCH net] net/sched:
cls_api: Fix flow action initializationThe cited commit refactored the flow action initialization sequence to use an interface method when translating tc action instances to flow
offload objects.
Quoted 3 lines
Quoted 3 lines
The refactored version skips the initialization of the generic flow action attributes for tc actions, such as pedit, that allocate more than one offload entry. This can cause potential issues for drivers mapping
flow action ids.
Quoted 12 lines
Quoted 12 lines
Populate the generic flow action fields for all the flow action entries.
Fixes c54e1d920f04 ("flow_offload: add ops to tc_action_ops for flowaction
setup")Signed-off-by Oz Shlomo <[email protected]>Reviewed-by Roi Dayan <[email protected]>---
net/sched/cls_api.c| 17 +++++++++++++----1 file changed, 13 insertions(+), 4 deletions(-)Quoted 5 lines
net/sched/cls_api.c int tc_setup_action(struct flow_action
Quoted 5 lines
net/sched/cls_api.c index renamed from net/sched/cls_api.c +0
-0
9bb4d3dcc994..d07c04096560100644net/sched/cls_api.c +0
-0@@ -3533,7 +3533,7 @@ int tc_setup_action(struct flow_action
*flow_action,Quoted 7 lines
net/sched/cls_api.c int tc_setup_action(struct flow_action *flow_action,
Quoted 7 lines
net/sched/cls_api.c +1
-1struct tc_action *actions[], struct netlink_ext_ack *extack) { - int i, j, index, err = 0; + int i, j, k, index, err = 0;struct tc_action *act; BUILD_BUG_ON(TCA_ACT_HW_STATS_ANY !=
FLOW_ACTION_HW_STATS_ANY); @@Quoted 10 lines
Quoted 10 lines
net/sched/cls_api.c +0
-1-3557,10 +3557,19 @@ int tc_setup_action(struct flow_action
*flow_action,entry->hw_index = act->tcfa_index; index = 0; err = tc_setup_offload_act(act, entry, &index, extack);net/sched/cls_api.c +1
-3-if (!err) - j += index; -else +if (err)goto err_out_locked;Quoted 8 lines
net/sched/cls_api.c int tc_setup_action(struct flow_action *flow_action, · line 3568
Quoted 7 lines
net/sched/cls_api.c +7
-0+ +/* initialize the generic parameters for actions that +* allocate more than one offload entry per tc action +*/ +for (k =1 ; k < index ; k++) { + entry[k].hw_stats =tc_act_hw_stats (act->hw_stats); + entry[k].hw_index = act->tcfa_index;Thanks Oz for bringing this change to us, I think it makes sense for us when
the pedit action is offloaded as a single action.
Quoted 1 line
Just a tiny advice for your reference, maybe we can start assignment from k
= 0 and delete the first entry assignment above, then we will put all the general assignment in this loop, it will be more clean, WDYT?
Quoted 6 lines
Quoted 4 lines
If we do that then the
hw_statsandhw_indexparameters will not be available to theoffload_act_setupmethod.
AFAIU no tc action actually uses these values (so possibly no regression) but perhaps it is better to leave them initialized.thanks for clarify about this, for the use of
hw_indexandhw_statsintc_setup_offload_act, since we pass the act to function, I think we can get parameters from act if they are needed. What is your opinion?
I agree.
I will send v2.
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
net/sched/cls_api.c +4
-0+ } + + j += index; +spin_unlock_bh(&act->tcfa_lock); }--
1.8.3.1