From owner-svn-src-stable@FreeBSD.ORG Sat Nov 13 00:55:17 2010 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 010DE1065672; Sat, 13 Nov 2010 00:55:17 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E1D1A8FC16; Sat, 13 Nov 2010 00:55:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oAD0tGQ6029488; Sat, 13 Nov 2010 00:55:16 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oAD0tGLR029486; Sat, 13 Nov 2010 00:55:16 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201011130055.oAD0tGLR029486@svn.freebsd.org> From: Pyun YongHyeon Date: Sat, 13 Nov 2010 00:55:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r215215 - stable/7/sys/dev/sk X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Nov 2010 00:55:17 -0000 Author: yongari Date: Sat Nov 13 00:55:16 2010 New Revision: 215215 URL: http://svn.freebsd.org/changeset/base/215215 Log: MFC r214898: If we got an invalid station address, generate random address. This might be caused by broken BIOS. Reported by: "Mikhail T." aldan.algebra.com> Modified: stable/7/sys/dev/sk/if_sk.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sk/if_sk.c ============================================================================== --- stable/7/sys/dev/sk/if_sk.c Sat Nov 13 00:46:07 2010 (r215214) +++ stable/7/sys/dev/sk/if_sk.c Sat Nov 13 00:55:16 2010 (r215215) @@ -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); @@ -1402,6 +1404,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