Linux kernel staging patches
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: fall back to random mac address
@ 2022-07-13  7:55 Martin Kaiser
  2022-07-13 10:27 ` Pavel Skripkin
  2022-07-14  5:08 ` Philipp Hortmann
  0 siblings, 2 replies; 3+ messages in thread
From: Martin Kaiser @ 2022-07-13  7:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Martin Kaiser, Joe Perches

Call eth_random_addr to generate a random mac address if we cannot load
the mac address from the efuses.

Do not use a constant mac address as fallback. This may create conflicts
if we have several r8188eu devices on the network.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/staging/r8188eu/hal/usb_halinit.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 68d012a442a8..8902dda7b8d8 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -912,11 +912,10 @@ unsigned int rtl8188eu_inirp_init(struct adapter *Adapter)
 
 static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail)
 {
-	u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x88, 0x02};
 	struct eeprom_priv *eeprom = &adapt->eeprompriv;
 
 	if (AutoLoadFail) {
-		memcpy(eeprom->mac_addr, sMacAddr, ETH_ALEN);
+		eth_random_addr(eeprom->mac_addr);
 	} else {
 		/* Read Permanent MAC address */
 		memcpy(eeprom->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: r8188eu: fall back to random mac address
  2022-07-13  7:55 [PATCH] staging: r8188eu: fall back to random mac address Martin Kaiser
@ 2022-07-13 10:27 ` Pavel Skripkin
  2022-07-14  5:08 ` Philipp Hortmann
  1 sibling, 0 replies; 3+ messages in thread
From: Pavel Skripkin @ 2022-07-13 10:27 UTC (permalink / raw)
  To: Martin Kaiser, Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, linux-staging,
	linux-kernel, Joe Perches

Hi Martin,

Martin Kaiser <martin@kaiser.cx> says:
> Call eth_random_addr to generate a random mac address if we cannot load
> the mac address from the efuses.
> 
> Do not use a constant mac address as fallback. This may create conflicts
> if we have several r8188eu devices on the network.
> 
> Suggested-by: Joe Perches <joe@perches.com>
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---

Looks OK to me, thanks

Reviewed-by: Pavel Skripkin <paskripkin@gmail.com>





Thanks,
--Pavel Skripkin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: r8188eu: fall back to random mac address
  2022-07-13  7:55 [PATCH] staging: r8188eu: fall back to random mac address Martin Kaiser
  2022-07-13 10:27 ` Pavel Skripkin
@ 2022-07-14  5:08 ` Philipp Hortmann
  1 sibling, 0 replies; 3+ messages in thread
From: Philipp Hortmann @ 2022-07-14  5:08 UTC (permalink / raw)
  To: Martin Kaiser, Greg Kroah-Hartman
  Cc: Larry Finger, Phillip Potter, Michael Straube, Pavel Skripkin,
	linux-staging, linux-kernel, Joe Perches

On 7/13/22 09:55, Martin Kaiser wrote:
> Call eth_random_addr to generate a random mac address if we cannot load
> the mac address from the efuses.
> 
> Do not use a constant mac address as fallback. This may create conflicts
> if we have several r8188eu devices on the network.
> 
> Suggested-by: Joe Perches <joe@perches.com>
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
>   drivers/staging/r8188eu/hal/usb_halinit.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
> index 68d012a442a8..8902dda7b8d8 100644
> --- a/drivers/staging/r8188eu/hal/usb_halinit.c
> +++ b/drivers/staging/r8188eu/hal/usb_halinit.c
> @@ -912,11 +912,10 @@ unsigned int rtl8188eu_inirp_init(struct adapter *Adapter)
>   
>   static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail)
>   {
> -	u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x88, 0x02};
>   	struct eeprom_priv *eeprom = &adapt->eeprompriv;
>   
>   	if (AutoLoadFail) {
> -		memcpy(eeprom->mac_addr, sMacAddr, ETH_ALEN);
> +		eth_random_addr(eeprom->mac_addr);
>   	} else {
>   		/* Read Permanent MAC address */
>   		memcpy(eeprom->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN);

Tested with:

static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 
*hwinfo, bool AutoLoadFail)
{
	struct eeprom_priv *eeprom = &adapt->eeprompriv;
	struct dvobj_priv *dvobj = adapter_to_dvobj(adapt);
	struct device *device = dvobj_to_dev(dvobj);

	dev_info(device, "AutoLoadFail: %i", AutoLoadFail);

	if (!AutoLoadFail) {
		eth_random_addr(eeprom->mac_addr);
	} else {
		/* Read Permanent MAC address */
		memcpy(eeprom->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN);
	}
	dev_info(device, "Test - MAC Address = %pM\n", eeprom->mac_addr);
}

Log:
[ 1799.018943] r8188eu 2-1.6:1.0: AutoLoadFail: 0
[ 1799.018969] r8188eu 2-1.6:1.0: Test - MAC Address = be:0a:e8:72:a8:4a
[ 1866.151995] r8188eu 2-1.6:1.0: AutoLoadFail: 0
[ 1866.152014] r8188eu 2-1.6:1.0: Test - MAC Address = 76:9b:4f:91:28:5f
[ 1900.266003] r8188eu 2-1.6:1.0: AutoLoadFail: 0
[ 1900.266008] r8188eu 2-1.6:1.0: Test - MAC Address = 5e:9d:d5:f5:ef:26


Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-14  5:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-13  7:55 [PATCH] staging: r8188eu: fall back to random mac address Martin Kaiser
2022-07-13 10:27 ` Pavel Skripkin
2022-07-14  5:08 ` Philipp Hortmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox