summaryrefslogtreecommitdiff
path: root/sys/net/if_vether.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2010-01-12 03:41:30 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2010-01-12 03:41:30 +0000
commit2ffe5c858e64748794af88d21f0dc46133869dca (patch)
tree3156e96efeaa40b97986da7420161875f544ecd4 /sys/net/if_vether.c
parent20bb74983055decf011de6c42a46c101cc46ccd9 (diff)
Unify the various fake ethernet generators as ether_fakeaddr() which
is safe for both hardware devices and virtual devices ok mpf, kettenis, moaning and groaning and slow acceptance from mcbride XXX should loop checking for uniqueness after new henning diff goes in
Diffstat (limited to 'sys/net/if_vether.c')
-rw-r--r--sys/net/if_vether.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/sys/net/if_vether.c b/sys/net/if_vether.c
index 994fe743299..ad0e0023274 100644
--- a/sys/net/if_vether.c
+++ b/sys/net/if_vether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vether.c,v 1.6 2009/11/22 12:33:25 deraadt Exp $ */
+/* $OpenBSD: if_vether.c,v 1.7 2010/01/12 03:41:29 deraadt Exp $ */
/*
* Copyright (c) 2009 Theo de Raadt
@@ -98,27 +98,16 @@ vether_clone_create(struct if_clone *ifc, int unit)
{
struct ifnet *ifp;
struct vether_softc *sc;
- u_int32_t macaddr_rnd;
int s;
if ((sc = malloc(sizeof(*sc),
M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL)
return (ENOMEM);
- /* from if_tun.c: generate fake MAC address: 00 bd xx xx xx unit_no */
- sc->sc_ac.ac_enaddr[0] = 0x00;
- sc->sc_ac.ac_enaddr[1] = 0xbd;
- /*
- * This no longer happens pre-scheduler so let's use the real
- * random subsystem instead of random().
- */
- macaddr_rnd = arc4random();
- bcopy(&macaddr_rnd, &sc->sc_ac.ac_enaddr[2], sizeof(u_int32_t));
- sc->sc_ac.ac_enaddr[5] = (u_char)unit + 1;
-
ifp = &sc->sc_ac.ac_if;
snprintf(ifp->if_xname, sizeof ifp->if_xname, "vether%d", unit);
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+ ether_fakeaddr(ifp);
ifp->if_softc = sc;
ifp->if_ioctl = vetherioctl;