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: <ZqKLd9ZIJ4l5tAL8@LQ3V64L9R2>
Date: Thu, 25 Jul 2024 10:29:27 -0700
From: Joe Damato <jdamato@...tly.com>
To: Cindy Lu <lulu@...hat.com>
Cc: dtatulea@...dia.com, mst@...hat.com, jasowang@...hat.com,
	parav@...dia.com, sgarzare@...hat.com, netdev@...r.kernel.org,
	virtualization@...ts.linux-foundation.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATH v6 1/3] vdpa: support set mac address from vdpa tool

On Thu, Jul 25, 2024 at 09:31:02AM +0800, Cindy Lu wrote:
[...]
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index 8d391947eb8d..532cf3b52b26 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -1361,6 +1361,81 @@ static int vdpa_nl_cmd_dev_config_get_doit(struct sk_buff *skb, struct genl_info
>  	return err;
>  }
>  
> +static int vdpa_dev_net_device_attr_set(struct vdpa_device *vdev,
> +					struct genl_info *info)
> +{
> +	struct vdpa_dev_set_config set_config = {};
> +	const u8 *macaddr;
> +	struct vdpa_mgmt_dev *mdev = vdev->mdev;
> +	struct nlattr **nl_attrs = info->attrs;
> +	int err = -EINVAL;

Nit: IIRC networking code prefers reverse-xmas tree style and
macaddr above needs to be moved.

> +	down_write(&vdev->cf_lock);
> +	if (nl_attrs[VDPA_ATTR_DEV_NET_CFG_MACADDR]) {
> +		set_config.mask |= BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR);
> +		macaddr = nla_data(nl_attrs[VDPA_ATTR_DEV_NET_CFG_MACADDR]);
> +
> +		if (is_valid_ether_addr(macaddr)) {
> +			ether_addr_copy(set_config.net.mac, macaddr);
> +			memcpy(set_config.net.mac, macaddr, ETH_ALEN);
> +			if (mdev->ops->dev_set_attr) {
> +				err = mdev->ops->dev_set_attr(mdev, vdev,
> +							      &set_config);
> +			} else {
> +				NL_SET_ERR_MSG_FMT_MOD(
> +					info->extack,
> +					"device does not support changing the MAC address");
> +			}
> +		} else {
> +			NL_SET_ERR_MSG_FMT_MOD(info->extack,
> +					       "Invalid MAC address");
> +		}
> +	}
> +	up_write(&vdev->cf_lock);
> +	return err;
> +}

Nit: other code in this file has line breaks separating functions.
Probably good to add one here?


> +static int vdpa_nl_cmd_dev_attr_set_doit(struct sk_buff *skb,
> +					 struct genl_info *info)

Nit: Does the above pass ./scripts/checkpatch.pl --strict ? I am asking
because it seems like the alignment might be off?

> +{
> +	const char *name;
> +	int err = 0;
> +	struct device *dev;
> +	struct vdpa_device *vdev;
> +	u64 classes;

Nit: Same as above; I believe networking code is supposed to follow
reverse xmas tree order so these variables should be rearranged.

> +	if (!info->attrs[VDPA_ATTR_DEV_NAME])
> +		return -EINVAL;
> +
> +	name = nla_data(info->attrs[VDPA_ATTR_DEV_NAME]);
> +
> +	down_write(&vdpa_dev_lock);
> +	dev = bus_find_device(&vdpa_bus, NULL, name, vdpa_name_match);
> +	if (!dev) {
> +		NL_SET_ERR_MSG_MOD(info->extack, "device not found");
> +		err = -ENODEV;
> +		goto dev_err;
> +	}
> +	vdev = container_of(dev, struct vdpa_device, dev);
> +	if (!vdev->mdev) {
> +		NL_SET_ERR_MSG_MOD(info->extack, "unmanaged vdpa device");
> +		err = -EINVAL;
> +		goto mdev_err;
> +	}
> +	classes = vdpa_mgmtdev_get_classes(vdev->mdev, NULL);
> +	if (classes & BIT_ULL(VIRTIO_ID_NET)) {
> +		err = vdpa_dev_net_device_attr_set(vdev, info);
> +	} else {
> +		NL_SET_ERR_MSG_FMT_MOD(info->extack, "%s device not supported",
> +				       name);
> +	}
> +
> +mdev_err:
> +	put_device(dev);
> +dev_err:
> +	up_write(&vdpa_dev_lock);
> +	return err;
> +}

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ