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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b5cd5f47-eb99-17bf-d88d-9166c49840f6@intel.com>
Date:   Wed, 19 Oct 2022 15:15:04 -0700
From:   Jacob Keller <jacob.e.keller@...el.com>
To:     Jakub Kicinski <kuba@...nel.org>, <davem@...emloft.net>,
        <johannes@...solutions.net>
CC:     <netdev@...r.kernel.org>, <edumazet@...gle.com>,
        <pabeni@...hat.com>, <jiri@...nulli.us>, <razor@...ckwall.org>,
        <nicolas.dichtel@...nd.com>, <gnault@...hat.com>, <fw@...len.de>
Subject: Re: [PATCH net-next 11/13] genetlink: inline old iteration helpers

On 10/18/2022 4:07 PM, Jakub Kicinski wrote:
> All dumpers use the iterators now, inline the cmd by index
> stuff into iterator code.
> 

Makes sense.

Reviewed-by: Jacob Keller <jacob.e.keller@...el.com>

> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
>  net/netlink/genetlink.c | 32 +++++++++-----------------------
>  1 file changed, 9 insertions(+), 23 deletions(-)
> 
> diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
> index 63807204805a..301981bae83d 100644
> --- a/net/netlink/genetlink.c
> +++ b/net/netlink/genetlink.c
> @@ -99,11 +99,6 @@ static const struct genl_family *genl_family_find_byname(char *name)
>  	return NULL;
>  }
>  
> -static int genl_get_cmd_cnt(const struct genl_family *family)
> -{
> -	return family->n_ops + family->n_small_ops;
> -}
> -
>  static void genl_op_from_full(const struct genl_family *family,
>  			      unsigned int i, struct genl_ops *op)
>  {
> @@ -217,18 +212,6 @@ genl_get_cmd(u32 cmd, u8 flags, const struct genl_family *family,
>  	return genl_cmd_full_to_split(op, family, &full, flags);
>  }
>  
> -static void genl_get_cmd_by_index(unsigned int i,
> -				  const struct genl_family *family,
> -				  struct genl_ops *op)
> -{
> -	if (i < family->n_ops)
> -		genl_op_from_full(family, i, op);
> -	else if (i < family->n_ops + family->n_small_ops)
> -		genl_op_from_small(family, i - family->n_ops, op);
> -	else
> -		WARN_ON_ONCE(1);
> -}
> -
>  struct genl_op_iter {
>  	const struct genl_family *family;
>  	struct genl_split_ops doit;
> @@ -246,22 +229,25 @@ genl_op_iter_init(const struct genl_family *family, struct genl_op_iter *iter)
>  
>  	iter->flags = 0;
>  
> -	return genl_get_cmd_cnt(iter->family);
> +	return iter->family->n_ops + iter->family->n_small_ops;
>  }
>  
>  static bool genl_op_iter_next(struct genl_op_iter *iter)
>  {
> +	const struct genl_family *family = iter->family;
>  	struct genl_ops op;
>  
> -	if (iter->i >= genl_get_cmd_cnt(iter->family))
> +	if (iter->i < family->n_ops)
> +		genl_op_from_full(family, iter->i, &op);
> +	else if (iter->i < family->n_ops + family->n_small_ops)
> +		genl_op_from_small(family, iter->i - family->n_ops, &op);
> +	else
>  		return false;
>  
> -	genl_get_cmd_by_index(iter->i, iter->family, &op);
>  	iter->i++;
>  
> -	genl_cmd_full_to_split(&iter->doit, iter->family, &op, GENL_CMD_CAP_DO);
> -	genl_cmd_full_to_split(&iter->dumpit, iter->family,
> -			       &op, GENL_CMD_CAP_DUMP);
> +	genl_cmd_full_to_split(&iter->doit, family, &op, GENL_CMD_CAP_DO);
> +	genl_cmd_full_to_split(&iter->dumpit, family, &op, GENL_CMD_CAP_DUMP);
>  
>  	iter->cmd = iter->doit.cmd | iter->dumpit.cmd;
>  	iter->flags = iter->doit.flags | iter->dumpit.flags;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ