lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 5 Jun 2023 11:55:54 +0200
From: Simon Horman <simon.horman@...igine.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, mleitner@...hat.com,
	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,
	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:
> Introduce a lookup helper to retrieve the tc_action_ops
> instance given its action id.
> 
> Co-developed-by: Victor Nogueira <victor@...atatu.com>
> Signed-off-by: Victor Nogueira <victor@...atatu.com>
> Co-developed-by: Pedro Tammela <pctammela@...atatu.com>
> Signed-off-by: Pedro Tammela <pctammela@...atatu.com>
> Signed-off-by: Jamal Hadi Salim <jhs@...atatu.com>
> ---
>  include/net/act_api.h |  1 +
>  net/sched/act_api.c   | 35 +++++++++++++++++++++++++++++++++++
>  2 files changed, 36 insertions(+)
> 
> diff --git a/include/net/act_api.h b/include/net/act_api.h
> index 363f7f8b5586..34b9a9ff05ee 100644
> --- a/include/net/act_api.h
> +++ b/include/net/act_api.h
> @@ -205,6 +205,7 @@ int tcf_idr_release(struct tc_action *a, bool bind);
>  
>  int tcf_register_action(struct tc_action_ops *a, struct pernet_operations *ops);
>  int tcf_register_dyn_action(struct net *net, struct tc_action_ops *act);
> +struct tc_action_ops *tc_lookup_action_byid(struct net *net, u32 act_id);
>  int tcf_unregister_action(struct tc_action_ops *a,
>  			  struct pernet_operations *ops);
>  int tcf_unregister_dyn_action(struct net *net, struct tc_action_ops *act);
> diff --git a/net/sched/act_api.c b/net/sched/act_api.c
> index 0ba5a4b5db6f..101c6debf356 100644

> --- a/net/sched/act_api.c
> +++ b/net/sched/act_api.c
> @@ -1084,6 +1084,41 @@ int tcf_unregister_dyn_action(struct net *net, struct tc_action_ops *act)
>  }
>  EXPORT_SYMBOL(tcf_unregister_dyn_action);
>  
> +/* 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;

Hi Jamal, Victor and Pedro,

A minor nit from my side: as this is networking code, please use reverse
xmas tree - longest line to shortest - for local variable declarations.

> +
> +	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;
> +		}
> +	}
> +	read_unlock(&act_mod_lock);
> +
> +	read_lock(&base_net->act_mod_lock);

base_net does not appear to be initialised here.

> +
> +	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);
> +
>  /* lookup by name */
>  static struct tc_action_ops *tc_lookup_action_n(struct net *net, char *kind)
>  {
> -- 
> 2.25.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ