summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2016-02-12 02:53:44 +0000
committerdteske <dteske@FreeBSD.org>2016-02-12 02:53:44 +0000
commit926c812b2fb8f65359b48dec9478ae433ffdb315 (patch)
tree7ec500f282d3563c39dc1b56e53d2b0323b7e48a /share
parentf6c9bac41e0af34b809d7c1847d86cb382f3e39f (diff)
downloadFreeBSD-src-926c812b2fb8f65359b48dec9478ae433ffdb315.zip
FreeBSD-src-926c812b2fb8f65359b48dec9478ae433ffdb315.tar.gz
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).
Diffstat (limited to 'share')
-rwxr-xr-xshare/examples/jails/jib19
-rwxr-xr-xshare/examples/jails/jng23
2 files changed, 24 insertions, 18 deletions
diff --git a/share/examples/jails/jib b/share/examples/jails/jib
index 934b5ed..acf64ac 100755
--- a/share/examples/jails/jib
+++ b/share/examples/jails/jib
@@ -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
}
diff --git a/share/examples/jails/jng b/share/examples/jails/jng
index 9b905c6..f9af70c 100755
--- a/share/examples/jails/jng
+++ b/share/examples/jails/jng
@@ -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
}
OpenPOWER on IntegriCloud