Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 May 2010 16:20:49 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        net@freebsd.org
Cc:        Brooks Davis <brooks@freebsd.org>
Subject:   Re: Workaround automatic re-loading of network drivers
Message-ID:  <201005031620.49141.jhb@freebsd.org>
In-Reply-To: <201005031527.18468.jhb@freebsd.org>
References:  <201005031527.18468.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 03 May 2010 3:27:18 pm John Baldwin wrote:
> While testing some changes with vlans and the new vlan_<if> syntax in rc.conf 
> I've noticed the following behavior:
> 
> 	ifconfig foo0.100 destroy
> 
> Will actually try to kldload the 'foo' driver.  This can prove very non-
> intuitive.  In general I think we shouldn't try to kldload anything when 
> destroying an interface period.  What I've done locally is to pass '-n' to 
> ifconfig when destroying an interface.
> 
> We should possibly fix some other bugs however.  For example, ifmaybeload() in 
> ifconfig should probably stop at the first non-digit it finds (e.g. ".") 
> rather than trimming from the first digit on.  Also, perhaps 'ifconfig <foo> 
> destroy' should imply -n without requiring it to be explicit.
> 
> I also moved the ifconfig destroy of wlan and vlan devices up before running 
> ifn_stop to prevent running 'ifconfig <foo> down' which would also reload the 
> driver due to the first bug in ifconfig.

I've noticed since sending this that the calls to ifn_stop when destroying
child interfaces are now superfluous in this patch since they are now moved
to after the destroy (devd will kick them off after the destroy runs), so
I've now removed them entirely.

Index: network.subr
===================================================================
--- network.subr	(revision 207329)
+++ network.subr	(working copy)
@@ -915,7 +915,7 @@
 	_list=
 
 	for ifn in ${cloned_interfaces}; do
-		ifconfig ${ifn} destroy
+		ifconfig -n ${ifn} destroy
 		if [ $? -eq 0 ]; then
 			_list="${_list}${_prefix}${ifn}"
 			[ -z "$_prefix" ] && _prefix=' '
@@ -1000,10 +1000,7 @@
 		if ! ifexists $child; then
 			continue
 		fi
-		if autoif $child; then
-			ifn_stop $child
-		fi
-		ifconfig $child destroy && cfg=0
+		ifconfig -n $child destroy && cfg=0
 	done
 
 	child_vlans=`get_if_var $ifn vlans_IF`
@@ -1014,10 +1011,7 @@
 		if ! ifexists $child; then
 			continue
 		fi
-		if autoif $child; then
-			ifn_stop $child
-		fi
-		ifconfig $child destroy && cfg=0
+		ifconfig -n $child destroy && cfg=0
 	done
 
 	return ${cfg}

-- 
John Baldwin



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