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] [day] [month] [year] [list]
Date:	Tue, 09 Feb 2010 17:22:17 +0000
From:	Ben Hutchings <bhutchings@...arflare.com>
To:	Yevgeny Petrilin <yevgenyp@...lanox.co.il>
Cc:	Roland Dreier <rdreier@...co.com>, general@...ts.openfabrics.org,
	netdev@...r.kernel.org, liranl@...lanox.co.il,
	tziporet@...lanox.co.il
Subject: Re: [PATCH 17/23 v3] mlx4_core: Randomize Mac addresses for slaves

On Thu, 2010-02-04 at 17:56 +0200, Yevgeny Petrilin wrote:
> Signed-off-by: Yevgeny Petrilin <yevgenyp@...lanox.co.il>
> ---
>  drivers/net/mlx4/fw.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c
> index 6e3e1d1..202a256 100644
> --- a/drivers/net/mlx4/fw.c
> +++ b/drivers/net/mlx4/fw.c
> @@ -32,6 +32,7 @@
>   * SOFTWARE.
>   */
>  
> +#include <linux/etherdevice.h>
>  #include <linux/mlx4/cmd.h>
>  #include <linux/cache.h>
>  
> @@ -149,11 +150,19 @@ int mlx4_QUERY_SLAVE_CAP_wrapper(struct mlx4_dev *dev, int slave, struct mlx4_vh
>  						       struct mlx4_cmd_mailbox *outbox)
>  {
>  	struct mlx4_caps *caps = outbox->buf;
> +	u8 rand_mac[6];
> +	int i, j;
>  
>  	memcpy(caps, &dev->caps, sizeof *caps);
>  
>  	/* The Master function is in charge for qp1 of al slaves */
>  	caps->sqp_demux = 0;
> +	for (i = 1; i <= dev->caps.num_ports; ++i) {
> +		random_ether_addr(rand_mac);
> +		caps->def_mac[i] = 0;
> +		for (j = 0; j < ETH_ALEN - 1; j++)
> +			caps->def_mac[i] |= ((u64)(rand_mac[j]) << 8 * j);
[...]

Do you really want the last byte to be 0 always?

Assuming you don't, you can avoid the inner loop by writing:

	union {
		u8 bytes[ETH_ALEN];
		__le64 qword;
	} rand_mac = {
		.qword = 0
	};
	...
		random_ether_addr(rand_mac.bytes);
		caps->def_mac[i] = le64_to_cpup(&rand_mac.qword);

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ