From owner-freebsd-current@FreeBSD.ORG Sat May 12 16:41:13 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B653916A406 for ; Sat, 12 May 2007 16:41:13 +0000 (UTC) (envelope-from fli@FreeBSD.org) Received: from mx1.h3q.net (mx1.h3q.net [212.37.5.30]) by mx1.freebsd.org (Postfix) with ESMTP id 7A65C13C46A for ; Sat, 12 May 2007 16:41:13 +0000 (UTC) (envelope-from fli@FreeBSD.org) Received: from [192.168.1.100] (81-232-22-115-no50.tbcn.telia.com [81.232.22.115]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: fli@shapeshifter.se) by mx1.h3q.net (Postfix) with ESMTP id D1C0978C20 for ; Sat, 12 May 2007 18:17:44 +0200 (CEST) Message-ID: <4645E8A2.1040408@FreeBSD.org> Date: Sat, 12 May 2007 18:17:38 +0200 From: Fredrik Lindberg User-Agent: Thunderbird 2.0.0.0 (X11/20070420) MIME-Version: 1.0 To: freebsd-current@freebsd.org Content-Type: multipart/mixed; boundary="------------040803070207010108080003" Subject: Network interface modules keeps re-loading X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 May 2007 16:41:13 -0000 This is a multi-part message in MIME format. --------------040803070207010108080003 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi Due to some exciting interaction between kldunload, devctl/devd, rc(8) and ifconfig it's currently impossible to unload a network interface module (without stopping devd first). What happens is that in kldunload during detach a INET DETACH devctl message is generated which is picked up by devd. devd will proceed by executing the default handler associated with this message, this happens to be /etc/pccard_ether foo0 stop. pccard_ether stop will run rc.d/netif stop foo0 which in turn executes, among other things, ifconfig_down foo0. ifconfig_down is defined in /etc/network.subr and runs as a last test the following code if ifexists $1; then ifconfig $1 down _cfg=0 fi Now, it starts to get interesting, ifexists is defined like this ifexists() { ifconfig $1 > /dev/null 2>&1 } This is all fine, except that the shiny new feature in ifconfig called ifmaybeload() will load non existing drivers, and viola, we're back where we started. The feature of having ifconfig loading modules was discussed briefly on current@ a while ago, but apparently nothing came out of it. ifmaybeload() is called quite early in ifconfig, my suggestion is to only call it if there is at least one more argument except the interface name given on the command line. This way the loading will still be there if one executes ifconfig foo0 up but not if one does ifconfig foo0. Or modify the rc-scripts in some mysterious ways to work around this. Fredrik Lindberg --------------040803070207010108080003 Content-Type: text/plain; name="ifconfig.c-20070512" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ifconfig.c-20070512" Index: ifconfig.c =================================================================== RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.130 diff -u -u -r1.130 ifconfig.c --- ifconfig.c 24 Mar 2007 20:26:54 -0000 1.130 +++ ifconfig.c 12 May 2007 16:13:39 -0000 @@ -229,7 +229,8 @@ argc--, argv++; /* check and maybe load support for this interface */ - ifmaybeload(ifname); + if (argc >= 1) + ifmaybeload(ifname); ifindex = if_nametoindex(ifname); if (ifindex == 0) { --------------040803070207010108080003--