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: <88de7791-2a50-64b1-6e3d-5c1a8235eb96@gmail.com>
Date:   Thu, 17 Sep 2020 14:23:54 -0600
From:   David Ahern <dsahern@...il.com>
To:     Parav Pandit <parav@...dia.com>, davem@...emloft.net,
        kuba@...nel.org, netdev@...r.kernel.org
Cc:     Jiri Pirko <jiri@...dia.com>
Subject: Re: [PATCH net-next v2 4/8] devlink: Support get and set state of
 port function

On 9/17/20 11:20 AM, Parav Pandit wrote:
> diff --git a/net/core/devlink.c b/net/core/devlink.c
> index d152489e48da..c82098cb75da 100644
> --- a/net/core/devlink.c
> +++ b/net/core/devlink.c
> @@ -595,6 +598,40 @@ devlink_port_function_hw_addr_fill(struct devlink *devlink, const struct devlink
>  	return 0;
>  }
>  
> +static bool devlink_port_function_state_valid(u8 state)

you have a named enum so why not 'enum devlink_port_function_state state'?


> +{
> +	return state == DEVLINK_PORT_FUNCTION_STATE_INACTIVE ||
> +	       state == DEVLINK_PORT_FUNCTION_STATE_ACTIVE;
> +}
> +
> +static int devlink_port_function_state_fill(struct devlink *devlink, const struct devlink_ops *ops,
> +					    struct devlink_port *port, struct sk_buff *msg,
> +					    struct netlink_ext_ack *extack, bool *msg_updated)
> +{
> +	enum devlink_port_function_state state;
> +	int err;
> +
> +	if (!ops->port_function_state_get)
> +		return 0;
> +
> +	err = ops->port_function_state_get(devlink, port, &state, extack);
> +	if (err) {
> +		if (err == -EOPNOTSUPP)
> +			return 0;
> +		return err;
> +	}
> +	if (!devlink_port_function_state_valid(state)) {
> +		WARN_ON(1);

WARN_ON_ONCE at most.

> +		NL_SET_ERR_MSG_MOD(extack, "Invalid state value read from driver");
> +		return -EINVAL;
> +	}
> +	err = nla_put_u8(msg, DEVLINK_PORT_FUNCTION_ATTR_STATE, state);
> +	if (err)
> +		return err;
> +	*msg_updated = true;
> +	return 0;
> +}
> +
>  static int
>  devlink_nl_port_function_attrs_put(struct sk_buff *msg, struct devlink_port *port,
>  				   struct netlink_ext_ack *extack)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ