On Thu, Apr 07, 2016 at 01:47:13PM +0200, Martin Pieuchot wrote:
> If we need a random value to fake an Ethernet address, let's use
> arc4random(9).
>
> ok?
You missed if_cdce.c which uses 0x2acb as well but uses microuptime.
Why can't these all just use ether_fakeaddr() ?
>
> Index: if_cdcef.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_cdcef.c,v
> retrieving revision 1.41
> diff -u -p -r1.41 if_cdcef.c
> --- if_cdcef.c 25 Nov 2015 03:10:00 -0000 1.41
> +++ if_cdcef.c 6 Apr 2016 14:25:35 -0000
> @@ -121,8 +121,6 @@ struct usbf_function_methods cdcef_metho
>
> #define DEVNAME(sc) ((sc)->sc_dev.bdev.dv_xname)
>
> -extern int ticks;
> -
> /*
> * USB function match/attach/detach
> */
> @@ -142,8 +140,9 @@ cdcef_attach(struct device *parent, stru
> struct ifnet *ifp;
> usbf_status err;
> struct usb_cdc_union_descriptor udesc;
> - int s;
> + u_int32_t macaddr_lo;
> u_int16_t macaddr_hi;
> + int s;
>
>
> /* Set the device identification according to the function. */
> @@ -239,7 +238,8 @@ cdcef_attach(struct device *parent, stru
>
> macaddr_hi = htons(0x2acb);
> bcopy(&macaddr_hi, &sc->sc_arpcom.ac_enaddr[0], sizeof(u_int16_t));
> - bcopy(&ticks, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
> + macaddr_lo = arc4random();
> + bcopy(&macaddr_lo, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
> sc->sc_arpcom.ac_enaddr[5] = (u_int8_t)(sc->sc_dev.bdev.dv_unit);
>
> printf(": address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));
> Index: if_ugl.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_ugl.c,v
> retrieving revision 1.18
> diff -u -p -r1.18 if_ugl.c
> --- if_ugl.c 25 Nov 2015 11:20:38 -0000 1.18
> +++ if_ugl.c 6 Apr 2016 14:26:47 -0000
> @@ -152,8 +152,6 @@ int ugldebug = 0;
> #define DPRINTFN(n,x)
> #endif
>
> -extern int ticks;
> -
> /*
> * Various supported device vendors/products.
> */
> @@ -214,6 +212,7 @@ ugl_attach(struct device *parent, struct
> usb_interface_descriptor_t *id;
> usb_endpoint_descriptor_t *ed;
> int i;
> + u_int32_t macaddr_lo;
> u_int16_t macaddr_hi;
>
> DPRINTFN(5,(" : ugl_attach: sc=%p, dev=%p", sc, dev));
> @@ -253,7 +252,8 @@ ugl_attach(struct device *parent, struct
>
> macaddr_hi = htons(0x2acb);
> bcopy(&macaddr_hi, &sc->sc_arpcom.ac_enaddr[0], sizeof(u_int16_t));
> - bcopy(&ticks, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
> + macaddr_lo = arc4random();
> + bcopy(&macaddr_lo, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
> sc->sc_arpcom.ac_enaddr[5] = (u_int8_t)(sc->sc_dev.dv_unit);
>
> printf("%s: address %s\n",
>