From owner-freebsd-net Tue Jul 16 12:12: 7 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5EA3537B400 for ; Tue, 16 Jul 2002 12:12:04 -0700 (PDT) Received: from isilon.com (isilon.com [65.101.129.58]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0C97143E65 for ; Tue, 16 Jul 2002 12:12:04 -0700 (PDT) (envelope-from bbaumann@isilon.com) Received: from localhost (localhost [127.0.0.1]) by isilon.com (8.12.2/8.11.1) with ESMTP id g6GJC3l3015522 for ; Tue, 16 Jul 2002 12:12:03 -0700 (PDT) (envelope-from bbaumann@isilon.com) Date: Tue, 16 Jul 2002 12:12:03 -0700 (PDT) From: Bill Baumann To: freebsd-net@FreeBSD.ORG Subject: Inconsistency between net/if.c and several ethernet drivers Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org In net/if.c in a couple of places, the ethernet address is needed. This is stored in the arpcom structure. A couple lines of code in if.c require struct arpcom be at the very begining of device softc structures. Nearly all drivers observe this. However, several do not. Sadly, this includes the one I'm working on. net/if.c routines if_findindex() and if_setlladdr() gain access to the ethernet address via the following expression: ((struct arpcom *)ifp->if_softc)->ac_enaddr The above code assumes that the if_softc pointer is equivalent to an struct arpcom pointer. The awi, ray, lnc and pdq drivers have other fields at the beginning of their softc structures. Attempts to set the ethernet address of these devices may cause corruption. Shouldn't access of arpcom be via ifp instead? ((struct arpcom *)ifp)->ac_enaddr For example, if_ethersubr.c uses the following macro: #define IFP2AC(IFP) ((struct arpcom *)IFP) It looked to me like the other code in net, like if_ethersubr.c use ifp rather than if_softc to find struct arpcom. Bug? - Bill Baumann (bbaumann@isilon.com) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message