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]
Date:   Sat, 13 Mar 2021 13:44:48 +0200
From:   Vladimir Oltean <olteanv@...il.com>
To:     Kurt Kanzenbach <kurt@...-computers.de>
Cc:     Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 3/4] net: dsa: hellcreek: Move common code to
 helper

On Sat, Mar 13, 2021 at 10:39:38AM +0100, Kurt Kanzenbach wrote:
> There are two functions which need to populate fdb entries. Move that to a
> helper function.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@...-computers.de>
> Reviewed-by: Andrew Lunn <andrew@...n.ch>
> ---
>  drivers/net/dsa/hirschmann/hellcreek.c | 85 +++++++++++++-------------
>  1 file changed, 43 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c
> index edac39462a07..38ff0f12e8a4 100644
> --- a/drivers/net/dsa/hirschmann/hellcreek.c
> +++ b/drivers/net/dsa/hirschmann/hellcreek.c
> @@ -670,6 +670,40 @@ static int __hellcreek_fdb_del(struct hellcreek *hellcreek,
>  	return hellcreek_wait_fdb_ready(hellcreek);
>  }
>  
> +static void hellcreek_populate_fdb_entry(struct hellcreek *hellcreek,
> +					 struct hellcreek_fdb_entry *entry,
> +					 size_t idx)
> +{
> +	unsigned char addr[ETH_ALEN];

You could have assigned:

	unsigned char *addr = entry->mac;

and avoided the memcpy, but it doesn't really matter much.

> +	u16 meta, mac;
> +
> +	/* Read values */
> +	meta	= hellcreek_read(hellcreek, HR_FDBMDRD);
> +	mac	= hellcreek_read(hellcreek, HR_FDBRDL);
> +	addr[5] = mac & 0xff;
> +	addr[4] = (mac & 0xff00) >> 8;
> +	mac	= hellcreek_read(hellcreek, HR_FDBRDM);
> +	addr[3] = mac & 0xff;
> +	addr[2] = (mac & 0xff00) >> 8;
> +	mac	= hellcreek_read(hellcreek, HR_FDBRDH);
> +	addr[1] = mac & 0xff;
> +	addr[0] = (mac & 0xff00) >> 8;
> +
> +	/* Populate @entry */
> +	memcpy(entry->mac, addr, sizeof(addr));
> +	entry->idx	    = idx;
> +	entry->portmask	    = (meta & HR_FDBMDRD_PORTMASK_MASK) >>
> +		HR_FDBMDRD_PORTMASK_SHIFT;
> +	entry->age	    = (meta & HR_FDBMDRD_AGE_MASK) >>
> +		HR_FDBMDRD_AGE_SHIFT;
> +	entry->is_obt	    = !!(meta & HR_FDBMDRD_OBT);
> +	entry->pass_blocked = !!(meta & HR_FDBMDRD_PASS_BLOCKED);
> +	entry->is_static    = !!(meta & HR_FDBMDRD_STATIC);
> +	entry->reprio_tc    = (meta & HR_FDBMDRD_REPRIO_TC_MASK) >>
> +		HR_FDBMDRD_REPRIO_TC_SHIFT;
> +	entry->reprio_en    = !!(meta & HR_FDBMDRD_REPRIO_EN);
> +}
> +

Reviewed-by: Vladimir Oltean <olteanv@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ