svn commit: r215214 - stable/8/sys/dev/sk
Pyun YongHyeon
yongari at FreeBSD.org
Sat Nov 13 00:46:07 UTC 2010
Author: yongari
Date: Sat Nov 13 00:46:07 2010
New Revision: 215214
URL: http://svn.freebsd.org/changeset/base/215214
Log:
MFC r214898:
If we got an invalid station address, generate random address. This
might be caused by broken BIOS.
Reported by: "Mikhail T." <mi+thun <> aldan.algebra.com>
Modified:
stable/8/sys/dev/sk/if_sk.c
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/dev/sk/if_sk.c
==============================================================================
--- stable/8/sys/dev/sk/if_sk.c Sat Nov 13 00:40:43 2010 (r215213)
+++ stable/8/sys/dev/sk/if_sk.c Sat Nov 13 00:46:07 2010 (r215214)
@@ -1319,8 +1319,10 @@ sk_attach(dev)
struct sk_softc *sc;
struct sk_if_softc *sc_if;
struct ifnet *ifp;
+ u_int32_t r;
int error, i, phy, port;
u_char eaddr[6];
+ u_char inv_mac[] = {0, 0, 0, 0, 0, 0};
if (dev == NULL)
return(EINVAL);
@@ -1400,6 +1402,23 @@ sk_attach(dev)
eaddr[i] =
sk_win_read_1(sc, SK_MAC0_0 + (port * 8) + i);
+ /* Verify whether the station address is invalid or not. */
+ if (bcmp(eaddr, inv_mac, sizeof(inv_mac)) == 0) {
+ device_printf(sc_if->sk_if_dev,
+ "Generating random ethernet address\n");
+ r = arc4random();
+ /*
+ * Set OUI to convenient locally assigned address. 'b'
+ * is 0x62, which has the locally assigned bit set, and
+ * the broadcast/multicast bit clear.
+ */
+ eaddr[0] = 'b';
+ eaddr[1] = 's';
+ eaddr[2] = 'd';
+ eaddr[3] = (r >> 16) & 0xff;
+ eaddr[4] = (r >> 8) & 0xff;
+ eaddr[5] = (r >> 0) & 0xff;
+ }
/*
* Set up RAM buffer addresses. The NIC will have a certain
* amount of SRAM on it, somewhere between 512K and 2MB. We
More information about the svn-src-stable
mailing list