Dynamic loading of network kernel modules?
David Horn
dhorn2000 at gmail.com
Tue Mar 17 14:27:58 PDT 2009
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
More information about the freebsd-net
mailing list