svn commit: r346052 - head/sys/dev/usb/net

Andrey V. Elsukov bu7cher at yandex.ru
Tue Sep 3 14:07:08 UTC 2019


On 09.04.2019 16:54, Ganbold Tsagaankhuu wrote:
> Author: ganbold
> Date: Tue Apr  9 13:54:08 2019
> New Revision: 346052
> URL: https://svnweb.freebsd.org/changeset/base/346052
> 
> Log:
>   In some cases like NanoPI R1, its second USB ethernet
>   RTL8152 (chip version URE_CHIP_VER_4C10) doesn't
>   have hardwired MAC address, in other words, it is all zeros.
>   This commit fixes it by setting random MAC address
>   when MAC address is all zeros.
>   
> -	if (sc->sc_chip & URE_CHIP_VER_4C00)
> +	if ((sc->sc_chip & URE_CHIP_VER_4C00) ||
> +	    (sc->sc_chip & URE_CHIP_VER_4C10))
>  		ure_read_mem(sc, URE_PLA_IDR, URE_MCU_TYPE_PLA,
>  		    ue->ue_eaddr, 8);
>  	else
>  		ure_read_mem(sc, URE_PLA_BACKUP, URE_MCU_TYPE_PLA,
>  		    ue->ue_eaddr, 8);
> +
> +	if (ETHER_IS_ZERO(sc->sc_ue.ue_eaddr)) {
> +		device_printf(sc->sc_ue.ue_dev, "MAC assigned randomly\n");
> +		arc4rand(sc->sc_ue.ue_eaddr, ETHER_ADDR_LEN, 0);
> +		sc->sc_ue.ue_eaddr[0] &= ~0x01; /* unicast */
> +		sc->sc_ue.ue_eaddr[0] |= 0x02;  /* locally administered */
> +	}
>  }

Hi,

there is ether_fakeaddr() function that is used for such purpose.
Maybe is it better to use it? Look at this commit:
	https://svnweb.freebsd.org/base?view=revision&revision=345139

-- 
WBR, Andrey V. Elsukov

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 554 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20190903/8152df1a/attachment.sig>


More information about the svn-src-all mailing list