From owner-freebsd-net@FreeBSD.ORG Tue Mar 17 21:27:57 2009 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9532A1065706 for ; Tue, 17 Mar 2009 21:27:57 +0000 (UTC) (envelope-from dhorn2000@gmail.com) Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.29]) by mx1.freebsd.org (Postfix) with ESMTP id 16EA18FC1F for ; Tue, 17 Mar 2009 21:27:56 +0000 (UTC) (envelope-from dhorn2000@gmail.com) Received: by yx-out-2324.google.com with SMTP id 8so122981yxm.13 for ; Tue, 17 Mar 2009 14:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=azTHmkEML61UEJMSaSxVJbs9lvE+15v7fiy8o39ufus=; b=fLkz4EfBCcShq2nAosO+Pyg+htU5Q0IJvyFYrI632u+oj96pFCeQQK8LZtEqpzGljJ iUI3ZekiqKKwyoafthL5nngbcz4CUHxJ+z+orsNS36UM+y4vmZ6ieDQhKa0zxL0D2TWc vil3LG79RdHqnc5JSPc76ErqGn6i6aiDgS0p0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=fmvtZWB9Dh/LpaiuNgloAQeoEtFTrnhy2pqfxeXiFHIoTzh/impzB8Mb2QMflibpBc SWD+AhfbzI6XdBlPcsVJZGgAK5IJSTwb6B+ijNfRpq6iHGnLZ2psAkByuYHrRviv9zuZ pSHLtcUxcA8UDfVzJr5m9vzUts5kI7begQcBQ= MIME-Version: 1.0 Received: by 10.231.10.140 with SMTP id p12mr209788ibp.50.1237325275548; Tue, 17 Mar 2009 14:27:55 -0700 (PDT) Date: Tue, 17 Mar 2009 17:27:55 -0400 Message-ID: <25ff90d60903171427y4032d11es516d7b757fc3b8e0@mail.gmail.com> From: David Horn To: freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Dynamic loading of network kernel modules? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Mar 2009 21:27:58 -0000 I made a minor change to ifconfig to try kldloading the interface name specified on the create wlandev XXXX (ifconfig already tries for normal invocations, just needed to try with the wlandev interface) /usr/src/sbin/ifconfig/ifieee80211.c --- ifieee80211.c.original 2009-03-17 16:53:29.000000000 -0400 +++ ifieee80211.c 2009-03-17 16:53:43.000000000 -0400 @@ -4673,6 +4673,7 @@ memcmp(params.icp_bssid, zerobssid, sizeof(zerobssid)) == 0) errx(1, "no bssid specified for WDS (use wlanbssid)"); ifr->ifr_data = (caddr_t) ¶ms; + ifmaybeload(params.icp_parent); if (ioctl(s, SIOCIFCREATE2, ifr) < 0) err(1, "SIOCIFCREATE2"); } This works nicely, however at startup, I still do not get the interface up, or the kernel module loaded, so a second patch is needed. At issue is the list_net_interfaces() function in /etc/rc.d/network.subr, which assumes that the greatest possible list of interfaces is that which 'ifconfig -l' can give us. Unfortunately, this puts us in a bit of a chicken and egg situation for network interfaces that are modules. I also have a patch to network.subr that will look for any manually configured interfaces in rc.conf that are not in the list of 'ifconfig -l', and will try to start those interfaces as well. {specifically looking for ifconfig_xxx and wlans_xxx and ipv6_ifconfig_xxx} /etc/network.subr --- network.subr.base_0317 2009-03-17 17:00:01.000000000 -0400 +++ network.subr 2009-03-17 17:10:15.000000000 -0400 @@ -690,6 +690,34 @@ return 0 } +# getconf_ifnames +# Return the value of all of the interfaces names referenced in rc.conf +# This is used to attempt to dynamically load kernel modules that +# are not already loaded, but could also be useful elsewhere +# +# wlans_IF, ifconfig_IF, ipv6_ifconfig_IF are currently used +getconf_ifnames() +{ + local val + matching_vars=`set | grep -e "ifconfig_" -e "^wlans_" | tr "\n" " " | tr -d "'=."` + debug "Here is a list of all of the matching variables: $matching_vars" + for i in ${matching_vars}; do + val="" + val="`expr "${i}" : 'ifconfig_\([a-zA-Z]*[0-9]*\).*'`" + if [ -z "$val" ]; then + val="`expr "${i}" : 'wlans_\([a-zA-Z]*[0-9]*\).*'`" + fi + if [ val != "0" -a -n "$val" ]; then + interfaces="${interfaces} $val" + fi + done + + debug "Here are the rc.conf potential interfaces: $interfaces" + echo "$interfaces" + exit 0 +} + + # # list_net_interfaces type # List all network interfaces. The type of interface returned @@ -712,6 +740,9 @@ [Aa][Uu][Tt][Oo]) _prefix='' _autolist="`ifconfig -l`" + _manuallist="`getconf_ifnames`" + _autolist="$_autolist$_manuallist" + debug "list of all interfaces: $_autolist" _lo= for _if in ${_autolist} ; do if autoif $_if; then Is this something that people would be interested in having commited? If so, I can clean up a little bit and remove the duplicate interfaces and debugging, and add getconf_ifnames() in more places. Both patches are against current from today (031709). --Thanks! -_Dave Horn