Re: Getting a stable MAC address for a RPI CM3+ with ue0 interface
Ronald Klop <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.arm |
|---|---|
| Message-ID | <[email protected]> |
On 9/25/23 22:34, Patrick M. Hausen wrote: > Hi all, > >> Am 25.09.2023 um 22:26 schrieb Ronald Klop <[email protected]>: >> The method ether_gen_addr() generates a MAC address bases on hostuuid and interface name. Maybe not ideal, bu a lot better then a random MAC. > > I do not understand why "we" as a project do not got the RPi Foundation documented way? > I can't help you on this question. I don't know either. >> It would be nice to see more information from the panic. Can you make a picture or movie of the screen while this happens? >> Or does the system make a kernel crashdump? See "dumpdev" in /etc/defaults/rc.conf. > > Of course. I have one more CM3+ that is not part of my TuringPi cluster that I can > use for that. Can't promise tomorrow, but sometime this week. > > Could you send me your patch in an archived binary format in direct email, please? > I manually applied the changes, because my MUA or whatever intermediate system > converted tabs to spaces and the patch did not apply automatically. Possibly I made some mistake. See attachment. I hope it gets through the list. I'll try to create a PR with the patch soon. > Kind regards, > Patrick
if_smsc.c.diff
(text/plain, 1013 B)
diff --git a/sys/dev/usb/net/if_smsc.c b/sys/dev/usb/net/if_smsc.c
index 0a0268bfa1a2..157f268ef4dd 100644
--- a/sys/dev/usb/net/if_smsc.c
+++ b/sys/dev/usb/net/if_smsc.c
@@ -1554,8 +1554,11 @@ static void
smsc_attach_post(struct usb_ether *ue)
{
struct smsc_softc *sc = uether_getsc(ue);
+ struct ether_addr eaddr;
+ if_t ifp;
uint32_t mac_h, mac_l;
int err;
+ int i;
smsc_dbg_printf(sc, "smsc_attach_post\n");
@@ -1589,9 +1592,10 @@ smsc_attach_post(struct usb_ether *ue)
err = usb_fdt_get_mac_addr(sc->sc_ue.ue_dev, &sc->sc_ue);
#endif
if ((err != 0) || (!ETHER_IS_VALID(sc->sc_ue.ue_eaddr))) {
- read_random(sc->sc_ue.ue_eaddr, ETHER_ADDR_LEN);
- sc->sc_ue.ue_eaddr[0] &= ~0x01; /* unicast */
- sc->sc_ue.ue_eaddr[0] |= 0x02; /* locally administered */
+ device_printf(ue->ue_dev, "No MAC address found. Using ether_gen_addr().\n");
+ ether_gen_addr(ue->ue_ifp, &eaddr);
+ for (i = 0; i < ETHER_ADDR_LEN; i++)
+ sc->sc_ue.ue_eaddr[i] = eaddr.octet[i];
}
}