summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMarc Balmer <mbalmer@cvs.openbsd.org>2008-03-13 08:32:03 +0000
committerMarc Balmer <mbalmer@cvs.openbsd.org>2008-03-13 08:32:03 +0000
commit58ed0bbbeda3d1a22dd7b8e9ac11899b4aba5eb9 (patch)
treed3fd2012992ae5976072f5b6dd02581bf1a797ed /sys/dev
parentf806a02a48dffd4879055cd8cdc1895a0a6c926e (diff)
when attaching a cdce(4) device that does not have a proper mac address,
use the tv_usec part of a getmicrotime(9) call instead of 'int ticks' to create a mac address. as ticks is 0 during boot, this resulted in both ends of a USB link cable to have the same mac address. problem found/diff tested winiger, feedback/ok deraadt
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/if_cdce.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/dev/usb/if_cdce.c b/sys/dev/usb/if_cdce.c
index 5b232a9f6c7..e5d9af92643 100644
--- a/sys/dev/usb/if_cdce.c
+++ b/sys/dev/usb/if_cdce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_cdce.c,v 1.39 2007/10/11 18:33:14 deraadt Exp $ */
+/* $OpenBSD: if_cdce.c,v 1.40 2008/03/13 08:32:02 mbalmer Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wpaul@windriver.com>
@@ -170,6 +170,8 @@ cdce_attach(struct device *parent, struct device *self, void *aux)
const usb_descriptor_t *desc;
usbd_desc_iter_t iter;
usb_string_descriptor_t eaddr_str;
+ struct timeval now;
+ u_int32_t macaddr_lo;
u_int16_t macaddr_hi;
int i, j, numalts, len;
int ctl_ifcno = -1;
@@ -319,7 +321,9 @@ found:
macaddr_hi = htons(0x2acb);
bcopy(&macaddr_hi, &sc->cdce_arpcom.ac_enaddr[0],
sizeof(u_int16_t));
- bcopy(&ticks, &sc->cdce_arpcom.ac_enaddr[2], sizeof(u_int32_t));
+ getmicrotime(&now);
+ macaddr_lo = htonl(now.tv_usec);
+ bcopy(&macaddr_lo, &sc->cdce_arpcom.ac_enaddr[2], sizeof(u_int32_t));
sc->cdce_arpcom.ac_enaddr[5] = (u_int8_t)(sc->cdce_unit);
} else {
for (i = 0; i < ETHER_ADDR_LEN * 2; i++) {