Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 May 2007 18:17:38 +0200
From:      Fredrik Lindberg <fli@FreeBSD.org>
To:        freebsd-current@freebsd.org
Subject:   Network interface modules keeps re-loading
Message-ID:  <4645E8A2.1040408@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4645E8A2.1040408>