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:   Wed, 17 Aug 2022 13:27:29 +0200
From:   Michal Kubecek <mkubecek@...e.cz>
To:     Vladimir Oltean <vladimir.oltean@....com>
Cc:     netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Claudiu Manoil <claudiu.manoil@....com>,
        Vinicius Costa Gomes <vinicius.gomes@...el.com>,
        Xiaoliang Yang <xiaoliang.yang_1@....com>,
        Kurt Kanzenbach <kurt@...utronix.de>,
        Rui Sousa <rui.sousa@....com>,
        Ferenc Fejes <ferenc.fejes@...csson.com>
Subject: Re: [RFC PATCH net-next 1/7] net: ethtool: netlink: introduce
 ethnl_update_bool()

On Wed, Aug 17, 2022 at 01:29:14AM +0300, Vladimir Oltean wrote:
> For a reason I can't really understand, ethnl_update_bool32() exists,
> but the plain function that operates on a boolean value kept in an
> actual u8 netlink attribute doesn't.

I can explain that: at the moment these helpers were introduced, only
members of traditional structures shared with ioctl interface were
updated and all attributes which were booleans logically were
represented as u32 in them so that no other helper was needed back then.


>                                       Introduce it; it's needed for
> things like verify-disabled for the MAC merge configuration.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
> ---
>  net/ethtool/netlink.h | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
> index c0d587611854..1653fd2cf0cf 100644
> --- a/net/ethtool/netlink.h
> +++ b/net/ethtool/netlink.h
> @@ -111,6 +111,32 @@ static inline void ethnl_update_u8(u8 *dst, const struct nlattr *attr,
>  	*mod = true;
>  }
>  
> +/**
> + * ethnl_update_bool() - update bool from NLA_U8 attribute
> + * @dst:  value to update
> + * @attr: netlink attribute with new value or null
> + * @mod:  pointer to bool for modification tracking
> + *
> + * Use the u8 value from NLA_U8 netlink attribute @attr to set bool variable
> + * pointed to by @dst to false (if zero) or 1 (if not); do nothing if @attr is
                                               ^ true

Looks good otherwise.

Michal

> + * null. Bool pointed to by @mod is set to true if this function changed the
> + * logical value of *dst, otherwise it is left as is.
> + */
> +static inline void ethnl_update_bool(bool *dst, const struct nlattr *attr,
> +				     bool *mod)
> +{
> +	u8 val;
> +
> +	if (!attr)
> +		return;
> +	val = !!nla_get_u8(attr);
> +	if (*dst == val)
> +		return;
> +
> +	*dst = val;
> +	*mod = true;
> +}
> +
>  /**
>   * ethnl_update_bool32() - update u32 used as bool from NLA_U8 attribute
>   * @dst:  value to update
> -- 
> 2.34.1
> 

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ