diff --git a/sys/mips/atheros/ar71xx_macaddr.c b/sys/mips/atheros/ar71xx_macaddr.c index f2f802333812..5b85820c3ba0 100644 --- a/sys/mips/atheros/ar71xx_macaddr.c +++ b/sys/mips/atheros/ar71xx_macaddr.c @@ -93,18 +93,9 @@ ar71xx_mac_addr_init(unsigned char *dst, const unsigned char *src, * Returns 0 on success, -1 on error. */ int -ar71xx_mac_addr_random_init(unsigned char *dst) +ar71xx_mac_addr_random_init(struct ifnet *ifp, struct ether_addr *dst) { - uint32_t rnd; - - rnd = arc4random(); - - dst[0] = 'b'; - dst[1] = 's'; - dst[2] = 'd'; - dst[3] = (rnd >> 24) & 0xff; - dst[4] = (rnd >> 16) & 0xff; - dst[5] = (rnd >> 8) & 0xff; + ether_gen_addr(ifp, dst); return (0); } diff --git a/sys/mips/atheros/ar71xx_macaddr.h b/sys/mips/atheros/ar71xx_macaddr.h index 2022c64c0f15..9f9ede84ca44 100644 --- a/sys/mips/atheros/ar71xx_macaddr.h +++ b/sys/mips/atheros/ar71xx_macaddr.h @@ -34,6 +34,6 @@ extern uint8_t ar71xx_board_mac_addr[ETHER_ADDR_LEN]; extern int ar71xx_mac_addr_init(unsigned char *dst, const unsigned char *src, int offset, int is_local); -extern int ar71xx_mac_addr_random_init(unsigned char *dst); +extern int ar71xx_mac_addr_random_init(struct ifnet *ifp, struct ether_addr *dst); #endif /* __ATHEROS_AR71XX_MACADDR_H__ */ diff --git a/sys/mips/atheros/if_arge.c b/sys/mips/atheros/if_arge.c index 2cc698f7f347..945c40b6c48f 100644 --- a/sys/mips/atheros/if_arge.c +++ b/sys/mips/atheros/if_arge.c @@ -876,7 +876,11 @@ arge_attach(device_t dev) if (bootverbose) device_printf(dev, "Generating random ethernet address.\n"); - (void) ar71xx_mac_addr_random_init(sc->arge_eaddr); + if (ar71xx_mac_addr_random_init(ifp, (void *) sc->arge_eaddr) < 0) { + device_printf(dev, "Failed to choose random MAC address\n"); + error = EINVAL; + goto fail; + } } if (arge_dma_alloc(sc) != 0) {