[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALnP8ZYDriSnxVtdUD5_hcvop_ojuTHWoK8DpQ+x4KgBqRTD2w@mail.gmail.com>
Date: Fri, 2 Jun 2023 12:36:34 -0700
From: Marcelo Ricardo Leitner <mleitner@...hat.com>
To: Jamal Hadi Salim <jhs@...atatu.com>
Cc: netdev@...r.kernel.org, deb.chatterjee@...el.com, anjali.singhai@...el.com,
namrata.limaye@...el.com, tom@...anda.io, p4tc-discussions@...devconf.info,
Mahesh.Shirshyad@....com, Vipin.Jain@....com, tomasz.osinski@...el.com,
jiri@...nulli.us, xiyou.wangcong@...il.com, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com, vladbu@...dia.com,
simon.horman@...igine.com, khalidm@...dia.com, toke@...hat.com
Subject: Re: [PATCH RFC v2 net-next 05/28] net/sched: act_api: introduce tc_lookup_action_byid()
On Wed, May 17, 2023 at 07:02:09AM -0400, Jamal Hadi Salim wrote:
> +/* lookup by ID */
> +struct tc_action_ops *tc_lookup_action_byid(struct net *net, u32 act_id)
> +{
> + struct tcf_dyn_act_net *base_net;
> + struct tc_action_ops *a, *res = NULL;
> +
> + if (!act_id)
> + return NULL;
> +
> + read_lock(&act_mod_lock);
> +
> + list_for_each_entry(a, &act_base, head) {
> + if (a->id == act_id) {
> + if (try_module_get(a->owner)) {
> + read_unlock(&act_mod_lock);
> + return a;
> + }
> + break;
It shouldn't call break here but instead already return NULL:
if id matched, it cannot be present on the dyn list.
Moreover, the search be optimized: now that TCA_ID_ is split between
fixed and dynamic ranges (patch #3), it could jump directly into the
right list. Control path performance is also important..
> + }
> + }
> + read_unlock(&act_mod_lock);
> +
> + read_lock(&base_net->act_mod_lock);
> +
> + base_net = net_generic(net, dyn_act_net_id);
> + a = idr_find(&base_net->act_base, act_id);
> + if (a && try_module_get(a->owner))
> + res = a;
> +
> + read_unlock(&base_net->act_mod_lock);
> +
> + return res;
> +}
> +EXPORT_SYMBOL(tc_lookup_action_byid);
Powered by blists - more mailing lists