Date: Tue, 9 Apr 2019 17:26:53 +0300 From: "Andrey V. Elsukov" <bu7cher@yandex.ru> To: Ganbold Tsagaankhuu <ganbold@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r346052 - head/sys/dev/usb/net Message-ID: <7e6208ff-9c9e-9a08-1f67-15e3506758aa@yandex.ru> In-Reply-To: <201904091354.x39Ds9e6070857@repo.freebsd.org> References: <201904091354.x39Ds9e6070857@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --zlwWwCAqsNAa7i8b9cDATykK3gTzVffv8 Content-Type: multipart/mixed; boundary="W7PYkrAMnbxKAvbPNjDV1e9OvSuqOtvnk"; protected-headers="v1" From: "Andrey V. Elsukov" <bu7cher@yandex.ru> To: Ganbold Tsagaankhuu <ganbold@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: <7e6208ff-9c9e-9a08-1f67-15e3506758aa@yandex.ru> Subject: Re: svn commit: r346052 - head/sys/dev/usb/net References: <201904091354.x39Ds9e6070857@repo.freebsd.org> In-Reply-To: <201904091354.x39Ds9e6070857@repo.freebsd.org> --W7PYkrAMnbxKAvbPNjDV1e9OvSuqOtvnk Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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 >=20 > 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. > =20 > - 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] &=3D ~0x01; /* unicast */ > + sc->sc_ue.ue_eaddr[0] |=3D 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=3Drevision&revision=3D345139 --=20 WBR, Andrey V. Elsukov --W7PYkrAMnbxKAvbPNjDV1e9OvSuqOtvnk-- --zlwWwCAqsNAa7i8b9cDATykK3gTzVffv8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQEzBAEBCAAdFiEE5lkeG0HaFRbwybwAAcXqBBDIoXoFAlysq60ACgkQAcXqBBDI oXrjJQgAsMs+O0i+GpxyN0Su5I3NnYvIrqKB2qStO3hXVUiDDqu56oVCCR4b1Vlh VrVyEG6VxUi2zN4nwlALNLJHvp3ujTML7ZYJmKXVrf7OiZewiDczOpBQkU1ZVpEP NSHCWxjBAaIK42Kv48sYqfNOc5+6QA7g87Hs8vHJASDEl/6bHi9rT+eUC2F9jnkk WXwzgLHDA3sX7nuJfRD/LhPvfw2m2LAPuqYxHRKGwTKBGi0IsvM0zXyN4DzHPtgf T+yZlEBm9PYuyRUxZAavVreinlKUL6rvzW7C7C/pKnnuabZ3rE13F1U2WHmYsDgW 0fn72S1ei+qusXAyDy0RK/WNPHZAcA== =8ZiJ -----END PGP SIGNATURE----- --zlwWwCAqsNAa7i8b9cDATykK3gTzVffv8--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7e6208ff-9c9e-9a08-1f67-15e3506758aa>