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: <186dd3ec-6bab-fe3c-cbab-a54898d51f57@pensando.io>
Date:   Sat, 16 Oct 2021 14:19:18 -0700
From:   Shannon Nelson <snelson@...sando.io>
To:     Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org
Cc:     olteanv@...il.com, andrew@...n.ch, idosch@...sch.org,
        f.fainelli@...il.com, vkochan@...vell.com, tchornyi@...vell.com
Subject: Re: [RFC net-next 3/6] ethernet: prestera: use eth_hw_addr_set_port()

On 10/15/21 12:38 PM, Jakub Kicinski wrote:
> Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
> of VLANs...") introduced a rbtree for faster Ethernet address look
> up. To maintain netdev->dev_addr in this tree we need to make all
> the writes to it got through appropriate helpers.
>
> We need to make sure the last byte is zeroed.
>
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
> CC: vkochan@...vell.com
> CC: tchornyi@...vell.com
> ---
>   drivers/net/ethernet/marvell/prestera/prestera_main.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> index b667f560b931..7d179927dabe 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> @@ -290,6 +290,7 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)
>   {
>   	struct prestera_port *port;
>   	struct net_device *dev;
> +	u8 addr[ETH_ALEN] = {};
>   	int err;
>   
>   	dev = alloc_etherdev(sizeof(*port));
> @@ -341,8 +342,8 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)
>   	/* firmware requires that port's MAC address consist of the first
>   	 * 5 bytes of the base MAC address
>   	 */
> -	memcpy(dev->dev_addr, sw->base_mac, dev->addr_len - 1);
> -	dev->dev_addr[dev->addr_len - 1] = port->fp_id;
> +	memcpy(addr, sw->base_mac, dev->addr_len - 1);
> +	eth_hw_addr_set_port(dev, addr, port->fp_id);

Notice in this case I think the original code is setting the last byte 
to port->fp_id, found I think by a call to their firmware, not by adding 
fp_id to the existing byte value.

This is an example of how I feel a bit queezy about this suggested 
helper: each driver that does something like this may need to do it 
slightly differently depending upon how their hardware/firmware works.  
We may be trying to help too much here.

As a potential consumer of these helpers, I'd rather do my own mac 
address byte twiddling and then use eth_hw_addr_set() to put it into place.

sln


>   
>   	err = prestera_hw_port_mac_set(port, dev->dev_addr);
>   	if (err) {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ