mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-22 15:47:37 +00:00
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).
This commit is contained in:
parent
4fa10b673c
commit
4b9a5d61f2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295556
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user