summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/networking
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-11-22 00:32:32 +0000
committerdteske <dteske@FreeBSD.org>2013-11-22 00:32:32 +0000
commit62d9fef816400b27a1f06fde3aeb944efdb59be7 (patch)
tree929051c93d84ded2b6c452f3d6863f48d473d34e /usr.sbin/bsdconfig/networking
parent5c0e403ebaeb115af439cf30e80116e31497d643 (diff)
downloadFreeBSD-src-62d9fef816400b27a1f06fde3aeb944efdb59be7.zip
FreeBSD-src-62d9fef816400b27a1f06fde3aeb944efdb59be7.tar.gz
Improve network device scanning in the netdev module. First, make it use the
`device.subr' framework (improving performane and reducing sub-shells). Next improve the `device.subr' framework itself. Make use of the `flags' device struct member for network interfaces to indicate if an interface is Active, Wired Ethernet, or 802.11 Wireless. Functions have been added to make checks against the `flags' bit-field quick and efficient. Last, add function for rescanning the network to update the device registers. Remove an unnecessary local (ifn) while we're here (use already provided local `if').
Diffstat (limited to 'usr.sbin/bsdconfig/networking')
-rwxr-xr-xusr.sbin/bsdconfig/networking/devices6
-rw-r--r--usr.sbin/bsdconfig/networking/share/device.subr37
2 files changed, 22 insertions, 21 deletions
diff --git a/usr.sbin/bsdconfig/networking/devices b/usr.sbin/bsdconfig/networking/devices
index 9d65c51..3d209e9 100755
--- a/usr.sbin/bsdconfig/networking/devices
+++ b/usr.sbin/bsdconfig/networking/devices
@@ -28,6 +28,12 @@
#
############################################################ INCLUDES
+# Prevent device.subr (included indirectly) from auto scanning; this will be
+# performed indirectly later via f_dialog_menu_netdev() -- but only after we've
+# successfully completed f_mustberoot_init().
+#
+DEVICE_SELF_SCAN_ALL=NO
+
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
f_dprintf "%s: loading includes..." "$0"
diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr
index 64aac03..02a5d60 100644
--- a/usr.sbin/bsdconfig/networking/share/device.subr
+++ b/usr.sbin/bsdconfig/networking/share/device.subr
@@ -74,8 +74,10 @@ f_dialog_menu_netdev()
#
# Get list of usable network interfaces
#
- local if iflist= # Calculated below
- for if in $( ifconfig -l ); do
+ local devs if iflist= # Calculated below
+ f_device_rescan_network
+ f_device_find "" $DEVICE_TYPE_NETWORK devs
+ for if in $devs; do
# Skip unsavory interfaces
case "$if" in
lo[0-9]*|ppp[0-9]*|sl[0-9]*|faith[0-9]*) continue ;;
@@ -91,9 +93,8 @@ f_dialog_menu_netdev()
if [ "$DIALOG_MENU_NETDEV_KICK_INTERFACES" ]; then
DIALOG_MENU_NETDEV_KICK_INTERFACES=
- local ifn
- for ifn in $iflist; do
- f_quietly ifconfig $ifn up
+ for if in $iflist; do
+ f_quietly ifconfig $if up
done
if [ "$DIALOG_MENU_NETDEV_SLEEP_AFTER_KICK" ]; then
@@ -107,13 +108,14 @@ f_dialog_menu_netdev()
# to the right of the device name.
#
menu_list=$(
- for ifn in $iflist; do
- active=$( ifconfig $ifn 2> /dev/null | awk '
- ($1 == "status:") {
- if ($2 == "active") { print 1; exit }
- }' )
- printf "'%s%s' '%s'\n" \
- $ifn "${active:+*}" "$( f_device_desc $ifn )"
+ for if in $iflist; do
+ f_device_desc $if $DEVICE_TYPE_NETWORK desc
+ f_shell_escape "$desc" desc
+ if f_device_is_active $if; then
+ printf "'%s\*' '%s'\n" $if "$desc"
+ else
+ printf "'%s' '%s'\n" $if "$desc"
+ fi
done
)
if [ ! "$menu_list" ]; then
@@ -121,21 +123,14 @@ f_dialog_menu_netdev()
return $DIALOG_CANCEL
fi
- #
# Maybe the default item was marked as active
- #
- if [ "$defaultitem" ]; then
- ifconfig "$defaultitem" 2> /dev/null |
- awk '($1 == "status:" && $2 == "active"){exit 1}' ||
- defaultitem="$defaultitem*"
- fi
-
- local hline="$hline_arrows_tab_enter"
+ f_device_is_active "$defaultitem" && defaultitem="$defaultitem*"
#
# Ask user to select an interface
#
local prompt="$msg_select_network_interface"
+ local hline="$hline_arrows_tab_enter"
local height width rows
eval f_dialog_menu_size height width rows \
\"\$DIALOG_TITLE\" \
OpenPOWER on IntegriCloud