From owner-svn-src-all@freebsd.org Fri Feb 12 02:53:46 2016 Return-Path: Delivered-To: svn-src-all@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 109D0AA57AB; Fri, 12 Feb 2016 02:53:46 +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 C52F7878; Fri, 12 Feb 2016 02:53:45 +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 u1C2ribN013454; Fri, 12 Feb 2016 02:53:44 GMT (envelope-from dteske@FreeBSD.org) Received: (from dteske@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1C2ridG013452; Fri, 12 Feb 2016 02:53:44 GMT (envelope-from dteske@FreeBSD.org) Message-Id: <201602120253.u1C2ridG013452@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dteske set sender to dteske@FreeBSD.org using -f From: Devin Teske Date: Fri, 12 Feb 2016 02:53:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r295556 - 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-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Feb 2016 02:53:46 -0000 Author: dteske Date: Fri Feb 12 02:53:44 2016 New Revision: 295556 URL: https://svnweb.freebsd.org/changeset/base/295556 Log: Comments and fix small bug Reduce differences between jib/jng and fix a bug that would prevent additional interfaces from being created if the first of many already existed (counter wasn't incremented before calling only continue). Modified: head/share/examples/jails/jib head/share/examples/jails/jng Modified: head/share/examples/jails/jib ============================================================================== --- head/share/examples/jails/jib Fri Feb 12 02:50:36 2016 (r295555) +++ head/share/examples/jails/jib Fri Feb 12 02:53:44 2016 (r295556) @@ -286,13 +286,16 @@ jib_addm() !*) iface=${iface#!} no_derive=1 ;; esac - # 1. Make sure the interface doesn't exist already - ifconfig "e${i}a_$name" > /dev/null 2>&1 && continue + # Make sure the interface doesn't exist already + if ifconfig "e${i}a_$name" > /dev/null 2>&1; then + i=$(( $i + 1 )) + continue + fi - # 2. Bring the interface up + # Bring the interface up ifconfig $iface up || return - # 3. Make sure the interface has been bridged + # Make sure the interface has been bridged if ! ifconfig "$iface$bridge" > /dev/null 2>&1; then new=$( ifconfig bridge create ) || return ifconfig $new addm $iface || return @@ -300,18 +303,18 @@ jib_addm() ifconfig "$iface$bridge" up || return fi - # 4. Create a new interface to the bridge + # Create a new interface to the bridge new=$( ifconfig epair create ) || return ifconfig "$iface$bridge" addm $new || return - # 5. Rename the new interface + # Rename the new interface ifconfig $new name "e${i}a_$name" || return ifconfig ${new%a}b name "e${i}b_$name" || return ifconfig "e${i}a_$name" up || return ifconfig "e${i}b_$name" up || return # - # 6. Set the MAC address of the new interface using a sensible + # Set the MAC address of the new interface using a sensible # algorithm to prevent conflicts on the network. # eiface_devid_a= eiface_devid_b= @@ -322,7 +325,7 @@ jib_addm() ifconfig "e${i}b_$name" ether $eiface_devid_b fi > /dev/null 2>&1 - i=$(( $i + 1 )) # on to next e{i}b_name + i=$(( $i + 1 )) done # for iface } Modified: head/share/examples/jails/jng ============================================================================== --- head/share/examples/jails/jng Fri Feb 12 02:50:36 2016 (r295555) +++ head/share/examples/jails/jng Fri Feb 12 02:53:44 2016 (r295556) @@ -291,18 +291,21 @@ jng_bridge() !*) iface=${iface#!} no_derive=1 ;; esac - # 0. Make sure the interface doesn't exist already + # Make sure the interface doesn't exist already eiface=ng${i}_$name - ngctl msg "$eiface:" getifname > /dev/null 2>&1 && continue + if ngctl msg "$eiface:" getifname > /dev/null 2>&1; then + i=$(( $i + 1 )) + continue + fi - # 1. Bring the interface up + # Bring the interface up ifconfig $iface up || return - # 2. Set promiscuous mode and don't overwrite src addr + # Set promiscuous mode and don't overwrite src addr ngctl msg $iface: setpromisc 1 || return ngctl msg $iface: setautosrc 0 || return - # 3. Make sure the interface has been bridged + # Make sure the interface has been bridged if ! ngctl info ${iface}bridge: > /dev/null 2>&1; then ngctl mkpeer $iface: bridge lower link0 || return ngctl connect $iface: $iface:lower upper link1 || @@ -310,7 +313,7 @@ jng_bridge() ngctl name $iface:lower ${iface}bridge || return fi - # 3.5. Optionally create a secondary bridge + # Optionally create a secondary bridge if [ "$bridge" != "bridge" ] && ! ngctl info "$iface$bridge:" > /dev/null 2>&1 then @@ -326,7 +329,7 @@ jng_bridge() return fi - # 4. Create a new interface to the bridge + # Create a new interface to the bridge num=2 while ngctl msg "$iface$bridge:" getstats $num > /dev/null 2>&1 do @@ -334,7 +337,7 @@ jng_bridge() done ngctl mkpeer "$iface$bridge:" eiface link$num ether || return - # 5. Rename the new interface + # Rename the new interface while [ ${#eiface} -gt 15 ]; do # OS limitation eiface=${eiface%?} done @@ -345,7 +348,7 @@ jng_bridge() ifconfig $eiface up || return # - # 6. Set the MAC address of the new interface using a sensible + # Set the MAC address of the new interface using a sensible # algorithm to prevent conflicts on the network. # eiface_devid= @@ -358,7 +361,7 @@ jng_bridge() [ "$eiface_devid" ] && ifconfig $eiface ether $eiface_devid > /dev/null 2>&1 - i=$(( $i + 1 )) # on to next ng{i}_name + i=$(( $i + 1 )) done # for iface }