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]
Message-ID: <921763be-9f8d-5f2d-18a3-400c9ac98797@gmail.com>
Date:   Mon, 23 Dec 2019 20:08:55 -0800
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Michal Kubecek <mkubecek@...e.cz>,
        David Miller <davem@...emloft.net>, netdev@...r.kernel.org
Cc:     Jakub Kicinski <jakub.kicinski@...ronome.com>,
        Jiri Pirko <jiri@...nulli.us>, Andrew Lunn <andrew@...n.ch>,
        John Linville <linville@...driver.com>,
        Stephen Hemminger <stephen@...workplumber.org>,
        Johannes Berg <johannes@...solutions.net>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v8 02/14] ethtool: helper functions for netlink
 interface



On 12/22/2019 3:45 PM, Michal Kubecek wrote:
> Add common request/reply header definition and helpers to parse request
> header and fill reply header. Provide ethnl_update_* helpers to update
> structure members from request attributes (to be used for *_SET requests).
> 
> Signed-off-by: Michal Kubecek <mkubecek@...e.cz>
> ---

[snip]

> +/**
> + * ethnl_update_u32() - update u32 value from NLA_U32 attribute
> + * @dst:  value to update
> + * @attr: netlink attribute with new value or null
> + * @mod:  pointer to bool for modification tracking
> + *
> + * Copy the u32 value from NLA_U32 netlink attribute @attr into variable
> + * pointed to by @dst; do nothing if @attr is null. Bool pointed to by @mod
> + * is set to true if this function changed the value of *dst, otherwise it
> + * is left as is.
> + */

I would find it more intuitive if an integer was returned: < 0 in case
of error, 0 if no change and 1 if something changed.

> +static inline void ethnl_update_u32(u32 *dst, const struct nlattr *attr,
> +				    bool *mod)
> +{
> +	u32 val;
> +
> +	if (!attr)
> +		return;
> +	val = nla_get_u32(attr);
> +	if (*dst == val)
> +		return;
> +
> +	*dst = val;
> +	*mod = true;
> +}
> +
> +/**
> + * ethnl_update_u8() - update u8 value from NLA_U8 attribute
> + * @dst:  value to update
> + * @attr: netlink attribute with new value or null
> + * @mod:  pointer to bool for modification tracking
> + *
> + * Copy the u8 value from NLA_U8 netlink attribute @attr into variable
> + * pointed to by @dst; do nothing if @attr is null. Bool pointed to by @mod
> + * is set to true if this function changed the value of *dst, otherwise it
> + * is left as is.
> + */
> +static inline void ethnl_update_u8(u8 *dst, const struct nlattr *attr,
> +				   bool *mod)
> +{
> +	u8 val;
> +
> +	if (!attr)
> +		return;
> +	val = nla_get_u32(attr);

Should not this be nla_get_u8() here? This sounds like it is going to
break on BE machines.
-- 
Florian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ