From: shaozhengchao <shaozhengchao@huawei.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<bpf@vger.kernel.org>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<xiyou.wangcong@gmail.com>, <jiri@resnulli.us>,
<martin.lau@linux.dev>, <daniel@iogearbox.net>,
<john.fastabend@gmail.com>, <ast@kernel.org>, <andrii@kernel.org>,
<song@kernel.org>, <yhs@fb.com>, <kpsingh@kernel.org>,
<sdf@google.com>, <haoluo@google.com>, <jolsa@kernel.org>,
<weiyongjun1@huawei.com>, <yuehaibing@huawei.com>
Subject: Re: [PATCH net-next 22/22] net: sched: act: remove redundant code in act_api
Date: Tue, 6 Sep 2022 20:20:41 +0800 [thread overview]
Message-ID: <737b8826-e746-bf96-47f1-478f12b536ec@huawei.com> (raw)
In-Reply-To: <CAM0EoMnbSAgjxxyUuP2C-YZVDL-ydQJex=Xc_ZMzL5P9SHv9FQ@mail.gmail.com>
On 2022/9/2 22:03, Jamal Hadi Salim wrote:
> On Fri, Sep 2, 2022 at 7:22 AM Zhengchao Shao <shaozhengchao@huawei.com> wrote:
>>
>> Based on previous patches of this patchset, the walk and lookup hooks in
>> the tc_action_ops structure are no longer used, and redundant code logic
>> branches should be removed. tcf_generic_walker() and tcf_idr_search() are
>> also used only in the act_api.c, change them to static.
>>
>
> All the rest look good.
> It is possible to have extra computation for a lookup/walk depending on the
> action complexity. That was the point of those APIs; however, we could argue
> that if a user shows up with those demands then we'll add them then.
> If you want to remove the callbacks, why not do them in the first patch?
>
> cheers,
> jamal
>
Hi jamal:
Thank you for your reply. I have test patchset v2 with TDC action
module, and they are all passed. Next, I will add some selftest in other
patchset.
I will reserve the walk and lookup interfaces and delete them only when
they are no longer used.
Zhengchao Shao
>> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
>> ---
>> include/net/act_api.h | 10 ----------
>> net/sched/act_api.c | 42 ++++++++++++------------------------------
>> 2 files changed, 12 insertions(+), 40 deletions(-)
>>
>> diff --git a/include/net/act_api.h b/include/net/act_api.h
>> index a79d6e58519e..ebd84ef06b5b 100644
>> --- a/include/net/act_api.h
>> +++ b/include/net/act_api.h
>> @@ -118,15 +118,10 @@ struct tc_action_ops {
>> struct tcf_result *); /* called under RCU BH lock*/
>> int (*dump)(struct sk_buff *, struct tc_action *, int, int);
>> void (*cleanup)(struct tc_action *);
>> - int (*lookup)(struct net *net, struct tc_action **a, u32 index);
>> int (*init)(struct net *net, struct nlattr *nla,
>> struct nlattr *est, struct tc_action **act,
>> struct tcf_proto *tp,
>> u32 flags, struct netlink_ext_ack *extack);
>> - int (*walk)(struct net *, struct sk_buff *,
>> - struct netlink_callback *, int,
>> - const struct tc_action_ops *,
>> - struct netlink_ext_ack *);
>> void (*stats_update)(struct tc_action *, u64, u64, u64, u64, bool);
>> size_t (*get_fill_size)(const struct tc_action *act);
>> struct net_device *(*get_dev)(const struct tc_action *a,
>> @@ -178,11 +173,6 @@ static inline void tc_action_net_exit(struct list_head *net_list,
>> rtnl_unlock();
>> }
>>
>> -int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
>> - struct netlink_callback *cb, int type,
>> - const struct tc_action_ops *ops,
>> - struct netlink_ext_ack *extack);
>> -int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index);
>> int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est,
>> struct tc_action **a, const struct tc_action_ops *ops,
>> int bind, bool cpustats, u32 flags);
>> diff --git a/net/sched/act_api.c b/net/sched/act_api.c
>> index 7063d2004199..2d26aec25e3a 100644
>> --- a/net/sched/act_api.c
>> +++ b/net/sched/act_api.c
>> @@ -636,10 +636,10 @@ static int tcf_del_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb,
>> return ret;
>> }
>>
>> -int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
>> - struct netlink_callback *cb, int type,
>> - const struct tc_action_ops *ops,
>> - struct netlink_ext_ack *extack)
>> +static int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
>> + struct netlink_callback *cb, int type,
>> + const struct tc_action_ops *ops,
>> + struct netlink_ext_ack *extack)
>> {
>> struct tcf_idrinfo *idrinfo = tn->idrinfo;
>>
>> @@ -653,9 +653,8 @@ int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
>> return -EINVAL;
>> }
>> }
>> -EXPORT_SYMBOL(tcf_generic_walker);
>>
>> -int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index)
>> +static int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index)
>> {
>> struct tcf_idrinfo *idrinfo = tn->idrinfo;
>> struct tc_action *p;
>> @@ -674,7 +673,6 @@ int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index)
>> }
>> return false;
>> }
>> -EXPORT_SYMBOL(tcf_idr_search);
>>
>> static int __tcf_generic_walker(struct net *net, struct sk_buff *skb,
>> struct netlink_callback *cb, int type,
>> @@ -945,8 +943,7 @@ int tcf_register_action(struct tc_action_ops *act,
>> struct tc_action_ops *a;
>> int ret;
>>
>> - if (!act->act || !act->dump || !act->init ||
>> - (!act->net_id && (!act->walk || !act->lookup)))
>> + if (!act->act || !act->dump || !act->init || !act->net_id)
>> return -EINVAL;
>>
>> /* We have to register pernet ops before making the action ops visible,
>> @@ -1658,16 +1655,10 @@ static struct tc_action *tcf_action_get_1(struct net *net, struct nlattr *nla,
>> goto err_out;
>> }
>> err = -ENOENT;
>> - if (ops->lookup) {
>> - if (ops->lookup(net, &a, index) == 0) {
>> - NL_SET_ERR_MSG(extack, "TC action with specified index not found");
>> - goto err_mod;
>> - }
>> - } else {
>> - if (__tcf_idr_search(net, ops, &a, index) == 0) {
>> - NL_SET_ERR_MSG(extack, "TC action with specified index not found");
>> - goto err_mod;
>> - }
>> +
>> + if (__tcf_idr_search(net, ops, &a, index) == 0) {
>> + NL_SET_ERR_MSG(extack, "TC action with specified index not found");
>> + goto err_mod;
>> }
>>
>> module_put(ops->owner);
>> @@ -1730,12 +1721,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
>> goto out_module_put;
>> }
>>
>> - if (ops->walk) {
>> - err = ops->walk(net, skb, &dcb, RTM_DELACTION, ops, extack);
>> - } else {
>> - err = __tcf_generic_walker(net, skb, &dcb, RTM_DELACTION, ops, extack);
>> - }
>> -
>> + err = __tcf_generic_walker(net, skb, &dcb, RTM_DELACTION, ops, extack);
>> if (err <= 0) {
>> nla_nest_cancel(skb, nest);
>> goto out_module_put;
>> @@ -2153,11 +2139,7 @@ static int tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
>> if (nest == NULL)
>> goto out_module_put;
>>
>> - if (a_o->walk)
>> - ret = a_o->walk(net, skb, cb, RTM_GETACTION, a_o, NULL);
>> - else
>> - ret = __tcf_generic_walker(net, skb, cb, RTM_GETACTION, a_o, NULL);
>> -
>> + ret = __tcf_generic_walker(net, skb, cb, RTM_GETACTION, a_o, NULL);
>> if (ret < 0)
>> goto out_module_put;
>>
>> --
>> 2.17.1
>>
>
prev parent reply other threads:[~2022-09-06 12:25 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-02 11:24 [PATCH net-next 00/22] refactor the walk and lookup hook functions in tc_action_ops Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 01/22] net: sched: act_api: implement generic walker and search for tc action Zhengchao Shao
2022-09-02 13:53 ` Jamal Hadi Salim
2022-09-02 11:24 ` [PATCH net-next 02/22] net: sched: act_bpf: get rid of tcf_bpf_walker and tcf_bpf_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 03/22] net: sched: act_connmark: get rid of tcf_connmark_walker and tcf_connmark_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 04/22] net: sched: act_csum: get rid of tcf_csum_walker and tcf_csum_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 05/22] net: sched: act_ct: get rid of tcf_ct_walker and tcf_ct_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 06/22] net: sched: act_ctinfo: get rid of tcf_ctinfo_walker and tcf_ctinfo_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 07/22] net: sched: act_gact: get rid of tcf_gact_walker and tcf_gact_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 08/22] net: sched: act_gate: get rid of tcf_gate_walker and tcf_gate_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 09/22] net: sched: act_ife: get rid of tcf_ife_walker and tcf_ife_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 10/22] net: sched: act_ipt: get rid of tcf_ipt_walker/tcf_xt_walker and tcf_ipt_search/tcf_xt_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 11/22] net: sched: act_mirred: get rid of tcf_mirred_walker and tcf_mirred_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 12/22] net: sched: act_mpls: get rid of tcf_mpls_walker and tcf_mpls_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 13/22] net: sched: act_nat: get rid of tcf_nat_walker and tcf_nat_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 14/22] net: sched: act_pedit: get rid of tcf_pedit_walker and tcf_pedit_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 15/22] net: sched: act_police: get rid of tcf_police_walker and tcf_police_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 16/22] net: sched: act_sample: get rid of tcf_sample_walker and tcf_sample_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 17/22] net: sched: act_simple: get rid of tcf_simp_walker and tcf_simp_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 18/22] net: sched: act_skbedit: get rid of tcf_skbedit_walker and tcf_skbedit_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 19/22] net: sched: act_skbmod: get rid of tcf_skbmod_walker and tcf_skbmod_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 20/22] net: sched: act_tunnel_key: get rid of tunnel_key_walker and tunnel_key_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 21/22] net: sched: act_vlan: get rid of tcf_vlan_walker and tcf_vlan_search Zhengchao Shao
2022-09-02 11:24 ` [PATCH net-next 22/22] net: sched: act: remove redundant code in act_api Zhengchao Shao
2022-09-02 14:03 ` Jamal Hadi Salim
2022-09-06 12:20 ` shaozhengchao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=737b8826-e746-bf96-47f1-478f12b536ec@huawei.com \
--to=shaozhengchao@huawei.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=haoluo@google.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=weiyongjun1@huawei.com \
--cc=xiyou.wangcong@gmail.com \
--cc=yhs@fb.com \
--cc=yuehaibing@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®