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: <0e497b6f-7ab0-4a43-afc6-c5ad205aa624@lunn.ch>
Date: Thu, 1 Aug 2024 02:51:24 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Jijie Shao <shaojijie@...wei.com>
Cc: yisen.zhuang@...wei.com, salil.mehta@...wei.com, davem@...emloft.net,
	edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
	horms@...nel.org, shenjian15@...wei.com, wangpeiyang1@...wei.com,
	liuyonglong@...wei.com, sudongming1@...wei.com,
	xujunsheng@...wei.com, shiyongbang@...wei.com,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH net-next 05/10] net: hibmcge: Implement some .ndo
 functions

> +static int hbg_net_set_mac_address(struct net_device *dev, void *addr)
> +{
> +	struct hbg_priv *priv = netdev_priv(dev);
> +	u8 *mac_addr;
> +
> +	mac_addr = ((struct sockaddr *)addr)->sa_data;
> +	if (ether_addr_equal(dev->dev_addr, mac_addr))
> +		return 0;
> +
> +	if (!is_valid_ether_addr(mac_addr))
> +		return -EADDRNOTAVAIL;

How does the core pass you an invalid MAC address?

> +static int hbg_net_change_mtu(struct net_device *dev, int new_mtu)
> +{
> +	struct hbg_priv *priv = netdev_priv(dev);
> +	bool is_opened = hbg_nic_is_open(priv);
> +	u32 frame_len;
> +
> +	if (new_mtu == dev->mtu)
> +		return 0;
> +
> +	if (new_mtu < priv->dev_specs.min_mtu || new_mtu > priv->dev_specs.max_mtu)
> +		return -EINVAL;

You just need to set dev->min_mtu and dev->max_mtu, and the core will
do this validation for you.

> +	dev_info(&priv->pdev->dev,
> +		 "change mtu from %u to %u\n", dev->mtu, new_mtu);

dev_dbg() Don't spam the log for normal operations.

	Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ