Received: by oss.sgi.com id ; Thu, 22 Jun 2000 06:59:05 -0700 Received: from smtprch2.nortelnetworks.com ([192.135.215.15]:20625 "EHLO smtprch2.nortel.com") by oss.sgi.com with ESMTP id ; Thu, 22 Jun 2000 06:58:46 -0700 Received: from zrchb213.us.nortel.com (actually zrchb213) by smtprch2.nortel.com; Thu, 22 Jun 2000 08:53:44 -0500 Received: from zctwb003.asiapac.nortel.com ([47.152.32.111]) by zrchb213.us.nortel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id NKANW3RM; Thu, 22 Jun 2000 08:56:51 -0500 Received: from pwold011.asiapac.nortel.com ([47.181.193.45]) by zctwb003.asiapac.nortel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id NCLF8FRJ; Thu, 22 Jun 2000 23:56:49 +1000 Received: from uow.edu.au (IDENT:akpm@[47.181.194.147]) by pwold011.asiapac.nortel.com (8.9.3/8.9.3) with ESMTP id XAA10039 for ; Thu, 22 Jun 2000 23:56:46 +1000 Message-ID: <39521C2C.B11140A2@uow.edu.au> Date: Fri, 23 Jun 2000 00:01:16 +1000 X-Sybari-Space: 00000000 00000000 00000000 From: Andrew Morton X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.14-15mdk i586) X-Accept-Language: en MIME-Version: 1.0 To: "netdev@oss.sgi.com" Subject: Re: modular net drivers References: Your message of "Thu, 22 Jun 2000 08:44:29 -0400." <39520A2D.498A3E39@mandrakesoft.com> <2460.961679037@ocs3.ocs-net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Orig: Sender: owner-netdev@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;netdev-outgoing Keith Owens wrote: > > Other calls to module functions do not run under the big kernel lock. > Instead they are meant to call open() first which bumps the reference > count. The problem with the net drivers is that they are "opened" within the module constructor, "closed" with the module destructor and their "open" and "close" methods don't (can't) manipulate the refcounts. You see, netdevice.open() is a misnomer. It simply switches an existing, already-open netdevice from 'down' to 'up'. It should be called 'start' (cf netdevice.stop). It's register_netdevice() which registers a device with the kernel and makes all its entry points available for use. register_netdevice is called from within module_init(). Seen in this light, incrementing the refcount within netdevice.open() is kinda arbitrary. All the other netdevice methods should also increment the refcount (yes, racy). Sigh. rm /sbin/rmmod. There. Fixed.