From owner-svn-src-head@freebsd.org Thu Feb 11 22:10:56 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5B963AA6788; Thu, 11 Feb 2016 22:10:56 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 113931F04; Thu, 11 Feb 2016 22:10:55 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u1BMAtTp029386; Thu, 11 Feb 2016 22:10:55 GMT (envelope-from dteske@FreeBSD.org) Received: (from dteske@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1BMAtgc029385; Thu, 11 Feb 2016 22:10:55 GMT (envelope-from dteske@FreeBSD.org) Message-Id: <201602112210.u1BMAtgc029385@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dteske set sender to dteske@FreeBSD.org using -f From: Devin Teske Date: Thu, 11 Feb 2016 22:10:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r295548 - head/share/examples/jails X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Feb 2016 22:10:56 -0000 Author: dteske Date: Thu Feb 11 22:10:54 2016 New Revision: 295548 URL: https://svnweb.freebsd.org/changeset/base/295548 Log: Add support for bridging iwn(4) based wlan(4) Documented in iwn(4), "Only one virtual interface may be configured at any time." However, netgraph with a cloned MAC address is able to communicate over an ng_eiface attached to an ng_bridge linked to the wlan(4) interface. While here, introduce syntax to specify the MAC address is to be cloned if the named interface begins with equals [=]. Modified: head/share/examples/jails/jng Modified: head/share/examples/jails/jng ============================================================================== --- head/share/examples/jails/jng Thu Feb 11 21:32:23 2016 (r295547) +++ head/share/examples/jails/jng Thu Feb 11 22:10:54 2016 (r295548) @@ -265,7 +265,7 @@ mustberoot_to_continue() fi } -jng_bridge_usage="bridge [-b BRIDGE_NAME] NAME interface0 [interface1 ...]" +jng_bridge_usage="bridge [-b BRIDGE_NAME] NAME [=]iface0 [[=]iface1 ...]" jng_bridge_descr="Create ng0_NAME [ng1_NAME ...]" jng_bridge() { @@ -286,10 +286,15 @@ jng_bridge() mustberoot_to_continue - local iface eiface eiface_devid - local new num quad i=0 + local iface parent eiface eiface_devid + local new clone_mac num quad i=0 for iface in $*; do + clone_mac= + case "$iface" in + =*) iface=${iface#=} clone_mac=1 ;; + esac + # 0. Make sure the interface doesn't exist already eiface=ng${i}_$name ngctl msg "$eiface:" getifname > /dev/null 2>&1 && continue @@ -347,7 +352,23 @@ jng_bridge() # 6. Set the MAC address of the new interface using a sensible # algorithm to prevent conflicts on the network. # - derive_mac $iface "$name" eiface_devid + case "$iface" in + wlan[0-9]*) + parent=$( sysctl -n net.wlan.${iface#wlan}.%parent ) + case "$parent" in + iwn[0-9]*) + # iwn(4) supports only 1 virtual net at a time + # NB: Cloning MAC allows new interface to work + clone_mac=1 ;; + esac + esac + if [ "$clone_mac" ]; then + eiface_devid=$( + ifconfig $iface ether | awk '/ether/,$0=$2' + ) + else + derive_mac $iface "$name" eiface_devid + fi ifconfig $eiface ether $eiface_devid i=$(( $i + 1 )) # on to next ng{i}_name