From owner-p4-projects@FreeBSD.ORG Wed Mar 26 21:48:45 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 20AA5106567F; Wed, 26 Mar 2008 21:48:45 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2AD21065675 for ; Wed, 26 Mar 2008 21:48:44 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id C459F8FC1B for ; Wed, 26 Mar 2008 21:48:44 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m2QLmig4098025 for ; Wed, 26 Mar 2008 21:48:44 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m2QLmiaD098023 for perforce@freebsd.org; Wed, 26 Mar 2008 21:48:44 GMT (envelope-from brooks@freebsd.org) Date: Wed, 26 Mar 2008 21:48:44 GMT Message-Id: <200803262148.m2QLmiaD098023@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Cc: Subject: PERFORCE change 138669 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Mar 2008 21:48:46 -0000 http://perforce.freebsd.org/chv.cgi?CH=138669 Change 138669 by brooks@brooks_coredump on 2008/03/26 21:47:51 Checkpoint support for creating vap devices with vaps_ specfying a list of vaps to attach to an interface. The list is processed when the physical interface is attached or detached. vap_create_ variables can be used to specify additional arguments (other than wlandev) to the creation process. This is totally untested and likely contains bugs, but it's a start. Affected files ... .. //depot/projects/vap/etc/defaults/rc.conf#6 edit .. //depot/projects/vap/etc/network.subr#4 edit .. //depot/projects/vap/etc/rc.d/netif#4 edit Differences ... ==== //depot/projects/vap/etc/defaults/rc.conf#6 (text+ko) ==== @@ -180,6 +180,7 @@ #ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry. #ifconfig_ed0_ipx="ipx 0x00010010" # Sample IPX address family entry. #ifconfig_fxp0_name="net0" # Change interface name from fxp0 to net0. +#vaps_ath0="ath0_main" # VAP interfaces for ath0 device #ipv4_addrs_fxp0="192.168.0.1/24 192.168.1.1-5/28" # example IPv4 address entry. # #autobridge_interfaces="bridge0" # List of bridges to check ==== //depot/projects/vap/etc/network.subr#4 (text+ko) ==== @@ -30,6 +30,56 @@ # Requires that rc.conf be loaded first. # +# ifn_start ifn +# Bring up and configure an interface. If some configuration is applied +# print the interface configuration. +# +ifn_start() +{ + local ifn cfg + ifn="$1" + cfg=1 + + [ -z "$ifn" ] && err 1 "ifn_start called without an interface" + + ifscript_up ${ifn} && cfg=0 + ifconfig_up ${ifn} && cfg=0 + ipv4_up ${ifn} && cfg=0 + ipx_up ${ifn} && cfg=0 + childif_create ${ifn} && cfg=0 + + if [ "$cfg" -eq 0 ]; then + ifconfig ${ifn} + fi + + return $cfg +} + +# ifn_start ifn +# Shutdown and de-configure an interface. If action is taken print the +# interface name. +# +ifn_stop() +{ + local ifn cfg + ifn="$1" + cfg=1 + + [ -z "$ifn" ] && return 1 + + ipx_down ${ifn} && cfg=0 + ipv4_down ${ifn} && cfg=0 + ifconfig_down ${ifn} && cfg=0 + ifscript_down ${ifn} && cfg=0 + childif_destroy ${ifn} && cfg=0 + + if [ "$cfg" -eq 0 ]; then + echo -n " ${ifn}" + fi + + return $cfg +} + # ifconfig_up if # Evaluate ifconfig(8) arguments for interface $if and # run ifconfig(8) with those arguments. It returns 0 if @@ -426,13 +476,7 @@ _prefix= _list= for ifn in ${cloned_interfaces}; do - _wlandev=`expr "$ifn" : 'wlan:\(.*\)'` - if [ -n "$_wlandev" ]; then - ifn="wlan"; - ifconfig ${ifn} create wlandev $_wlandev - else - ifconfig ${ifn} create - fi + ifconfig ${ifn} create if [ $? -eq 0 ]; then _list="${_list}${_prefix}${ifn}" [ -z "$_prefix" ] && _prefix=' ' @@ -458,6 +502,44 @@ debug "Destroyed clones: ${_list}" } +# Create and configure child interfaces. +# Return 0 if child interfaces are created. +# +childif_create() +{ + local cfg child child_vaps create_args ifn i + cfg=1 + + ifn=$1 + + # Create VAPs + child_vaps=`get_if_var $ifn vaps_IF` + for child in ${child_vaps}; do + create_args="wlandev $ifn `get_if_var $child vap_create_IF`" + if expr $child : 'wlan[0-9][0-9]*$' >/dev/null 2>&1; then + ifconfig $child create ${create_args} && cfg=0 + else + i=`ifconfig wlan create ${create_args}` + ifconfig $i name $child && cfg=0 + fi + ifn_start + done + + return +} + +# Destroy child interfaces. +# +childif_destroy() +{ + local cfg child child_vaps ifn + + child_vaps=`get_if_var $ifn vaps_IF` + for child in ${child_vaps}; do + ifconfig $child destroy && cfg=0 + done +} + # Create netgraph nodes. # ng_mkpeer() { ==== //depot/projects/vap/etc/rc.d/netif#4 (text+ko) ==== @@ -68,7 +68,7 @@ fi # Configure the interface(s). - network_common ifn_start verbose + network_common ifn_start if [ -f /etc/rc.d/ipfilter ] ; then # Resync ipfilter @@ -92,34 +92,31 @@ echo '.' } -# network_common routine verbose +# network_common routine # Common configuration subroutine for network interfaces. This # routine takes all the preparatory steps needed for configuriing -# an interface and then calls $routine. If $verbose is specified, -# it will call ifconfig(8) to show, in long format, the configured -# interfaces. If $verbose is not given, it will simply output the -# configured interface(s). +# an interface and then calls $routine. network_common() { - local _cooked_list _fail _func _verbose + local _cooked_list _fail _func _func= - _verbose= if [ -z "$1" ]; then err 1 "network_common(): No function name specified." else _func="$1" fi - [ -n "$2" ] && _verbose=yes # Set the scope of the command (all interfaces or just one). # _cooked_list= if [ -n "$cmdifn" ]; then - # Don't check that the interfaces exist. We need to run + # Don't check that the interface(s) exist. We need to run # the down code even when the interface doesn't exist to # kill off wpa_supplicant. + # XXXBED: is this really true or does wpa_supplicant die? + # if so, we should get rid of the devd entry _cooked_list="$cmdifn" else _cooked_list="`list_net_interfaces`" @@ -127,59 +124,13 @@ _fail= for ifn in ${_cooked_list}; do - if ${_func} ${ifn} ; then - eval showstat_$ifn=1 - else - _fail="$_fail $ifn" + if !${_func} ${ifn} $2; then + _fail="${_fail} ${ifn} fi done - # Display interfaces configured by this script - # - for ifn in ${_cooked_list}; do - eval showstat=\$showstat_${ifn} - if [ ! -z ${showstat} ]; then - if [ -n "$_verbose" ]; then - ifconfig ${ifn} - else - echo -n " ${ifn}" - fi - fi - done debug "The following interfaces were not configured: $_fail" } -ifn_start() -{ - local ifn cfg - ifn="$1" - cfg=1 - - [ -z "$ifn" ] && return 1 - - ifscript_up ${ifn} && cfg=0 - ifconfig_up ${ifn} && cfg=0 - ipv4_up ${ifn} && cfg=0 - ipx_up ${ifn} && cfg=0 - - return $cfg -} - -ifn_stop() -{ - local ifn cfg - ifn="$1" - cfg=1 - - [ -z "$ifn" ] && return 1 - - ipx_down ${ifn} && cfg=0 - ipv4_down ${ifn} && cfg=0 - ifconfig_down ${ifn} && cfg=0 - ifscript_down ${ifn} && cfg=0 - - return $cfg -} - load_rc_config $name run_rc_command $*